Created
October 20, 2014 05:21
-
-
Save jimwhitfield/960fb85c4f4ac36a8113 to your computer and use it in GitHub Desktop.
random_leds - randomly turn LEDs on and off
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 PIN_BASE=4; // lowest pin to use. | |
int PIN_CT=6; // number of LEDs attached | |
int delayBase=35; // a heartbeat, of sorts. in milliseconds. | |
void setup() { | |
// initialize digital pins (base) to (base+count) as output: | |
for (int i = PIN_BASE; i <= PIN_BASE+PIN_CT; i++) { | |
pinMode(i, OUTPUT); | |
} | |
randomSeed(analogRead(0)); | |
} | |
void loop(){ | |
digitalWrite(random(PIN_BASE,PIN_BASE+PIN_CT+1), random(LOW,HIGH+1) ); | |
delay(random(1,3)* delayBase); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment