This project involves building a car using an ESP32 microcontroller and an L298N or L293D motor driver to control the steering and back wheels motors. I had an old RC controlled car lying around, I removed the radio control PCB and mounted the outputs of the motors of the car respectively
- ESP32 Pin 19 (
steeringPin1
): Connected to IN1 of L298N. - ESP32 Pin 21 (
steeringPin2
): Connected to IN2 of L298N.
- ESP32 Pin 22 (
backWheelsPin1
): Connected to IN3 of L298N. - ESP32 Pin 23 (
backWheelsPin2
): Connected to IN4 of L298N.
- ESP32 Pin 2 (
enablePin
): Connected to ENA (Enable A) of L298N. Control motor speed using analogWrite.
- ESP32 Pin 19 (
steeringPin1
): Connected to IN1 of L293D. - ESP32 Pin 21 (
steeringPin2
): Connected to IN2 of L293D. - ESP32 Pin 22 (
backWheelsPin1
): Connected to IN3 of L293D. - ESP32 Pin 23 (
backWheelsPin2
): Connected to IN4 of L293D.
- ESP32 Pin 4 (
enablePin
): Connected to EN_X of L293D. Control motor speed using analogWrite.
- VIN of L293D: Connected to Positive (+) of 9V Battery.
- GND of L293D: Connected to Negative (-) of 9V Battery.
- Connect the ESP32 GPIO pins to the respective L298N or L293D inputs and enable pins as specified.
- Connect the GND of ESP32 to GND of the motor driver.
- Connect VIN or 5V of ESP32 to VCC of the motor driver.
- Connect the motors to the motor driver outputs.
- Connect a separate power supply (e.g., battery) to the specified input of the motor driver.
Use power supply according to your motor driver, in 2 attemps I fried my L293D motor driver, I suggest using L298N motor driver as it is the best in handling excessive power, also for powering the ESP32 you can try different methods. Please Note that a 9V battery is not sufficient to power the ESP32 properly. Feel free to customize the connections based on your hardware setup and specifications.
To control the car, use the provided Python script keyboard_control.py
. This script allows you to drive the car using keyboard inputs on your computer.
The car has to be powered properly. Using a 9V battery is not suggested, it is to determine wheter the connections are set or not, also I would suggest a 7v [minimum 400mah] battery and connect it to the motor driver and then using the same battery it is possible to power the esp32 module in the VIN and GND pins. After powering the esp32 you can wait for atlest 5 seconds before you send commands
- Python installed on your computer
- Keyboard library (
pip install keyboard
)
-
Ensure both the computer and the ESP32 are connected to the same Wi-Fi network.
-
Open a terminal and navigate to the directory containing
keyboard_control.py
. Use the "W" "A" "S" "D" keys to naviagte the car after running the script -
Run the script:
python keyboard_control.py
You can reach me out on my email here: Mail me here