All submissions

Solving Approach:

Connect 5LEDS and a potentiometer to an arduino. Read the pot value. 

Code

#define POTENTIOMETER A0
#define LED1 11
#define LED2 10
#define LED3 9
#define LED4 6
#define LED5 5


int potValue = 0;
int potValueOld = 0;

void setup() 
{
  pinMode(POTENTIOMETER, INPUT);
  pinMode(LED1, OUTPUT);
  pinMode(LED2, OUTPUT);
  pinMode(LED3, OUTPUT);
  pinMode(LED4, OUTPUT);
  pinMode(LED5, OUTPUT);

}

void loop() 
{
  potValue = analogRead(POTENTIOMETER);

  potValue = map(potValue, 0, 1023, 0, 255);
  
  if(potValue > potValueOld)
  {
    analogWrite(LED1, potValue);
    delay(200);
    analogWrite(LED2, potValue);
    delay(200);
    analogWrite(LED3, potValue);
    delay(200);
    analogWrite(LED4, potValue);
    delay(200);
    analogWrite(LED5, potValue);
    delay(200);
  }
  else
  {
    analogWrite(LED5, potValue);
    delay(200);
    analogWrite(LED4, potValue);
    delay(200);
    analogWrite(LED3, potValue);
    delay(200);
    analogWrite(LED2, potValue);
    delay(200);
    analogWrite(LED1, potValue);
    delay(200);
  }

  potValueOld = potValue;

}



 

Output

Video

Video of output (know more)

Photo of Output

 

Submit Your Solution

Note: Once submitted, your solution goes public, helping others learn from your approach!