Bluetooth Controlled Car using ESP32 and Smart phone:
We are making a Bluetooth Controlled Car using ESP32 Dev module. There is a reason why we have chosen ESP32 instead of any other board like Arduino.
Why we have chosen ESP32:
ESP32 is now becoming more famous due to its great features like inbuilt Bluetooth and Wi-Fi modules. Also, it has a more powerful CPU more RAM and ROM which is a great advantage over Arduino or any other development board of IOT-based projects which requires an active internet connection or features like Bluetooth. hence we have chosen ESP32 for our project.
Components required:
1. Geared DC motor
2. L293D motor driver or N298 MOSFET driver
3. chaises for housing component
4. ESP32 dev module (development board)
5. Jumper wires
6. Android smartphone with Blynk App installed on it
7. Mini Robot Chasis.
8. Battery pack (lithium-ion x 3).
Below Given circuit diagram you can see that 2 motors are interfaced with L293D driver IC. This IC is controlled by ESP32 Dev Module.
Working of Bluetooth controlled RC car:
As we power the ESP32’s the Bluetooth module starts working and gets connected to a smartphone when you start Dabble App installed on it. In that application, there is a gamepad. By using that gamepad you can control the Bluetooth car. You can move your car in three different modes. Know more about dabble.
Joystick mode:
In this mode you can control the car using a single joystick easy to control.
Button mode:
In this mode there are four buttons using which you can control your car, but you have to use more buttons.
Code for Bluetooth Controlled Car using ESP32:
int motor1Pin1 = 27; int motor1Pin2 = 26; int enable1Pin = 14; int motor2Pin1 = 32; int motor2Pin2 = 33; int enable2Pin = 25; #define CUSTOM_SETTINGS #define INCLUDE_GAMEPAD_MODULE #include void setup() { Dabble.begin("MyEsp32"); pinMode(motor1Pin1, OUTPUT); pinMode(motor1Pin2, OUTPUT); pinMode(enable1Pin, OUTPUT); // sets the pins for motor2 as outputs: pinMode(motor2Pin1, OUTPUT); pinMode(motor2Pin2, OUTPUT); pinMode(enable2Pin, OUTPUT); digitalWrite(enable1Pin, HIGH); digitalWrite(enable2Pin, HIGH); } void loop() { Dabble.processInput(); boolean a = GamePad.isUpPressed(); boolean b = GamePad.isDownPressed(); boolean c = GamePad.isLeftPressed(); boolean d = GamePad.isRightPressed(); boolean e = GamePad.isTrianglePressed(); boolean f = GamePad.isCirclePressed(); boolean g = GamePad.isCrossPressed(); boolean h = GamePad.isSquarePressed(); // boolean i = GamePad.isStartPressed(); // boolean j = GamePad.isSelectPressed(); //Go forward if (a || e) { digitalWrite(motor1Pin1, LOW); digitalWrite(motor1Pin2, HIGH); digitalWrite(motor2Pin1, HIGH); digitalWrite(motor2Pin2, LOW); } // Go Left condition else if(d || f) { digitalWrite(motor1Pin1, LOW); digitalWrite(motor1Pin2, HIGH); digitalWrite(motor2Pin1, LOW); digitalWrite(motor2Pin2, LOW); } //* Rights condition else if(c || h) { digitalWrite(motor1Pin1, LOW); digitalWrite(motor1Pin2, LOW); digitalWrite(motor2Pin1, HIGH); digitalWrite(motor2Pin2, LOW); } // Go back condition else if(b || g) { digitalWrite(motor1Pin1, HIGH); digitalWrite(motor1Pin2, LOW); digitalWrite(motor2Pin1, LOW); digitalWrite(motor2Pin2, HIGH); } //stop condition else { digitalWrite(motor1Pin1, LOW); digitalWrite(motor1Pin2, LOW); digitalWrite(motor2Pin1, LOW); digitalWrite(motor2Pin2, LOW); } }