const int ledPin = 13;
const int btnPin = 2;
int ledState = LOW;
int btnState = HIGH;
void setup() {
pinMode(ledPin, OUTPUT);
pinMode(btnPin, INPUT_PULLUP);
digitalWrite(ledPin, ledState);
}
void loop() {
if (digitalRead(btnPin) == LOW)
{
if (btnState != LOW)
{
ledState = !ledState;
digitalWrite(ledPin, ledState);
}
btnState = LOW;
}
else
{
btnState = HIGH;
}
delay(100);
}