Thanks for any help.
Objective:
Have one of the five LED lights turn on and then off (i.e. blink) randomly. This is to be repeated 25 times before stopping.
What is wrong with my code?
// Declare pin names
int light_one = 1;
int light_two = 2;
int light_three = 3;
int light_four = 4;
int light_five = 5;
int light;
int t_delay;
void setup(){
//Serial.begin(9600); // Uncomment this if you want to print things, otherwise it doens't matter
// Initialize Lights -
//The numbers correspond to the switch that the lights are connected to (change based on your config)
pinMode(light_one, OUTPUT);
pinMode(light_two, OUTPUT);
pinMode(light_three, OUTPUT);
pinMode(light_four, OUTPUT);
pinMode(ligth_five, OUTPUT);
}
// Program continually loops
void loop(){
// this is really easy if you have them in pins 1 thru 4 because you can just generate a random in in that space
light = random(1,5);
// If statement isn't necessary if pins are 1-4, however, if arbitrary pins (4,6,8,13) etc.. then just
// re-assign the digitalOutput pin number to the pin/light it's connected to
if(light == 1){
digitalOutput(light_one, HIGH);
}
else if(light == 2){
digitalOutput(light_two, HIGH);
}
else if(light == 3){
digitalOutput(light_three, HIGH);
}
else if(light == 4){
digitalOutput(light_four, HIGH);
}
else if(light == 5){
digitalOutput(light_five, HIGH);
}
// randomize how long the lights are on for between 3 to 6 seconds
t_delay = random(3000, 6000);
delay(t_delay);
// Turn off all lights
// Change the numbers to the corresponidng pin outputs
digitalOutput(light_one, LOW);
digitalOutput(light_two, LOW);
digitalOutput(light_three, LOW);
digitalOutput(light_four, LOW);
digitalOutput(light_five, LOW);
}