Radio-Control Car With 2 Speed Modes - AWD

by abdullahkhalid098 in Circuits > Arduino

915 Views, 10 Favorites, 0 Comments

Radio-Control Car With 2 Speed Modes - AWD

Screenshot (237).png

This project is about making an arduino-based RC Car. The unique thing for this car is, it uses a Hobby-Grade Transmitter and Receiver system which gives a proportional control and also it gives a very long range. As long as 1km!

Supplies

Screenshot (238).png
Screenshot (239).png
Screenshot (240).png
Screenshot (242).png
Screenshot (243).png

For this Project, we need:

  1. Arduino UNO
  2. L298N Motor Driver
  3. 18650 battery
  4. 18650 battery holder
  5. TT Gear Motors
  6. Rubber Tyres

For the Radio Control System, I am using:

  1. Flysky i6X Transmitter
  2. Flysky iA6B Receiver


Circuit Diagram:

L293D -- ARDUINO:-
ENA --- 5
ENB --- 6
IN1 --- 2
IN2 --- 3
IN3 --- 4
IN4 --- 7

RECEIVER --- ARDUINO:-
CH1 --- A0
CH2 --- A1
CH3 --- A2
CH4 --- A3
CH5 --- A4
CH6 --- A5
VCC --- VCC
GND --- GND

Installing Motors

Screenshot (244).png

The first step is to attach the motors to a base using hot glue.

Installing the Battery Holder

Screenshot (245).png

The 2nd step is to install the battery holder. You can install it at any place you want. But I had space at the under of the base, so I installed it there.

Installing Arduino and Motor Driver

Screenshot (246).png
Screenshot (247).png
Screenshot (249).png

The wires of motors shall come out to the top part of the base. Next up, we install the Arduino and the L298N motor driver. For installing these components, I am using Nuts and Bolts. After installing these, we can connect the motor wires to the motor driver and fix them in place using a screw driver.

Installing the Receiver

Screenshot (250).png
Screenshot (251).png

The next step is to install the receiver and connect its wires to arduino according to the circuit diagram mentioned above.

Programming

Screenshot (252).png
Screenshot (253).png

The hardware part is almost complete. Now we can program the robot. We connect the Arduino to our computer using a USB cable, and then upload the code. The code is given below.

// Arduino RC Car using Flysky Transmitter and Receiver
// Subscribe the Channel: https://www.youtube.com/@AKElectroDIY
// Tutorial Video Link: https://youtu.be/q-Clw0m3E18

int enA = 5;
int in1 = 2;
int in2 = 3;
int enB = 6;
int in3 = 4;
int in4 = 7;

int receiver_pins[] = {A0, A1, A2, A3, A4, A5};
int receiver_values[] = {0, 0, 0, 0, 0, 0};
int res_min = 950;
int res_max = 2020;

int working_range = 255; // motor driver range

boolean prt = true;

int mode = 0;
//-1 = transmitter not connected or out of range
// 0 = transmitter connected and ready
// 1 = slow speed mode
// 2 = high speed mode

void setup() {
pinMode(enA, OUTPUT);
pinMode(enB, OUTPUT);
pinMode(in1, OUTPUT);
pinMode(in2, OUTPUT);
pinMode(in3, OUTPUT);
pinMode(in4, OUTPUT);

Serial.begin(115200);
}

void loop() {
receive();
setModeLED();

int m1 = 0;
int m2 = 0;

int rot = receiver_values[0];

if (mode == 1) {
m1 = receiver_values[1] / 2.5 + (rot)/3;
m2 = receiver_values[1] / 2.5 - (rot)/3;

} else if (mode == 2) {

m1 = receiver_values[1] + rot / 1.75;
m2 = receiver_values[1] - rot / 1.75;
}

mpower(1, m1);
mpower(2, m2);
}

int rp = 0;

void receive() {
receiver_values[rp] = map(pulseIn (receiver_pins[rp], HIGH), res_min, res_max, -1 * working_range, working_range);
rp++;
if (rp == 6){
rp = 0;
}
boolean activevalues = true;
for (int i = 0; i < 6; i++) {
if (prt) {
Serial.print("CH");
Serial.print(i);
Serial.print(" : ");
Serial.print(receiver_values[i]);
Serial.print(",\t");
}
if (receiver_values[i] < -500) {
activevalues = false;
}
}
mode = 0;
if (!activevalues) {
mode = -1;
} else if (receiver_values[4] > -100) {
mode = 2;
} else if (receiver_values[5] > -100) {
mode = 1;
}
if (prt) {
Serial.println("");
}
}

void mpower(int motor, int spd) {
int rotation = 0;
if (spd > 0) {
rotation = 1;
} else if (spd < 0) {
rotation = -1;
spd *= -1;
}
if (spd > 255) {
spd = 255;
}
int pwm;
int pA;
int pB;
if (motor == 1) {
pwm = enA;
pA = in1;
pB = in2;
} else if (motor == 2) {
pwm = enB;
pA = in3;
pB = in4;
} else {
return;
}
if (rotation == 0) {
digitalWrite(pA, LOW);
digitalWrite(pB, LOW);
} else if (rotation == 1) {
digitalWrite(pA, HIGH);
digitalWrite(pB, LOW);
} else if (rotation == -1) {
digitalWrite(pA, LOW);
digitalWrite(pB, HIGH);
}
analogWrite(pwm, spd);
}

Installing Tyres and Inserting Batteries

Screenshot (254).png
Screenshot (255).png

Now we can install the tyres and insert 3 18650 batteries.

Transmitter Setup

Screenshot (256).png

The final step is to set up the Transmitter.

It is very simple. We just need to set 2 aux switches to channels 5 and 6. We can use these switches to switch between modes. We have 1 switch to arm and disarm the motors. And 2nd switch to set the motor speeds.

Enjoy!

Screenshot (257).png
Screenshot (258).png
Screenshot (260).png

The car is now ready. We can play with it around and enjoy!