const int LED_ID = 3;
const int BUTTON_ID = 8;
int isPressed = 0;
int state = 0;
void setup() {
pinMode(LED_ID, OUTPUT);
digitalWrite(LED_ID, LOW);
pinMode(BUTTON_ID, INPUT);
Serial.begin(9600);
}
void loop() {
isPressed = digitalRead(BUTTON_ID);
if (isPressed && state == 0 )
{
digitalWrite(LED_ID, HIGH);
state = 1;
}
else if (isPressed && state == 1)
{
digitalWrite(LED_ID, LOW);
state = 0;
}
Serial.print(state);
delay(50);
}