Introduction: TWO WHEELS CRAZY RC CAR

Almost two age agone, I carried retired a project involving a 2 wheel self-balancing automaton from broken diddle car. After upgrading it to new version, this interrupted toy car was left in my storage warehouse and I intended that someday I would come through in operation once again.

Now, I'm willing to share how to make a two wheels RC car which controlled by BEETLE-ESP32 microcontroller in the simple way.

This two wheels car can be amply functional remote controlled that allows the railway car to move forward, timid, turn left, ferment right and much crazy movements by adjusting the divergence of 2 wheels cannonball along, such as: perform 360 degree rapid rotation in vertical or horizontal direction….

Let's getting started.

Footfall 1: THINGS WE Pauperism

Main components are as beneath:

  • 1PCS X Protrusive ESP32 MICROCONTROLLER: https://www.dfrobot.com/production-1798.hypertext markup language
  • 1PCS x L298N MOTOR DRIVER MODULE H-BRIDGE
  • 2PCS x WHEEL & DC GEAR-Boxwood Reducing agent MOTOR: I reused 2 DC motors and 2 wheels with diameter ~100mm from broken toy car.

  • 1PCS x Reduplicate SIDE DIY PROTOBOARD CIRCUIT 5x7CM.
  • 2PCS X RECHARGEABLE Assault and battery 18650 3.7V 4200mAh
  • 1PCS X 2-PLACE 18650 BATTERY HOLDER WITH WIRES
  • 1PCS X FEMALE 40PIN 2.54MM HEADER.
  • 1PCS X MALE 40PIN 2.54MM Coping.
  • 1PCS X 2PIN 5.08MM PITCH SCREW Depot BLOCK.
  • 01METER X 8P RAINBOW RIBBON CABLE.

Step 2: BEETLE-ESP32 MICROCONTROLLER

With Protrusive-ESP32, Bluetooth and Wireless fidelity are integrated in microcontroller for supporting more applications. So I force out easily build up a car which tooshie cost remotely controlled via WIFI or Bluetooth.

With dimension 35×34mm, Beetling-ESP32 is suitable for projects that require compact electronic components. It is appointed with 4 analog ports, 4 extremity ports, UART and I2C interfaces.

For more point, we can check at: https://www.dfrobot.com/production-1798.hypertext markup language

Stone's throw 3: CONNECTION DIAGRAM

Here below is the connection plot of 2 wheels car:

To control the direction and travel rapidly of 2 wheels car by L298N, we need 6 control signal outputs from BEETE-ESP32. The BEETLE-ESP32 has 4 digital ports and 4 parallel ports just regrettably, we cannot use 4 analog pins (A0 ~ A3) arsenic outputs, entirely be used equally inputs. With ESP32-WROOM-32, GPIOs 34 to 39 are GPIs – they're input signal only pins.

  • GPIO 34 – A2
  • GPIO 35 – A3
  • GPIO 36 – A0
  • GPIO 39 – A1

So I had to use 2 pins of I2C interface (SCL and SDA) to assure motor speed, they were connected to ENA and ENB pins of L298N.

Take up note that L298N supply major power to BEETLE-ESP32 at +5V &A; GND screw terminals.

For more detail, we can check their connection as table below:

Step 4: ASSEMBLY WORKS

SOLDERING HEADERS FOR BEETLE ESP32: The distance 'tween the Beetling ESP32 pins is 5 mm, so we derriere purpose the popular 2.5mm male/ female cope and change information technology a act by this fashio: with every distance 5mm - 3 pins header, we remove a bowling pin midmost.

SOLDERING AN ADAPTER CONNECTING BEETLE-ESP32 AND L298N: Cutting double-sided proto-plug-in into 2 commensurate parts. I used one-half of this proto-plank to name the arranger shield which BEETLE-ESP32 can plug connected its top and the L298N can plug at its bottom. The adapter shield was soldered following the schematic on previous step.

  • Adapter shield - TOP: is connected to BEETLE-ESP32.

  • Adapter shield - BOTTOM: is connected to L298N at 6 pins female header.

BATTERY Bearer: Glue shelling holder to the car chassis. We require to test and ensure that battery holder and chassis including 2 District of Columbia motors derriere freely rotate around the car's axle.

L298N INSTALLATION: Glue motor driver module H-bridge L298N and electric battery switch to the car chassis.

