#define BUTTON_PIN 9
void setup() {
Serial.begin(115200);
pinMode(BUTTON_PIN, INPUT_PULLUP);
}
int lastState = HIGH;
void loop() {
int value = digitalRead((BUTTON_PIN));
if (lastState != value) {
lastState = value;
if (value == HIGH) {
Serial.println(" released");
}
if (value == LOW) {
Serial.println(" pressed");
}
}
}
Loading
esp32-c3-rust-1
esp32-c3-rust-1