ESP32-S3 Project Design
Table
| Function | GPIO | Net | Direction | Notes |
|---|---|---|---|---|
| Key 1 | 4 | KEY1 | Input pull-up | SW1 to GND, active-low |
| Key 2 | 5 | KEY2 | Input pull-up | SW2 to GND, active-low |
| Key 3 | 6 | KEY3 | Input pull-up | SW3 to GND, active-low |
| Key 4 | 7 | KEY4 | Input pull-up | SW4 to GND, active-low |
| Key 5 | 8 | KEY5 | Input pull-up | SW5 to GND, active-low |
| Key 6 | 9 | KEY6 | Input pull-up | SW6 to GND, active-low |
| Key 7 | 10 | KEY7 | Input pull-up | SW7 to GND, active-low |
| Key 8 | 11 | KEY8 | Input pull-up | SW8 to GND, active-low |
| BOOT | 0 | BOOT | Input strap | SW9 to GND for download mode |
| Reset/Enable | EN | ESP_EN | Hardware | R1 10 kΩ to 3V3, C4 1 uF to GND, SW10 to GND |
| USB D- | 19 | USB_D_N | Native USB | J1 DN1/DN2 |
| USB D+ | 20 | USB_D_P | Native USB | J1 DP1/DP2 |
platformio.iniIni
[env:esp32-s3-devkitc-1] platform = espressif32 board = esp32-s3-devkitc-1 framework = arduino monitor_speed = 115200 build_flags = -DARDUINO_USB_MODE=1 -DARDUINO_USB_CDC_ON_BOOT=1
src/main.cppCpp
#include <Arduino.h> static const uint8_t KEY_PINS[8] = {4, 5, 6, 7, 8, 9, 10, 11}; static const char* KEY_NAMES[8] = { "KEY1", "KEY2", "KEY3", "KEY4", "KEY5", "KEY6", "KEY7", "KEY8" }; static bool lastState[8]; static uint32_t lastDebounceMs[8]; const uint32_t DEBOUNCE_MS = 25; void setup() { Serial.begin(115200); delay(1000); Serial.println("ESP32-S3 8-Key Controller starting"); for (uint8_t i = 0; i < 8; i++) { pinMode(KEY_PINS[i], INPUT_PULLUP); lastState[i] = digitalRead(KEY_PINS[i]); lastDebounceMs[i] = millis(); } Serial.println("Keys initialized as active-low inputs with internal pull-ups"); } void loop() { const uint32_t now = millis(); for (uint8_t i = 0; i < 8; i++) { bool raw = digitalRead(KEY_PINS[i]); if (raw != lastState[i] && (now - lastDebounceMs[i]) >= DEBOUNCE_MS) { lastDebounceMs[i] = now; lastState[i] = raw; Serial.printf("%s %s\n", KEY_NAMES[i], raw == LOW ? "PRESSED" : "RELEASED"); } } }
Bash
pio run pio run -t upload pio device monitor
Platform & Toolchain
Pin Mapping
`platformio.ini`
`src/main.cpp`
Build & Flash