const int buttonPin = 4; // the pin number of the pushbutton pin
int buttonState = 0; // variable for storing the pushbutton status
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
pinMode(buttonPin, INPUT); // initialize the pushbutton pin as an input
Serial.println("Hello, ESP32!");
}
void loop() {
// read the state of the pushbutton value
buttonState = digitalRead(buttonPin);
if(buttonState == HIGH) {
Serial.print("Tombol Ditekan: ");
Serial.println(buttonState);
} else if(buttonState == LOW) {
Serial.print("Tombol Dilepas: ");
Serial.println(buttonState);
}
delay(300);
}