Double Wireless RC Truck (2 X Wireless Communication Remote and Bluetooth) on Arduino

by ngrigoriev in Circuits > Arduino

2067 Views, 19 Favorites, 0 Comments

Double Wireless RC Truck (2 X Wireless Communication Remote and Bluetooth) on Arduino

2015-01-01 23.31.10.jpg

Hello everyone. I just decided to make something easy and accessible to everyone. I saw a lot of videos and descriptions how to build an remotely controllable cars, truck. So my point is to invest as little as possible of efforts and money to build something incredible and useful toy. I wonder if I could keep in mind the operation by remote control, but in the same time I would like to improve my abilities and implant a bluetooth overall so make it possible to control via bluetooth and via remote control.

Installing the Connectors in the Rear Side of the Truck

2015-01-05 10.56.59.jpg

We simply need to make some entrance for connectors which consists of 5 wires (DTR, RX, TX, GRND and +5V VCC). You don't really need to connect 3.3V to GRND (nothing will happen seriously but you will not be able to upload your sketch on Arduino).

Connect Male Side of Wires to Arduino Pro Mini

2014-12-08 22.49.04.jpg

Once you connected them, you can apply some force to bend the terminals like "L" and then solder to arduino board.

Upload the Sketch

2014-12-08 22.59.37.jpg

/* DTR connexion is on left side from back look. 3.3 V pin is free (not connected)

Enable 1 on A0 and Enable 2 on A1

Motor A, rear motor (pin 2 and pin 4) motor B front motor (pin 6 and pin 8)

*/

const int pinMA1=2;

const int pinMA2=4;

const int pinMB1=6;

const int pinMB2=8;

const int Enable1=A0;

const int Enable2=A1;

int Byteout=0;

int space=32;

float val=255;

void setup(){

Serial.begin(9600);

pinMode(pinMA1,OUTPUT);

pinMode(pinMA2,OUTPUT);

pinMode(pinMB1,OUTPUT);

pinMode(pinMB2,OUTPUT);

pinMode(Enable1,OUTPUT);

pinMode(Enable2,OUTPUT);

}

void loop(){

if(Serial.available()>=0){

char Byteout=Serial.read();

Serial.write(space);

Serial.print("Enable1=");

Serial.print(Enable1);

digitalWrite(Enable1,LOW);

Serial.write(space);

Serial.print("Enable2=");

Serial.print(Enable2);

digitalWrite(Enable2,LOW);

if(Byteout=='w'){ //Move forward

Serial.print("forward A");

Serial.write(space);

digitalWrite(pinMA1, HIGH);

digitalWrite(pinMA2, LOW);

char Byteout=Serial.read();

analogWrite(Enable1, val);

}

if(Byteout=='q'){ //Turn left and move forward

Serial.print("left && forward");

Serial.write(space);

digitalWrite(pinMA1, HIGH);

digitalWrite(pinMA2, LOW);

digitalWrite(pinMB1, LOW);

digitalWrite(pinMB2, HIGH);

char Byteout=Serial.read();

analogWrite(Enable1, val);

analogWrite(Enable2, val);

}

if(Byteout=='e'){ //Turn right and move forward

Serial.print("right && forward");

Serial.write(space);

digitalWrite(pinMA1, HIGH);

digitalWrite(pinMA2, LOW);

digitalWrite(pinMB1, HIGH);

digitalWrite(pinMB2, LOW);

char Byteout=Serial.read();

analogWrite(Enable1, val);

analogWrite(Enable2, val);

}

if(Byteout=='s'){ //Move backward

Serial.print("backward A");

Serial.write(space);

digitalWrite(pinMA1, LOW);

digitalWrite(pinMA2, HIGH);

char Byteout=Serial.read();

analogWrite(Enable1, val);

}

if(Byteout=='a'){ //Move backward

Serial.print("backward A");

Serial.write(space);

digitalWrite(pinMA1, LOW);

digitalWrite(pinMA2, HIGH);

digitalWrite(pinMB1, HIGH);

digitalWrite(pinMB2, LOW);

char Byteout=Serial.read();

analogWrite(Enable1, val);

analogWrite(Enable2, val);

}

if(Byteout=='d'){ //Move backward

Serial.print("backward A");

Serial.write(space);

digitalWrite(pinMA1, LOW);

digitalWrite(pinMA2, HIGH);

digitalWrite(pinMB1, LOW);

digitalWrite(pinMB2, HIGH);

char Byteout=Serial.read();

analogWrite(Enable1, val);

analogWrite(Enable2, val);

}

if(Byteout=='x'){ //Turn right

Serial.print("forward B");

Serial.write(space);

digitalWrite(pinMB1, HIGH);

digitalWrite(pinMB2, LOW);

char Byteout=Serial.read();

analogWrite(Enable2, val);

}

if(Byteout=='z'){ //Turn left

Serial.print("backward B");

Serial.write(space);

digitalWrite(pinMB1, LOW);

digitalWrite(pinMB2, HIGH);

char Byteout=Serial.read();

analogWrite(Enable2, val);

}

if(Byteout=='h'){ //Breaking all motors high

Serial.print("high A && B");

Serial.write(space);

digitalWrite(pinMA1, HIGH);

digitalWrite(pinMA2, HIGH);

digitalWrite(pinMB1, HIGH);

digitalWrite(pinMB2, HIGH);

char Byteout=Serial.read();

analogWrite(Enable1, val);

analogWrite(Enable2, val);

}

if(Byteout=='l'){ //Breaking all motors low

Serial.print("low A && B");

Serial.write(space);

digitalWrite(pinMA1, LOW);

digitalWrite(pinMA2, LOW);

digitalWrite(pinMB1, LOW);

digitalWrite(pinMB2, LOW);

char Byteout=Serial.read();

analogWrite(Enable1, val);

analogWrite(Enable2, val);

}

}

delay(500);

}

Favorite Part Is to Connect L298N to 2 Motors

2014-12-25 17.59.49.jpg

You can refer on L298N motor driver picture. There is the rest information how to connect the L298N to the motors and to Arduino. You can skip 10 OHM resistor which links the GRND with current sensor. Enable1 and Enable2 pins goes to A0 and A1 respectively. Pins 2, 4 ,6, 8 on Arduino plugs to motor A and motor B.

L298N (motor Driver Chip)

2014-12-25 18.00.25.jpg

Every single pin on L298N chip should be linked to motors to Arduino, to power supplying the chip, for power supplying the motors and 2 wires Enable1 and Enable2 to GRND. GRND linked to GRND Arduino board. No free pins should be left on L298N.

L298N Chip

L298N (not 10ohm).png

10OHM resistor is heating up, you can try to mount something greater than 10OHM, but the current will get too imitated and current sensing will not work. You will be not able to rotate the motors direct and opposite senses..

Arduino Pro Mini to Converter FTDI

Arduino Pro Mini.png

If you don't see your port in Serial port. It does not mean that your connexion is wrong. You should probably go check your FTDI drivers for Arduino pro mini. You can go:

https://learn.sparkfun.com/tutorials/how-to-instal...

Connexion Arduino Board to Bluetooth

Connexion Arduino to bluetooth.png

This diagram illustrates how to provide 3.3V to bluetooth's RX from TX Arduino's board pin. The only thing is different is the board itself. I am using Arduino Pro Mini (I find it more practical for projects like this).

SPDT Switch

DSC00102.JPG

SPDT switch provides the power from the 7.5V batteries to RAW pin of arduino UNO. In case, when a remote control is used this switch cuts the power off of arduino Pro Mini board and it allows to save the power. Another switch would be preferable to access to VCC of bluetooth. Instead of open up each time the truck and take away VCC's bluetooth, that would be easier to switch the power to upload the sketch.