It's basically a Wi-Fi remoted controlled car, we can drive it in three modes:
- Normal joystick mode
- Joystick mode with anticollision system
- Autoparking mode
For our project we've used:
- 2 x MSP432P401R Launchpads
- 2 x ESP32 modules
- BOOSTXL-EDUMKII
- L298N Motor Driver Module
- HC-SR04 ultrasonic module
- 9g Micro Servo
- 9V battery
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
We've build the Joystick Controller with an MSP432P401R Launchpad connected to the BOOSTXL-EDUMKII and to the ESP32 Wi-Fi and Bluetooth module.
We've used as our chassis the ELEGOO UNO R3 Project Smart Robot Car V 4.0 with his built-in motors and wheels, but it's not mandatory, you can use whatever chassis you prefer, we have use four DC motor (from 3V to 6V).
├──MSP432_SENDER #controller's code
| ├──Debug
| ├──LcdDriver
| ├──targetConfigs
| ├──ConnectionUart.c
| ├──ConnectionUart.h
| ├──Display.c
| ├──Display.h
| ├──Joystick.c
| ├──Joystick.h
| ├──main.c
| ├──msp432p401r.cmd
| ├──startup_msp432p401r_ccs.c
| └──system_msp432p401r.c
|
├──MSP432_RECEIVER #car's code
| ├──Debug
| ├──LcdDriver
| ├──targetConfigs
| ├──ConnectionUart.c
| ├──ConnectionUart.h
| ├──Motor.c
| ├──Motor.h
| ├──UltrasonicSensor.c
| ├──UltrasonicSensor.h
| ├──main.c
| ├──msp432p401r.cmd
| ├──startup_msp432p401r_ccs.c
| └──system_msp432p401r.c
|
├──ESP32_SENDER #esp32 connected to the controller
| └──ESP32_SENDER.ino
|
└──ESP32_RECEIVER #esp32 connected to the car
├──ESP32_RECEIVER.ino
├──ESP32_Servo.cpp
└──ESP32_Servo.h
As you can see, the code is divided in four parts: the code loaded into the controller (MSP432_SENDER) and the code in the MSP432 of the car (MSP432_RECEIVER) are the main parts, moreover we have setup the two ESP32 with some arduino code to communicate between them using their Wi-Fi modules (this is the only part done with arduinoIDE, the rest of the project is coded in C language).
We've used the UART serial communication to let MSP432 and ESP32 talk to each other:
We have setup a unilateral UART connection because it was enough for our project, but it' easily implementable a bilateral communication between the two devices.
The graphic part is composed basically by the functions that allow us to print elements on the LCD screen:
- The graphicsInit() function setup the LCD screen and projects the WELCOME screen.
- The graphics_first_menu() function projects the menu screen.
- The joystick_mode_graphics(int sel1) function projects the joystick mode screen, some strings (the one which communicate us if we are going straight on or in retro mode and the one that indicates turn) are projected by a function draw() in joystick_mode_setup() in Joystick.c.
- The auto_park_mode_graphics() function projects the autopark mode screen.
The joystick code include all the button's interrupts_handler:
- Boosterpack's S1 and S2 buttons interrupt handlers
- MSP432's S1 button interrupt handler
Then we have the mode function:
- joystick_mode_setup() calls his graphic's function and then check the ADC14 x and y values, converts them and send them to the car.
- keep_distance(bool on) if on send to the car 3 times the code 202 (enable anticollision) else it send 203 (disable anticollision).
- auto_park_mode() calls his graphic's function and then send the code 201 to the car til the BACK button is released.
For the receiver MSP432 we use an interrupt to take the number via UART and then decode it to know the mode and movement of the motors. For motors we use the PWM technique to make them go at the speed we want.
The numbers received by the MSP432 are managed in this way:
- 0-99: used to give the direction to the x axis of the motors, this number is mapped in to the [-50,+50] range and this number is used for decide the power relation between the motors.
- 100-199: used to send the power to the y axis of the motors and also this is mapped in to the [-50,+50] range Then we have to generate the message to enable or disable functions:
- 200-255: are for extra functions, 201 for parking mode, 202 for anti-collision and 203 for normal joystick mode.
For the parking mode we use Ultrasonic Sensor, the car goes straight on until it finds a place big enough to allow parking and it applies the algorithm to park.
If you haven't done it already download the latest version of Code Composer Studio at this link. First of all clone this repo and then import the folder as a project in CCS. Then you have to download driverlib at this link and then add it to your current project, following these lines:
- Extract simplelink_msp432p4_sdk_3_40_01_02.zip file.
- Open CSS and left click on Project Folder to select Properties
- Select CSS Build
- Click ARM Compiler and then Include Options
- Add "simplelink_msp432p4_sdk_3_40_01_02/source" directory to "Add dir to #include search path" window.
- Click ARM Linker and File Search Path
- Add "simplelink_msp432p4_sdk_3_40_01_02/source/ti/devices/msp432p4xx/driverlib/ccs/msp432p4xx_driverlib.lib" to "Include library file..." window
- Add "simplelink_msp432p4_sdk_3_40_01_02\source\ti\grlib\lib\ccs\m4f\grlib.a" to "Include library file..." window
PIN | FUNCTION | NOTES |
3.2 | RX | it's connected to ESP's pin G16. From there, the board receive controller's messages |
2.7 | Echo | Connected to Ultrasonic Sensor's Echo pin |
2.6 | Trig | Connected to Ultrasonic Sensor's Trig pin |
2.4 | EN_2 | Connected to L298N's EN_B pin |
5.6 | EN_1 | Connected to L298N's EN_A pin |
5.7 | IN2_2 | Connected to L298N's IN3 pin |
1.7 | IN1_1 | Connected to L298N's IN1 pin |
5.0 | IN2_1 | Connected to L298N's IN2 pin |
5.2 | IN1_2 | Connected to L298N's IN4 pin |
L298N is designed to have two motors connected, since we wanted to control four, we connected the left motors to OUT1 and OUT2 in pairs and similarly we connected the right motors to OUT3 and OUT4.
At the beginning we were using a motor shield which wasn't able to serve four motors simultaneously because it accepted only 5V power; so we have bought a new motor shield (L298N) and ae provide 9V power supply.
PIN | FUNCTION | NOTES |
3.3 | TX | it's connected to ESP's pin G17. From there, the board send messages to the car |
Motors setup and movement alghoritms | Mattia Rigon |
UART and Wi-Fi communication | Simone Roman |
Joystick interface, graphics and controller functions | Stefano Bonetto |
Sensors setup, Autoparking mode and ABS mode | Stefano Bonetto, Simone Roman, Mattia Rigon |
Project debug and test | Stefano Bonetto, Simone Roman, Mattia Rigon |
Stefano Bonetto: [email protected]
Simone Roman: [email protected]
Mattia Rigon: [email protected]