I'm trying to make a drag race practice tree. It has a stage light that turns on when you press a button then, a timer that runs and turns on a yellow when it's done. Then it will show a red light if you let off the button early or a green light if you were on time
int stage = 1; //the switch for stage will go here
int stageLight = 12; //stage light output
int yellowLight = 11; //tree amber light output
int greenLight = 10; //tree green light output
int redLight = 9; //tree red light output
void setup()
{
pinMode(stage, INPUT);
pinMode(stageLight, OUTPUT);
pinMode(yellowLight, OUTPUT);
pinMode(greenLight, OUTPUT);
pinMode(redLight, OUTPUT);
}
void loop()
{
if(analogRead(stage) == HIGH);
{
digitalWrite(stageLight, HIGH);
delay(500);
digitalWrite(yellowLight, HIGH);
}
}
I need someway to know if I'm letting go of the button to soon which would turn the red light on or at the correct time which would turn the green light on.