The are many lot cost RC cars with lots of features like the LED headlights and underglow lights. However, the remote controller came with the car cannot control lights and motors individually. With mobile App and Arduino board, we can convert these ordinary RC Cars to a more advanced bluetooth control toys.
We are using an Arduino Compatible board with BLE (Bluetooth Low Energy) by Wombatics, so that it works with both iOS and Android phone.
1. Picking a RC CarWe picked a Fast Lane 1:24 RC Car. This car is prefect for this project, as it has all features that we are looking for, such as headlight and underglow LEDs with enough room to put our board inside.
2. Taking the Car apartAfter taking it apart, identify the wires for LEDs and motors. The desoldering them off the board and replace them with Arduino board and motor drive module.
3. Putting on the motor drive moduleIn this step, solder the steering motor to "MOTO A" and back motor to "MOTO B" on the motor driver module. Solder jumper wires to headlight & under-glow LEDs on both +ve & -ve side.
4. Connecting to the SAM01 Arduino robotics boardPutting on the SAM01 Arduino Robotics Board and connecting the jumper wires as following.
PIN 3 - INT1 for Motor A (Steering Motor)PIN 5 - INT2 for Motor A PIN 6 - INT3 for Motor B (Drive Motor)PIN 9 - INT4 for Motor BPIN 10 - Headlight LEDsPIN 13 - Under-glow LEDs
5. Arduino Coding & TestingNow it is time for testing all the connections. I have made Sam_RC_Car_Test.ino for ease of testing. Upload the ino file with Arduino IDE.
** Set board to "Arduino Nano" in Arduino IDE**
/*************************************************************
SAM01 RC Car Connections Testing
*************************************************************
This example shows how to use SAM01 Arduino Robotics board
to control a RC Car.
This example code is in the public domain.
https://github.com/wombatics/sam01/tree/master/Arduino/examples
*************************************************************/
#define MA1 3
#define MA2 5
#define MB1 6
#define MB2 9
#define BOTTOM_LED 13
#define FRONT_LED 10
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
pinMode(MA1, OUTPUT);
pinMode(MA2, OUTPUT);
pinMode(MB1, OUTPUT);
pinMode(MB2, OUTPUT);
pinMode(BOTTOM_LED, OUTPUT);
pinMode(FRONT_LED, OUTPUT);
}
void loop() {
// right
analogWrite(MA1, 255);
analogWrite(MA2, 0);
// forward
analogWrite(MB1, 150);
analogWrite(MB2, 0);
delay(3000);
// left
analogWrite(MA1, 0);
analogWrite(MA2, 255);
// stop
analogWrite(MB1, 0);
analogWrite(MB2, 0);
delay(3000);
// middle
analogWrite(MA1, 0);
analogWrite(MA2, 0);
// backward
analogWrite(MB1, 0);
analogWrite(MB2, 255);
delay(3000);
// Testing LEDs
digitalWrite(BOTTOM_LED, HIGH);
digitalWrite(FRONT_LED, HIGH);
delay(100);
digitalWrite(BOTTOM_LED, LOW);
digitalWrite(FRONT_LED, LOW);
delay(100);
}
6. Prepare for BlynkAfter the connections are verified. We are ready to connect with Blynk through BLE.
First upload the file Sam_Blynk_RC_Car.ino with Arduino IDE.
/*************************************************************
SAM01 RC Car with Blynk.
Blynk is a platform with iOS and Android apps to control
Arduino, Raspberry Pi and the likes over the Internet /
WiFi / Bluetooth.
*************************************************************
This example shows how to use SAM01 Arduino Robotics board
to connect a RC Car to Blynk.
NOTE: BLE support is in beta for Blynk. Too much data will
cause errors in BLE with Blynk.
This example code is in the public domain.
https://github.com/wombatics/sam01/tree/master/Arduino/examples
*************************************************************/
#define MA1 3
#define MA2 5
#define MB1 6
#define MB2 9
#define BOTTOM_LED 13
#define FRONT_LED 10
//#define BLYNK_USE_DIRECT_CONNECT
// You could use a spare Hardware Serial on boards that have it (like Mega)
#include <SoftwareSerial.h>
SoftwareSerial BLESerial(10, 9); // RX, TX
#define BLYNK_PRINT Serial
#include <BlynkSimpleSerialBLE.h>
// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "yourAuthToken";
bool turbo;
void forward(int speed)
{
analogWrite(MB1, speed);
analogWrite(MB2, 0);
// Serial.println("Speed: ");
// Serial.println(speed);
}
void backward(int speed)
{
analogWrite(MB1, 0);
analogWrite(MB2, -speed);
// Serial.println("back speed: ");
// Serial.println(speed);
}
void right(int speed)
{
analogWrite(MA1, speed);
analogWrite(MA2, 0);
}
void left(int speed)
{
analogWrite(MA1, 0);
analogWrite(MA2, speed);
}
BLYNK_WRITE(V0)
{
int pinValue = param.asInt(); // assigning incoming value from pin V1 to a variable
Serial.println(pinValue);
if(pinValue >= 0)
{
if(turbo)
forward(pinValue);
else if (pinValue == 0)
forward(0);
else
forward(pinValue * 0.7 + 30);
}
else
{
backward(pinValue * 0.7 - 30);
}
}
BLYNK_WRITE(V2)
{
int pinValue = param.asInt(); // assigning incoming value from pin V1 to a variable
//Serial.print("Left ");
//Serial.println(pinValue);
if(pinValue)
left(255);
else
left(0);
}
BLYNK_WRITE(V3)
{
int pinValue = param.asInt(); // assigning incoming value from pin V1 to a variable
//Serial.print("Right ");
//Serial.println(pinValue);
if(pinValue)
right(255);
else
right(0);
}
BLYNK_WRITE(V1)
{
int pinValue = param.asInt(); // assigning incoming value from pin V1 to a variable
if(pinValue)
turbo = true;
else
turbo = false;
}
void setup()
{
// Debug console
Serial.begin(115200);
Serial.println("Waiting for connections...");
// Blynk will work through Serial
// Do not read or write this serial manually in your sketch
BLESerial.begin(9600);
Blynk.begin(BLESerial, auth);
pinMode(MA1, OUTPUT);
pinMode(MA2, OUTPUT);
pinMode(MB1, OUTPUT);
pinMode(MB2, OUTPUT);
forward(0);
turbo = false;
}
void loop()
{
Blynk.run();
}
7. Setup BlynkCopy the Auth Token back to Sam_Blynk_RC_Car.ino.
char auth[] = "yourAuthToken";
Turn on the RC Car's power and search for SAM01 in Blynk App by following the steps below
Comments