Hi i am looking to write code to have a Green Led flashing every 5 seconds and when a push button is pressed 5000 times a blue led starts flashing and the green led goes off. There is a second push button and if that is pressed a red led goes on and the green and blue turn off. Only 1 led can be flashing at a time and i cant use the delay function to flash the led as the delay is too long. I have attached the code i have with no flashing. Thanks
int COUNT = 0;
void setup()
{
pinMode(12, INPUT);//Push button 1
pinMode(7, OUTPUT);// Green led;
pinMode(5, OUTPUT);// Blue led
pinMode(11, INPUT);// Push button 2
pinMode(6, OUTPUT);// Red led
Serial.begin(9600);
}
void loop()
{
if (digitalRead(12) == 1) {
if (COUNT < 5000) {
COUNT += 1;
digitalWrite(7, HIGH);
delay(1000); // Wait for 1000 millisecond(s)
} else {
if (COUNT >= 5000) {
digitalWrite(5, HIGH);
digitalWrite(7, LOW);
}
}
}
if (digitalRead(11) == 1) {
digitalWrite(6, HIGH);
digitalWrite(5, LOW);
digitalWrite(7, LOW);
}
Serial.println(COUNT);
}