Build a Classroom ESP32 Trainer
The Story
A good ESP32 class starts with one input, one output, one shared ground, and visible feedback. GPIO12 reads the button, GPIO14 drives the LED, and Serial Monitor reports the same state so learners can compare code with hardware. The component list, wiring table, GPIO map, code constants, expected output, troubleshooting, and FAQ now describe the same bench build so a learner can verify each step instead of guessing.
Explain Like I'm 12
The button is like a doorbell for the ESP32. Pressing it changes GPIO12, and the program turns on the LED at GPIO14 as the answer. Prove the local wiring and code first, then add displays, logging, or Wi-Fi after the simple version behaves exactly as expected.
Safety Standards
- Unplug USB before changing jumper wires. Recheck 3.3 V, 5 V, and GND before reconnecting power.
- Do not power motors, pumps, LED strips, or servos from the ESP32 3.3 V pin. Use a suitable external supply and common ground.
- Breadboards are for low-current prototypes. Move high-current or unattended builds to proper terminals, enclosure, strain relief, and fusing.
What You Will Build
A trainer circuit where a push button on GPIO12 controls a status LED on GPIO14 and prints clear state messages to Serial Monitor.
Learning Objectives
- Wire the exact GPIO pins used by the sketch.
- Run the starter code and compare output with the wiring table.
- Explain the main sensor or input signal in plain language.
- Troubleshoot one wiring mistake using Serial Monitor evidence.
Components List
- ESP32 DevKit boardUSB-programmable ESP32 board used as the trainer brain.
- Push button module or momentary buttonConnects GPIO12 to ground when pressed; the sketch uses the ESP32 internal pull-up.
- Status LED with series resistorLED output on GPIO14; use a resistor or LED module.
- Breadboard and jumper wiresKeeps the lesson easy to inspect.
Bill of Materials
| Part | Qty | Estimated Cost | Notes |
|---|---|---|---|
| ESP32 DevKit board | 1 | Varies | USB-programmable ESP32 board used as the trainer brain. |
| Push button module or momentary button | 1 | Varies | Connects GPIO12 to ground when pressed; the sketch uses the ESP32 internal pull-up. |
| Status LED with series resistor | 1 | Varies | LED output on GPIO14; use a resistor or LED module. |
| Breadboard and jumper wires | 1 | Varies | Keeps the lesson easy to inspect. |
Wiring
A trainer circuit where a push button on GPIO12 controls a status LED on GPIO14 and prints clear state messages to Serial Monitor.
-
1
Unplug USB before changing any trainer wires.
-
2
Connect one side of the button to GPIO12.
-
3
Connect the other side of the button to GND.
-
4
Connect the resistor-protected LED signal to GPIO14.
-
5
Connect the LED ground side to GND.
-
6
Reconnect USB and open Serial Monitor at 115200 baud.
GPIO Mapping
| Signal | ESP32 Pin | Direction | Notes |
|---|---|---|---|
| Button input | GPIO12 | Input | Uses INPUT_PULLUP, so pressed reads LOW. |
| Status LED | GPIO14 | Output | Turns on when the button is pressed. |
| GND | GND | Ground | Shared reference. |
Circuit Explanation
The internal pull-up keeps GPIO12 HIGH until the button connects it to GND. GPIO14 drives the LED output.
Engineering Explanation
This project teaches the input-output loop used in larger ESP32 systems without adding Wi-Fi or sensor complexity.
Libraries
- Arduino ESP32 coreInstall ESP32 board support in Arduino IDE.
Code
Copy into Arduino IDE. Install any libraries noted in the component guides first.
// ESP32 Learning Trainer - button and status LED
const int BUTTON_PIN = 12;
const int LED_PIN = 14;
void setup() {
Serial.begin(115200);
pinMode(BUTTON_PIN, INPUT_PULLUP);
pinMode(LED_PIN, OUTPUT);
}
void loop() {
bool pressed = digitalRead(BUTTON_PIN) == LOW;
digitalWrite(LED_PIN, pressed ? HIGH : LOW);
Serial.println(pressed ? "pressed" : "released");
delay(50);
}
Code Explanation
BUTTON_PIN is GPIO12 and LED_PIN is GPIO14. loop() reads the button, lights the LED only when pressed, and prints pressed or released.
Expected Output
With the button released, Serial Monitor prints released and the LED stays off. Pressing the button prints pressed and turns the LED on. Releasing it returns both to the released state.
Troubleshooting
- LED is always on Check that the button is not permanently shorting GPIO12 to GND.
- Serial Monitor never changes Verify the button is wired to GPIO12 and GND.
- LED never lights Check LED polarity, current limiting, and the GPIO14 connection.
Common Mistakes
- Expecting HIGH to mean pressed when INPUT_PULLUP makes pressed read LOW.
- Forgetting the LED resistor when using a loose LED.
- Moving wires while USB is connected.
Testing Checklist
- Upload the sketch with only the documented circuit attached.
- Open Serial Monitor and confirm the expected messages.
- Move or trigger the input and watch the output change.
- Power-cycle the project and confirm it starts safely.
Engineering Tips
- Change one variable at a time.
- Keep wires short and labeled while testing.
- Record any calibrated threshold before installing the project.
Upgrade Ideas
- Add a second LED that shows the opposite state.
- Count button presses and print the count.
- Add an OLED display after serial output is understood.
Real-World Applications
- Classroom lab build
- Bench prototype
- Local ESP32 learning project
FAQs
Why does pressed read LOW?
INPUT_PULLUP holds the pin HIGH until the button connects it to ground.
Can I use another GPIO?
Yes, choose a general-purpose GPIO and update the code and wiring together.
Is 5 V needed?
No. USB power is enough for this trainer.
Review, Testing, and References
Author: Abdul Mubeen and the ESP32 Engine editorial team. Last updated: 2026-06-18. Reviewed: wiring logic, Arduino code structure, beginner safety, and learning sequence.
Educational level: Beginner. Estimated completion time: 45-60 min. This project is for learning and prototyping; production or unattended hardware needs additional engineering review.
Project Complete!
You completed ESP32 Learning Trainer Board as a real ESP32 engineering build with matching wiring, code, testing, and troubleshooting.
- Read the GPIO map
- Verify code against hardware
- Troubleshoot with Serial Monitor
