int btnPin = 2;
int ledPin1 = 9;//LED 1
int ledPin2 = 10;//LED 2
int btnState = 0;
int prevBtnState = 0;
int counter = 0;
void setup() {
// Open the serial port
Serial.begin(9600);
// set the button pin to be an input
pinMode(btnPin, INPUT);
// set the LED pin to be an OUTPUT
pinMode(ledPin1, OUTPUT);
pinMode(ledPin2, OUTPUT);
}
void loop() {
// read the button pin
btnState = digitalRead(btnPin);
// check if the button state has changed
if(btnState != prevBtnState){
// print the changed state
Serial.print("Button state changed to: ");
Serial.println(btnState);
prevBtnState =1;
if (btnState == HIGH) {
int remainder = counter % 3;
digitalWrite(ledPin1, remainder != 0);
digitalWrite(ledPin2, remainder > 1);
Serial.println(remainder);
counter++;
}
if (btnState == LOW) {
prevBtnState = 0;
}
}
delay(10);
}