gpio-button-led.ino
Basic example to interact with digital I/O.
Uses GPIO0 as input (button) and GPIO2 as output (LED). The ESP32-S3 handles hardware interrupts if needed. Compile with 'M5Stack-ESP32-S3' board in Arduino IDE.
gpio-button-led.ino
#include <Arduino.h>
// Définir les broches (adapter selon le schéma PaperDIY si nécessaire)
#define BUTTON_PIN 0 // Bouton BOOT intégré ou GPIO externe
#define LED_PIN 2 // LED RGB ou LED externe sur GPIO2
void setup() {
Serial.begin(115200);
pinMode(BUTTON_PIN, INPUT_PULLUP);
pinMode(LED_PIN, OUTPUT);
digitalWrite(LED_PIN, LOW);
}
void loop() {
if (digitalRead(BUTTON_PIN) == LOW) {
digitalWrite(LED_PIN, HIGH);
Serial.println("Bouton pressé");
delay(500);
digitalWrite(LED_PIN, LOW);
}
}