int ledpin=8;
int buttonpin=7;
int last_state=HIGH;
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
pinMode(buttonpin, INPUT_PULLUP);
pinMode(ledpin, OUTPUT);
}
void loop() {
// put your main code here, to run repeatedly:
int value = digitalRead(buttonpin);
if (last_state != value)
{
last_state=value;
if (value==HIGH)
{
digitalWrite(ledpin, LOW);
Serial.println("led is on button pushed");
}
else{
digitalWrite(ledpin, HIGH);
Serial.println("pressed");
}
}
}