Hey i am very new to Arduino and just getting started. I made the following program in which one button is turning the LED on and another is turning the LED off.
int ledPin = 5;
int buttonApin = 9;
int buttonBpin = 8;
byte leds = 0;
void setup()
{
pinMode(ledPin, OUTPUT);
pinMode(buttonApin, INPUT_PULLUP);
pinMode(buttonBpin, INPUT_PULLUP);
}
void loop()
{
if (digitalRead(buttonApin) == LOW)
{
digitalWrite(ledPin, HIGH);
}
if (digitalRead(buttonBpin) == LOW)
{
digitalWrite(ledPin, LOW);
}
}
Now onto my question is it possible to let "buttonBpin" (in my example) to shut the LED off after i press the button a defined amount of times(like 4 for example)? I can turn the LED on and off after pressing the buttons once but i am stuck going further than that.
Thank you in advance.