This project is a ball simulation system built on an ESP32 that uses an MPU6050 motion sensor and displays interactive feedback on a 0.96" OLED screen. A push button allows interaction (e.g. reset or menu control). The simulation visualizes movement like a ball in a sloshing container, responding to tilt detected by the MPU6050.
- Reads real-time orientation data from the MPU6050 (accelerometer/gyroscope)
- Simulates ball motion on the OLED screen
- Push button input for user control (e.g., reset or menu navigation)
- Powered by the ESP32 for wireless expandability and fast I²C communication
| Component | ESP32 Pin | Description |
|---|---|---|
| MPU6050 VCC | 3.3V | Power supply |
| MPU6050 GND | GND | Ground |
| MPU6050 SDA | GPIO21 | I²C data line |
| MPU6050 SCL | GPIO22 | I²C clock line |
| OLED VCC | 3.3V | Power supply |
| OLED GND | GND | Ground |
| OLED SDA | GPIO21 | I²C data line (shared) |
| OLED SCL | GPIO22 | I²C clock line (shared) |
| Button | GPIO19 | Digital input |
| Button GND | GND | Connected via pull-down |
📝 Note: SDA and SCL are shared between the MPU6050 and OLED (I²C bus).
- The ESP32 initializes both the MPU6050 and the OLED.
- Motion data is continuously fetched from the MPU6050.
- Using basic physics and smoothing, the sketch simulates how a ball might roll and bounce inside a boundary based on the tilt angles.
- The push button allows the user to reset or interact with the simulation.
- ESP32 board
- MPU6050 gyroscope/accelerometer
- 0.96" I²C OLED display (SSD1306)
- Push button
- Breadboard and jumper wires
Install these via the Arduino Library Manager:
Adafruit GFXAdafruit SSD1306Wire.hMPU6050orAdafruit MPU6050depending on your sketch
ball_simulation.ino– Main Arduino sketchREADME.md– Project documentation
- Connect your components based on the wiring diagram.
- Open
ball_simulation.inoin the Arduino IDE. - Select your ESP32 board and correct COM port.
- Upload and monitor the output on the OLED screen.
- Add sound feedback with a buzzer
- Implement Wi-Fi-based data logging or control
- Expand to 3D ball simulation using quaternion math
MIT License
Made by Moses – Year 12 High school student - @Hack_updt
