void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
Serial.println("Hello, ESP32!");
pinMode(12, OUTPUT);
pinMode(18, INPUT_PULLUP);
}
int nowButtonState, oldButtonState;
void loop() {
// put your main code here, to run repeatedly:
nowButtonState = digitalRead(18);
if(nowButtonState == LOW && oldButtonState == HIGH )
{
digitalWrite(12, !digitalRead(12)); //flip the last valuable to the inverser if last HIGH then LOW
}
//for the poor simulator :(
delay(100);
oldButtonState = nowButtonState;
Serial.print(oldButtonState);
}