/*radom delay random blink 8 leds
This sketch created and copyright by Gary C. Granai https://www.facebook.com/gary.granai and is included in the
Arduino For Model Railing Library at https://steamtraininfo.com/arduino-projects
You are free to use this sketch and amend it for your own personal use as long as these credits remain intact.
Using it in any manner or form for commercial purposes is prohibited.*/
int randNumber;
void setup() {
/* This sets 8 leds on pins D2 to D9 to output */
for (int i = 2; i <= 7; i++) {
pinMode(i, OUTPUT); // sets pins to output
}
randomSeed(analogRead(A0)); /*sets the pin to create “static so the the initial LED to light is different
each time through the loop */
}
//***************************************************
void loop() {
BlinkRandomly();
}
//**************************************************
void BlinkRandomly() {
randNumber= random(500, 500);
int LightLED = random(2, 7); //randomly selects LED to light. Must use +1 over the last pin number
//(ie: 9 + 1 = 10)
int dlay = randNumber; // sets the blink rate in milliseconds
digitalWrite(LightLED, HIGH);
delay(dlay);
digitalWrite(LightLED, LOW);
delay(dlay);
}