Arduino Dual Controlled RC Car (Bluetooth and WiFi)

25,266

75

28

Introduction: Arduino Dual Controlled RC Car (Bluetooth and WiFi)

This project will combine software and hardware using an Android app and Arduino module.

Things you will need to complete this project:

1. Any old, second hand or junk RC Car

2. Arduino nano

3. HC-05 / HC-06 Bluetooth module

4. ESP8266 WiFi module

5. L928N H-Bridge Motor Driver

6. 3.3V Regulator

7. Servo Motor for turning the wheel

8. FTDI232 USB to TTL Serial Converter Adapter Module 3.3V 5V FT232RL

Step 1: Flashing Esp8266

Download all the necessary files for flashing the esp8266 module here:

And follow the steps from this instructables.

Step 2: The Connection

To put all the modules in RC car, I've cleaned the chassis to make room for the electronic devices.

You can now follow the connection from the image. Then download this app to control the RC car:

https://play.google.com/store/apps/details?id=com....

Arduino code is available on the app.

To see how this actually works:

Thanks and enjoy!.

Step 3:

Be the First to Share

    Recommendations

    • Big and Small Contest

      Big and Small Contest
    • Game Design: Student Design Challenge

      Game Design: Student Design Challenge
    • For the Home Contest

      For the Home Contest

    28 Comments

    0
    ISO-JAS
    ISO-JAS

    7 years ago

    I cant seem to find the code for the Arduino, the app doesn't seem to have the provision for loading it. I'm using a Galaxy S5 and the app looks much different than the example.

    0
    josapedm
    josapedm

    Reply 7 years ago

    Arduino code

    #include
    #include

    // servo
    Servo myservo;
    SoftwareSerial esp(5,6);
    int pos = 45;
    const int analogpin = A0;
    const int pinForward = 3;
    const int pinReverse = 4;
    const int BTState = 7; // Bluetooth state on pin 7 of arduino

    // byte to receive from android
    byte cmd;
    char c;
    int motorSpeed = 0; // default speed, from 0 to 255

    void setup() {
    // setup connection
    Serial.begin(9600);
    esp.begin(115200);
    myservo.attach(9);

    // setup pin mode
    pinMode(analogPin, OUTPUT);
    pinMode(pinForward, OUTPUT);
    pinMode(pinReverse, OUTPUT);
    pinMode(BTState, INPUT);
    }

    void loop() {
    myservo.write(pos);
    motorSpeed = 100;

    // stop car when connection lost or bluetooth disconnected
    if (digitalRead(BTState) == LOW)
    {
    c = 'S';
    myservo.write(pos);
    }

    if (Serial.available() > 0)
    {
    cmd = Serial.read();

    if (cmd == 'A')
    {
    motorSpeed = 100;
    }
    else if (cmd == 'B')
    {
    motorSpeed = 150;
    }
    else if (cmd == 'C')
    {
    motorSpeed = 200;
    }
    else if (cmd == 'D')
    {
    motorSpeed = 255;
    }
    } else if (esp.available() > 0) {

    cmd = esp.read();

    if (cmd == 'A')
    {
    motorSpeed = 100;
    }
    else if (cmd == 'B')
    {
    motorSpeed = 150;
    }
    else if (cmd == 'C')
    {
    motorSpeed = 200;
    }
    else if (cmd == 'D')
    {
    motorSpeed = 255;
    }
    }

    analogWrite(analogPin, motorSpeed);

    c = cmd;
    Serial.println(c);

    // FORWARD
    if (c == 'F')
    {
    digitalWrite(pinForward, HIGH); digitalWrite(pinReverse, LOW);
    }
    // REVERSE
    else if (c == 'G')
    {
    digitalWrite(pinForward, LOW); digitalWrite(pinReverse, HIGH);
    }
    // STOP
    else if (c == 'S')
    {
    digitalWrite(pinForward, LOW); digitalWrite(pinReverse, LOW);
    }
    // RIGHT
    else if (c == 'R')
    {
    pos = 90;
    myservo.write(pos);
    }
    // LEFT
    else if (c == 'L')
    {
    pos = 0; myservo.write(pos);
    }
    // STRAIGHT
    else if (c == 'I')
    {
    pos = 45; myservo.write(pos);
    }
    }

    0
    mateoENP
    mateoENP

    Reply 3 years ago

    Hola el codigo me tira un error stray 342 a que se refiere ?

    0
    zeesh1979
    zeesh1979

    Reply 6 years ago

    such a clever and simple approach you used to do this amazing task. i need some help on below:

    1. you used ESP in your project but i couldnt see how you are using it in code. are you receiving commands from mobile via bluetooth or wifi?

    2. I have HC-06 module. its STATE pin will tell me its connectivity status too or its only HC-05 who does this?

    3. can i have android source code for mobile app?

    i am working on similar project but to control my quadcopter. i used HC-06 succesfully but i can do good test coz i fear if BT is disconnected then i will loose my quad. i am not sure if HC-06 STATE pin really gives status of BT or no.

    waiting for your support. God bless you.

    0
    josapedm
    josapedm

    Reply 6 years ago

    Question 1: I'm using ESP to receive command from my Androuino App.

    Question 2: HC-06 has to state pin. You can do this using HC-05 module only.

    Question 3: Sorry it's pretty complicated to give you my Android source code.

    HC-06 state pin is not functioning. I've tried that before. You can only succeed using the HC-05 bluetooth module. It's the module I know that has a state capability in case you loose connection.

    Let me know if you have more questions. I'll be happy to response and help you. You can also check my Android App if you want to make or suggest an improvement of if you want me to add more functionality to the app so that your need will be met using my app. I'm frequently updating my App based on the demand of my users. Thank you.

    Good luck and God bless also...

    All the best,

    0
    zeesh1979
    zeesh1979

    Reply 6 years ago

    Thanks Josapedm for your quick response which usually lacks on such forums. i totally agree with the complexity of your sharing android code but can you just tell me which java class you used for sending data?

    for HC-06, you are right that state pin doesnt help u but were u able to find out what is the purpose of this STATE pin?

    from your article, i can summarise the steps as below:

    1. flash ESP with nodemcu_integer_0.9.6-dev_20150406.bin you put on github

    2. connect ESP with pin 5 and 6 (skip BT part as main communication is via wifi)

    3. send output to ESC to run motor

    4. send control commands from android app

    5. you are using BT just to make sure the connection with app is alive (dont we have similar function in ESP?)

    0
    josapedm
    josapedm

    Reply 6 years ago

    Hi,

    BT state usually work when the connection is lost or there's no live connection between two devices. It work like a continuous talking of two devices once established the connection.

    For the complete documentation or example code of java class. If you're familiar with Android Studio, you can view the example Bluetooth chat app from the IDE. I have used most of my java codes from this example. This is a very good starting point and I recommend it to you.

    We can achieve the same functionality using esp and this will be implimented starting from my next updated lua script.

    0
    josapedm
    josapedm

    Reply 7 years ago

    The source code for arduino is available on the app in arduino code menu.

    However if there's something wrong with the app. Could you take screen shots of the problem you're having with the app and kindly send it to me in this email: androuino.info@gmail.com.

    I'll do my best to solve this issue.

    Thanks‥.

    0
    zeesh1979
    zeesh1979

    Reply 6 years ago

    can you please share the ESP8266 library you used here and also did you programme it as well?

    0
    josapedm
    josapedm

    Reply 7 years ago

    Could you also provide me the Android Version of your Galaxy S5? Thanks.

    1
    Martin17
    Martin17

    6 years ago

    hi josapedm

    could you please leave the full Arduino code here?

    or it will be wonderful if you could email it to me.

    i wasn't able to copy the arduino code from the mobile app and I wasn't able to extract it at all.

    thanks.

    0
    josapedm
    josapedm

    Reply 6 years ago

    Sure. I'll paste it here. I can also send it to you if you want. Just give me ur email so I can give u the .ino files, it would be more convenient.

    0
    alifn7
    alifn7

    Reply 5 years ago

    hey can you send the ino file to me?? please

    0
    josapedm
    josapedm

    Reply 5 years ago

    Hi, it's in the comment below. Try to look at it.

    0
    alifn7
    alifn7

    Reply 5 years ago

    Its different from code in your app...
    And you have video can make it easier in flashing esp8266 or sugestion video from youtube may be..

    0
    josapedm
    josapedm

    Reply 5 years ago

    What exactly you need? The ino file or how to flash esp8266?

    You can give me your email by the way if you need the ino sketch.

    0
    alifn7
    alifn7

    Reply 5 years ago

    Both of them ..

    0
    Martin17
    Martin17

    Reply 6 years ago

    thanks a lot

    could you please just paste it here.

    I really thank you