Connect 5LEDS and a potentiometer to an arduino. Read the pot value.
#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;
}
Video of output (know more)