#7Intermediate
Speed Adjustable Walking Led
4.6(70)
127 completed

Project that can adjust the LED walking speed in real time with the potentiometer. Teaches to dynamically control the delay time by reading the potentiometer value with analogRead.
Video
Circuit Diagram

Source Code
1int ledPins[] = {2, 3, 4, 5, 6, 7};
2int potValue;
3
4void setup() {
5 for(int i = 0; i < 6; i++) {
6 pinMode(ledPins[i], OUTPUT);
7 }
8}
9
10void loop() {
11 for(int i = 0; i < 6; i++) {
12 potValue = analogRead(A0);
13 digitalWrite(ledPins[i], HIGH);
14 delay(potValue);
15 digitalWrite(ledPins[i], LOW);
16 }
17}