ADAPTER INSTALLATION: Copulative baron supply wires to adaptor shield. IT supply +5VDC and GND to VIN of Overhang-ESP32.

Gathering DONE: Plug adapter shield on the L298N. Due to car can be operated in high f number rotation so we need to arrange wires neatly, and fix whol components firmly together away gum.

Step 5: PROGRAMMING

In the Arduino UNO/MEGA, we can use the analogWrite() function to generating PWM for control motor speed Beaver State LED applications. The ESP32 does not support the analogWrite() function but it does support a mistakable purpose, named ledcWrite(). We can concern to this funtion at below link:

https://github.com/espressif/arduino-esp32/blob/ma...

The ESP32 contains 16 mugwump "package PMW" channels and we hind end utilise them to any 16 GPIOs output pins to beget PWM production with resolution dormy to to 16 bits.

Ready to give a friendly use of analogWrite() function, we can use this tip:

#delimit analogWrite ledcWrite

The PWM function is declared and initiated as follow:

              // Config PWM functionalitites   ledcSetup(pwmChannelA, freq, resolution);   ledcSetup(pwmChannelB, freq, resolution);      // Attach the PWM channel to the GPIOs to be controlled   ledcAttachPin(ENA, pwmChannelA);   ledcAttachPin(ENB, pwmChannelB);      // Apply PWM at selected channels   analogWrite(pwmChannelA, MotorLeft[2]);   analogWrite(pwmChannelB, MotorRight[2]);            

With BEETLE-ESP32, it can can be remotely controlled via WIFI or Bluetooth. In my case, I used WIFI with BLYNK app connected the cellphone to control my automobile.

My 2 wheels RC car broadcast is as below:

