This project is a sensor-driven robot built using an ESP32 and MicroPython.
It integrates distance sensing, stepper motor movement, tilt detection, and user feedback via a buzzer, LED, and OLED display.
| Component | Pin Connections |
|---|---|
| LED | D12 (Output) |
| Button | D27 (Input, Pull-Up enabled) |
| Buzzer | D15 (Output via Buzzer class) |
| Ultrasonic Sensor | Trigger: D5, Echo: D18 |
| Left Stepper | STEP Pin: D13 (A4988 Driver) |
| Right Stepper | STEP Pin: D19 (A4988 Driver) |
| OLED Display | I2C (SCL: D22, SDA: D21) |
| Accelerometer | I2C (SCL: D22, SDA: D21) |
| Action | Result |
|---|---|
| Startup | Displays "Press button to start" |
| Button Press | Buzzer beeps once, starts distance measurement |
| Measures Distance | OLED displays distance and calculated steps |
| Drives Motors | Moves robot corresponding to the measured distance |
| Tilt Detected While Driving | Stops immediately, lights LED, beeps 3 times, displays "TILTED" |
| Successfully Reached Destination | Buzzer beeps once, displays "REACHED" |
| File | Purpose |
|---|---|
main.py |
Main control logic for the robot |
buzzer.py |
Handles buzzer beeping functions |
ultrasonic.py |
Reads distance from ultrasonic sensor |
stepper.py |
Controls stepper motor movement |
oled.py |
Manages text display on the OLED screen |
mpu6050.py |
Reads accelerometer values (AcY axis) |
⚡ How to run this project:
- Go to Wokwi Simulator.
- Create a new ESP32 project.
- Upload all source files (
main.py,buzzer.py,ultrasonic.py,stepper.py,oled.py,mpu6050.py) into the Wokwi project. - Set up the virtual components according to the Hardware Components table above.
- Click Start Simulation — and you're good to go!
Note:
Make sure the filenames match exactly! Wokwi depends on proper file naming for imports to work correctly.
🔗 Click here to view the live simulation
- ESP32 Datasheet
- HC-SR04 Ultrasonic Sensor Datasheet
- A4988 Stepper Motor Driver Datasheet
- MPU6050 Accelerometer Datasheet
- MicroPython Documentation
- Microcontroller: ESP32 Dev Module
- Programming Language: MicroPython
- Distance Calculation: Based on ultrasonic pulse timing
- Step Calibration: 10 steps ≈ 1 cm
- Tilt Detection Threshold: Accelerometer AcY axis > 12000 or < -12000
- Buzzer Notifications:
- 1 short beep on start
- 3 short beeps on tilt detection
- 1 short beep on successful movement
| Field | Details |
|---|---|
| Name | Sief Ali Sayed Said |
| GitHub | github.com/red-x-0 |
| 463688431@cairo5.moe.edu.eg |
