PROJECTS Arduino DIY BLE Control RC Rover (Powered by Romeo BLE Quard)
DFRobot
Jan 21 2017 260472
This tutorial is wrote by Salah Uddin and originally posted on hackster.io. Bellowing is the text.
/2017-01-05_19_wXWawNych3.jpg)
THINGS USED IN THIS PROJECT
----------------------------------------------------------------------------------------------------------------------------
Hardware components:
Jumper wires (generic) × 1
Software apps and online services:
STORY
-------------------------------------------------------------------------------------------------------------------------
Introduction
Playing with RC car is fun but if you play with your own RC car then its a explosion of fun. Now a days most of the RC car controller user BLE technology with may reduce the cost. Every smart phone has BLE, so let play with it. If you follow this tutorials you are able to build your own DRY RC car.
Thanks to DFRobot to give me the opportunity to play with Romeo BLE Quard Motor Driver . Its a powerful motor driver with 32 bit ARM Microcontroller with CC2540 (Bluetooth 4.0) chip. For more detail about Romeo BLE quard please check the page.
Just follow those simple step and enjoy:
—Install the Mobile apps on your smart phone (check the given links for apk file)
—Connect the Rover5 Chassis with BLE Quard Motor Driver
—Upload the Arduino Sketch on BLE Quard
—Connect the power source to BLE quard
—Open the apps and play with your RC car
The Text command for Moving RC Rover
—Move Forward F
—Move Backword B
—Move Left L
—Move Right R
Project Demo:
SCHEMATICS
--------------------------------------------------------------------------------------------------------------
Connection Diagram
/connection_73QgEE06q4.jpg)
Code
* @file BLE-control_motord_rive.ino* @brief Motor control program for Romeo BLE Quard V1.0 using Mobile Application via Bluethooth* @Control Command Use 'F'for Forward 'B' for backwoard 'L' for Left and 'R' for Right* @ Here i use two Motor noly MA and MC possible to extend with forur Motor* control motor using BLE via Bluno Test Apps* * @author akash.bangla@gmail.com* @version V1.0* @date 2017-01-05* pin mapping ref: https://www.dfrobot.com/wiki/index.php/Romeo_BLE_Quad_Robot_Controller_SKU:_DFR0398 * product wiki: https://www.dfrobot.com/wiki/index.php/Romeo_BLE_Quad_Robot_Controller_SKU:_DFR0398*/// motor oneconst int IA1=8; const int IA2=23;// motor Twoconst int IB1=7;const int IB2=9;// motor Threeconst int IC1=24;const int IC2=14;// motor fourconst int ID1=4;const int ID2=25;
byte byteRead;
void setup() { Serial1.begin(115200); //initial the Serial //use four motor pinMode(IA1, OUTPUT); pinMode(IA2, OUTPUT); pinMode(IB1, OUTPUT); pinMode(IB2, OUTPUT); pinMode(IC1, OUTPUT); pinMode(IC2, OUTPUT); pinMode(ID1, OUTPUT); pinMode(ID2, OUTPUT);
pinMode(13, OUTPUT); pinMode (20,OUTPUT); // place a LED on pin 20 }//use slow decay PWM value maximum 100 ref https://www.dfrobot.com/wiki/index.php/Dual_1.5A_Motor_Driver_-_HR8833_SKU:_DRI0040void loop() { digitalWrite(13,LOW); digitalWrite(20,LOW); Motor_reset(); /* check if data has been sent from the computer: */ if (Serial1.available()) { /* read the most recent byte */ byteRead = Serial1.read(); /*Listen for a F which means Forward */ if(byteRead== 'F'){ Serial1.println("Moving Forward"); digitalWrite(13,HIGH); digitalWrite(20,HIGH); MA_move(50,0); MC_move(50,0); delay(1000); } else if (byteRead == 'B') { Serial1.println("Moving Backword"); digitalWrite(20,HIGH); MA_move(50,1); MC_move(50,1); delay(1000); } else if (byteRead == 'L') { Serial1.println("Moving Left"); digitalWrite(20,HIGH); MA_move(50,0); MC_move(50,1); delay(1000); } else if (byteRead == 'R') { Serial1.println("Moving Right"); digitalWrite(20,HIGH); MA_move(50,1); MC_move(50,0); delay(1000); } else{ /*ECHO the value that was read, back to the serial port. */ Serial1.write(byteRead); } }
}
//fuction that reset all the motor void Motor_reset(){ //reset the motor A digitalWrite(IA1,LOW); digitalWrite(IA2,LOW); //reset the motor B digitalWrite(IB1,LOW); digitalWrite(IB2,LOW); //reset the motor C digitalWrite(IC1,LOW); digitalWrite(IC2,LOW); //reset the motor D digitalWrite(ID1,LOW); digitalWrite(ID2,LOW);}
void MA_move(int Speed,int dir) //for dir FALSE move forward, otherwise Backword { if (dir == 0) { analogWrite(IA1,Speed); //set the PWM value digitalWrite(IA2,HIGH); } else { analogWrite(IA2,Speed); //set the PWM value digitalWrite(IA1,HIGH); } }
void MB_move(int Speed,bool dir) //for dir FALSE move forward, otherwise Backword { if (dir == 0) { analogWrite(IB1,Speed); //set the PWM value digitalWrite(IB2,HIGH); } else { analogWrite(IB2,Speed); //set the PWM value digitalWrite(IB1,HIGH); } }
void MC_move(int Speed,bool dir) //for dir FALSE move forward, otherwise Backword { if (dir == 0) { analogWrite(IC1,Speed); //set the PWM value digitalWrite(IC2