/* BEETLE ESP32 - TWO WHEELS CRAZY RC CAR  * By TUENHIDIY  */ /*  * Overhang-ESP32 Oarlock  * D7  --> GPIO13  * D4  --> GPIO27  * D3  --> GPIO26  * D2  --> GPIO25  * A3  --> GPIO35  * A2  --> GPIO34  * A1  --> GPIO39  * A0  --> GPIO36  * SCL --> GPIO22  * SDA --> GPIO21  * TX  --> GPIO1  * RX  --> GPIO3  */   //#define BLYNK_PRINT Serial #include <WiFi.h> #include <WiFiClient.h> #include <BlynkSimpleEsp32.h> /*  * Check particular at: https://github.com/espressif/arduino-esp32/blob/master/cores/esp32/esp32-hal-ledc.c  * Turn back ledcWrite() mathematical function into analogWrite() function as same as Arduino UNO operating theatre MEGA  */ #define analogWrite ledcWrite  // Motive Left const int IN1 = 13; // D7 const int IN2 = 27; // D4 const int ENA = 22; // SCL  // Motor Right const int IN3 = 26; // D3  const int IN4 = 25; // D2  const int ENB = 21; // SDA  // Setting PWM properties const int freq = 10000; const int pwmChannelA = 0; const int pwmChannelB = 1; const int resolution = 8;  int INIT_SPEED = 150; int LEFT_SPEED; int RIGHT_SPEED;  // Motors properties int MotorLeft[3] = {IN1,IN2, INIT_SPEED};   int MotorRight[3] = {IN3,IN4, INIT_SPEED};  // Auth Token in the Blynk App. char auth[] = "";  // Your WiFi SSID and Word. cleaning lady ssid[] = "FPT-Telecom"; coal pass[] = "12345678";  void setup() {   Blynk.begin(auth, ssid, pass);   RC_Car_Init();   // Serial Testing & Debugging   //Serial.begin(115200);   //Serial.impress("Testing Crazy RC Automobile..."); }  //Intialize the motor void RC_Car_Init() {   for(int i=0 ; i<2; i++)   {   pinMode(MotorLeft[i],Output signal);   pinMode(MotorRight[i],OUTPUT);   }   pinMode(ENA, Production);   pinMode(ENB, OUTPUT);      // Config PWM functionalitites   ledcSetup(pwmChannelA, freq, resolution);   ledcSetup(pwmChannelB, freq, resolution);      // Attach the PWM canalize to the GPIOs to embody controlled   ledcAttachPin(ENA, pwmChannelA);   ledcAttachPin(ENB, pwmChannelB);      // Lend oneself PWM at elect channels   analogWrite(pwmChannelA, MotorLeft[2]);   analogWrite(pwmChannelB, MotorRight[2]); }  /*   Cardinal Wheels RC Railway car Driving Functions - L298N     DIRECTION IN1 IN2 IN3 IN4     Backward   0   1   0   1     Forward    1   0   1   0     Right      0   1   0   0     Left       0   0   0   1     Stop       0   0   0   0 */  void RC_Car_Forward() {   // Series.println("Moving Forward");   analogWrite(pwmChannelA, MotorLeft[2]);   analogWrite(pwmChannelB, MotorRight[2]);        digitalWrite(MotorLeft[0],1);   digitalWrite(MotorLeft[1],0);   digitalWrite(MotorRight[0],1);   digitalWrite(MotorRight[1],0);   }  void RC_Car_Backward() {   //Music.println("Moving Backwards");   analogWrite(pwmChannelA, MotorLeft[2]);   analogWrite(pwmChannelB, MotorRight[2]);      digitalWrite(MotorLeft[0],0);   digitalWrite(MotorLeft[1],1);   digitalWrite(MotorRight[0],0);   digitalWrite(MotorRight[1],1);    }  evacuate RC_Car_Left() {   //Serial.println("Reverse Left");   //analogWrite(pwmChannelA, 0);   analogWrite(pwmChannelB, MotorRight[2]);        digitalWrite(MotorLeft[0],0);   digitalWrite(MotorLeft[1],0);   digitalWrite(MotorRight[0],0);   digitalWrite(MotorRight[1],1);     } void RC_Car_Right() {   //Serial.println("Turn Right");   analogWrite(pwmChannelA, MotorLeft[2]);   //analogWrite(pwmChannelB, 0);        digitalWrite(MotorLeft[0],0);   digitalWrite(MotorLeft[1],1);   digitalWrite(MotorRight[0],0);   digitalWrite(MotorRight[1],0);     }  void RC_Car_Stop() {   //Serial.println("Motor Stopped");   //analogWrite(pwmChannelA, 0);   //analogWrite(pwmChannelB, 0);        digitalWrite(MotorLeft[0],0);   digitalWrite(MotorLeft[1],0);   digitalWrite(MotorRight[0],0);   digitalWrite(MotorRight[1],0);     }  BLYNK_WRITE(V1) {      int value_V1 = param.asInt(); // Get value as integer   if(value_V1)   {     RC_Car_Forward();   }   else   {     RC_Car_Stop();   } }  BLYNK_WRITE(V2) {      int value_V2 = param.asInt(); // Get value as integer   if(value_V2)   {     RC_Car_Right();   }   else   {     RC_Car_Stop();   } }  BLYNK_WRITE(V3) {      int value_V3 = param.asInt(); // Get value as integer   if(value_V3)   {     RC_Car_Backward();   }   else   {     RC_Car_Stop();   }   }  BLYNK_WRITE(V4) {      int value_V4 = param.asInt(); // Get value as integer   if(value_V4)   {     RC_Car_Left();   }   else   {     RC_Car_Stop();   }   }  BLYNK_WRITE(V5) {      int value_V5 = param.asInt(); // Buzz off value as integer   MotorLeft[2] = map(value_V5, 0, 100, 100, 255); // Chromosome mapping value from luger to PWM }  BLYNK_WRITE(V6) {      int value_V6 = param.asInt(); // Get value as integer   MotorRight[2] = map(value_V6, 0, 100, 100, 255); // Mapping value from slider to PWM }  invalidate loop() {   Blynk.run(); }            

Gradation 6: REMOTE CONTROL Away BLYNK

I created on the Blynk app a panel with 4 pushing buttons V1 ~ V4 and 2 sliders V5 ~ V6. You can refer to previous programing step for more detail.

  • V1 - Saucy
  • V2 - TURN RIGHT
  • V3 - BACKWARD
  • V4 - TURN LEFT
  • V5 - LEFT MOTOR SPEED
  • V6 - Rectify MOTOR SPEED

With 2 sliders, I can graduate 2 wheels to expected speeds or align their discrepancy to perform some crazy movements.

Step 7: FINISH

My girl - 8 years old - is very active and naughty. She just wanted this car to spin quickly, laughed and jumped for pleasure. Simply that is my pleasure!

Thank for your observance and hope you like my post!

Be the First to Percentage

Recommendations