This project was used for teaching a STEM workshop. The target audience was high school students with no exposure to coding or engineering before - and we only had 15min per group. None had ever coded or built electronics, yet all groups were able to complete the project successfully!
This year’s breakout session, “Coding Explosions,” had participants engineering a motor to pull a string and trigger a mentos eruption—what a blast! 🚀 The excitement was clear as the girls learned about mechanical, software, and electrical engineering.
Objective: Code an ESP32 to turn a Servo Motor 180 degrees, pulling a string that drops the Mentos into the Diet Coke.
Materials:
- Battery Pack (turns on the ESP32, starting the whole process)
- ESP32 Dev Board
- Servo Motor
- USB to MicroUSB Cable
- It must allow you to connect the ESP32 to your computer for flashing the code to the ESP32. Be sure to test ahead of time.
- Jumper Wires
- Cardboard
- Tape that sticks well to cardboard
- String/Ribbon
- Mentos
- Diet Coke
- (Optional) Geyser Tube
Student Roles (3 students per group):
- Software Engineer: Fill in the code for the ESP32 to trigger the Servo Motor. Start with
src/incomplete.ino
and fill in the missing parts. Usesrc/complete.ino
as a reference to help them understand what the code should do. - Mechanical Engineer: Build the structure to hold the Diet Coke and Mentos trigger system.
- Electrical Engineer: Connect the ESP32 to the Servo Motor and power source. Learn about how to use jumper wires safely and which pins to use.
Every group of students launched theirs successfully, for a total of 10 bottles! 🚀
We used multiple computers so that each student could do their own typing. This way you can just edit the code and hit Run.
Step 1: Set Up Arduino IDE for ESP32
- Before using the ESP32Servo library, you'll need to make sure that the Arduino IDE is set up for ESP32 development.
- Install the ESP32 Board Package:
- Open the Arduino IDE.
- Go to
File > Preferences
. - In the
Additional Boards Manager URLs
field, enter this URL:https://dl.espressif.com/dl/package_esp32_index.json
- Click OK.
- Install ESP32 Board in Board Manager:
- Go to Tools > Board > Boards Manager.
- Search for "ESP32" and click the Install button for the "esp32" by Espressif Systems.
- Once installed, go to
Tools > Board
and select your ESP32 board model (e.g., "ESP32 Dev Module").
Step 2: Install ESP32Servo Library
- Install the
ESP32Servo
Library: - Open the Arduino IDE.
- Go to
Sketch > Include Library > Manage Libraries
. - In the Library Manager, search for "ESP32Servo".
- Install the "ESP32Servo" library by Kevin Harrington.
- Attach the Red (Positive) wire of the Servo Motor to the 5V (VIN) pin on the ESP32.
- Attach the Brown (Negative) wire of the Servo Motor to the GND pin on the ESP32.
- Attach the Orange (Signal) wire of the Servo Motor one of a few GPIO pins on the ESP32. You can use almost any GPIO pin that supports PWM (e.g., GPIO 19, 21, 23, 25, 26, 27).