int ledpin = 8;
int buttonPin = 7;
int ledstate = 0;
int lastButtonState = 0;
void setup() {
// put your setup code here, to run once:
pinMode(7 , INPUT_PULLUP);
pinMode(8,OUTPUT);
Serial.begin(115200);
}
void loop() {
// put your main code here, to run repeatedly:
int currentbuttonstate = digitalRead(buttonPin);
if(currentbuttonstate == 1 && lastButtonState == 0){
ledstate = !ledstate;
}
Serial.println(currentbuttonstate);
digitalWrite(ledpin,ledstate);
lastButtonState = currentbuttonstate;
Serial.print("last :");
Serial.println(lastButtonState);
delay(100);
}