ESP32-based LEGO robotics car controlled via PS4 controller with autonomous navigation capabilities
Watch our project presentation:
Click the image above to watch the full demonstration
- PlatformIO (recommended)
- USB cable for ESP32 programming
- PS4 controller
- Clone the repository
git clone <repository-url>
cd mastodon-mbti-
Install dependencies
PlatformIO will automatically install required libraries:
PS4Controllerby aed3ESP32Servo
-
Configure PS4 Controller MAC Address
Use SixaxisPairTool to pair your PS4 controller with the ESP32's Bluetooth MAC address.
Update in
src/main.cpp:
const char* PS4_MAC_ADDRESS = "YOUR:ESP32:BLUETOOTH:MAC";-
Build and Upload
Using PlatformIO:
pio run --target uploadOr use the PlatformIO GUI in VS Code.
- Monitor Serial Output
pio device monitor// Motor Control
#define MOTOR_PIN1 12
#define MOTOR_PIN2 13
#define MOTOR_ENABLE_PIN 15
// Steering
#define SERVO_PIN 18
// Sensors
#define ULTRASONIC_TRIG_PIN 5
#define ULTRASONIC_ECHO_PIN 4
// Lighting
#define BRAKE_LIGHT_PIN 17
#define FIXED_LED_PIN 16
#define LEFT_BLINKER_PIN 23
#define RIGHT_BLINKER_PIN 21
#define LEFT_BLINKER_PIN_2 19
#define RIGHT_BLINKER_PIN_2 22
// RGB LED
#define RGB1_RED_PIN 25
#define RGB1_GREEN_PIN 26
#define RGB1_BLUE_PIN 27
// PS4 Feedback
#define PS4_FEEDBACK_LED_PIN 2| Class | Responsibility | Key Methods |
|---|---|---|
RemoteControl |
PS4 controller management | begin(), update(), handleButtons() |
Motor |
DC motor speed control | setSpeed(), brake(), emergencyStop() |
Steering |
Servo-based direction | setDirection(), setDirectionFromJoystick() |
Blinkers |
Turn signal management | toggleLeftBlinker(), toggleRightBlinker() |
Lights |
Brake/headlight control | startBrakeLights(), stopBrakeLights() |
Ultrasonic |
Distance measurement | getDistance(), isObstacleDetected() |
AutoMode |
Autonomous navigation | toggle(), update() |
| Button/Trigger | Function |
|---|---|
| R2 (Right Trigger) | Throttle (forward) |
| L2 (Left Trigger) | Reverse |
| Left Joystick (X-axis) | Steering |
| L1 | Toggle left turn signal |
| R1 | Toggle right turn signal |
| Triangle | Toggle warning lights |
| Cross (X) | Turn on feedback LED |
| Circle (O) | Turn off feedback LED |
| OPTIONS | Toggle autonomous mode |
When activated with OPTIONS button:
- Robot drives forward automatically
- Detects obstacles with ultrasonic sensor
- Reverses when obstacle < 20cm
- Turns to avoid obstacle
- Returns to forward motion
- 📊 Project Pitch Presentation - 3-minute overview
- 📝 Work Logs - Detailed development timeline
- 📋 Technical Report - In-depth technical analysis
Project Members:
- Maximilian Lopizzo - maximilian.lopizzo@eduvaud.ch
- Bryan Zweiacker - bryan.zweiacker@eduvaud.ch
- Ilyass Chelli - ilyass.chelli@eduvaud.ch
- Trystan Gaillard - trystan.gaillard@eduvaud.ch
This project is licensed under the MIT License - see the LICENSE file for details.
