-
-
Save JeffersGlass/8773bf13e2f15eb18747b7e3a2eb8da8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const int leds[] = {9, 10, 11, 12, 13}; | |
const int NUMLEDS = 5; | |
const int knobPin = A5; | |
const int button1 = 7; | |
const int button2 = 8; | |
int loopStep = 1; | |
int i = 0; | |
void setup() { | |
// put your setup code here, to run once: | |
for (int i = 0; i < NUMLEDS; i++){ | |
pinMode(leds[i], OUTPUT); | |
digitalWrite(leds[i], LOW); | |
} | |
pinMode(knobPin, INPUT); | |
pinMode(button1, INPUT_PULLUP); | |
pinMode(button2, INPUT_PULLUP); | |
} | |
void loop() { | |
// put your main code here, to run repeatedly: | |
digitalWrite(leds[i], HIGH); | |
delay(analogRead(knobPin)); | |
digitalWrite(leds[i], LOW); | |
i = (i + loopStep) % NUMLEDS; | |
if (i < 0) i = NUMLEDS-1; | |
if (digitalRead(button1) == LOW) loopStep = -1; | |
if (digitalRead(button2) == LOW) loopStep = 1; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment