Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const int MaxState = 8;
- int state = 1;
- unsigned long currentMillis;
- unsigned long previousMillis;
- unsigned long interval=2000;
- //arrays are zero based, so ignore the first element
- //fill this with the pin numbers of your LEDs, in order
- int ledArray[] = {0,1,2,3,4,5,6,7};
- void loop() {
- currentMillis = millis();
- if (currentMillis - previousMillis >= interval) {
- digitalWrite(ledArray[state], HIGH);
- state++;
- if (state == MaxState) {
- // turn off all the LEDs
- state = 1;
- }
- previousMillis = currentMillis;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement