Friday 11 November 2016

Android App controlled 2WD RC Robot Platform Car Kit with BT hc-06 +Arduino UNO + L293D motor shield






1. The Kit
This kit is available from our eBay store.
It comes with the following  parts:

2 x Geared motors + 2 x Tyres/wheels + 2 x Motor fixings
4 x motor cables.
1 x  transparent acrylic glass plate 
1 x L293D motor shield
1 x  Arduino UNO328 controller board (CH340 usb driver)
1 x HC-06 Bluetooth module
1 x Battery holder (12V , 8 x AA / batteries not included)
2 x motor speed encoding disks (Use with IR optocoupler sensors which are not included)
1 x USB cable for arduino 
1x Castor wheel + 4 x Copper pillar + Screws kit 
1x on/off toggle mini switch, extra screws and nuts, tie cables etc


2. Connect the motors


Connect the motors and wheels as shown in the  figure 1.  Solder the red and black wires as shown. These correspond to the positive and negative of the motors/battery terminals. If you connect the red and black to the +ve and -ve of the battery , all the motors/ wheels should spin in the same direction. If any wheel spins in a different direction swap the wires on the motor terminals to correct the spin.

Figure 1: Connecting wheels and motors




2. Connect Bluetooth Hc-06 to arduino
Solder wires to arduino uno according to the following connection table.


HC-06
Arduino
VCC
3.3v
GND
GND
TXD
RXD
RXD
TXD
Figure 2



Figure 3:

3. Connect the motor shield

and tie to chassis as shown below



Figure 4



4. Connect motor cables and power to Arduino shield
connect both motors to the shied as shown in figure below. The terminal are marked as M3 and M4 on the shield. Also connect the battery terminals to power the board.


Figure 5



5. Arduino code:

Before uploading the code to arduino uno, always disconnect the power to HC-06.

To control the motors, i used the library <AFMotor.h>.

#include <AFMotor.h> //creates two objects to control the terminal 3 and 4 of motor shield AF_DCMotor motor1(3); AF_DCMotor motor2(4); char command; void setup() { Serial.begin(9600); //Set the baud rate to your Bluetooth module. } void loop(){ if(Serial.available() > 0){ command = Serial.read(); Stop(); //initialize with motors stoped //Change pin mode only if new command is different from previous. Serial.println(command); switch(command){ case 'F': forward(); break; case 'B': back(); break; case 'L': left(); break; case 'R': right(); break; } } } void forward() { motor1.setSpeed(255); motor1.run(BACKWARD); motor2.setSpeed(255); motor2.run(BACKWARD); } void back() { motor1.setSpeed(255); motor1.run(FORWARD); motor2.setSpeed(255); motor2.run(FORWARD); } void left() { motor1.setSpeed(255); motor1.run(BACKWARD); motor2.setSpeed(0); motor2.run(RELEASE); } void right() { motor1.setSpeed(0); motor1.run(RELEASE); motor2.setSpeed(255); motor2.run(BACKWARD); } void Stop() { motor1.setSpeed(0); motor2.run(RELEASE); motor2.setSpeed(0); motor2.run(RELEASE); }

6. Android App


The link to Download the app from google play store is:
A screen shot of the app is shown in Fig 6. The app has both accelerometer and button control functionality.


Figure 6: Bluetooth RC Controller









7. Results: 





1 comment: