Created
December 25, 2011 01:17
-
-
Save michaeltwofish/1518597 to your computer and use it in GitHub Desktop.
cycling 8 LEDs
This file contains hidden or 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
int ledPins[] = {2,3,4,5,6,7,8,9}; | |
int duration = 100; | |
int inLeft[] = {0, 8, 1}; | |
int inRight[] = {7, -1, -1}; | |
void setup() { | |
// This is weird, inRight only works if I do this | |
Serial.begin(9600); | |
// initialize the digital pins as an output. | |
for (int i = 0 ; i < 8; i++) { | |
pinMode(ledPins[i], OUTPUT); | |
} | |
} | |
void loop() { | |
for (int j = 0 ; j < 5; j++) { | |
seq(inLeft, HIGH); | |
seq(inRight, LOW); | |
} | |
for (int j = 0 ; j < 5; j++) { | |
seq(inLeft, HIGH); | |
seq(inLeft, LOW); | |
} | |
for (int j = 0 ; j < 5; j++) { | |
seq(inRight, HIGH); | |
seq(inLeft, LOW); | |
} | |
for (int j = 0 ; j < 5; j++) { | |
seq(inRight, HIGH); | |
seq(inRight, LOW); | |
} | |
} | |
void seq(int param[], boolean power) { | |
for (int i = param[0]; i != param[1]; i += param[2]) { | |
digitalWrite(ledPins[i], power); | |
delay(duration); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment