Buy from US | Buy from UK | Buy from DE | Buy from IT | Buy from FR | Buy from ES |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
Welcome to the fourth lesson of OSOYOO 2WD Robot Car Starter Kit!
In this lesson, we will introduce how to control the car by the mobile APP through bluetooth.
Step 1: Install latest Arduino IDE
(If you have Arduino IDE version after 1.1.16, please skip this step). Download Arduino IDE from https://www.arduino.cc/en/Main/Software?setlang=en , then install the software.
Step 2: Download and unzip lesson-4.zip , you will see a folder called lesson-4.
Step 3: Connect UNO R3 board to PC with USB cable, open Arduino IDE, choose corresponding board/port for your project,upload the sketch to the board.
Step 4: Arduino IDE: Click file -> click Open -> choose code “lesson-4.ino” in lesson-4 folder, load the code into arduino.
Install the robot car basic framework as per Lesson 1 and Lesson 3. If you have already completed the installation in Lesson 1 and Lesson 3, just keep it, no need to remove any module installed.
Install the bluetooth module on the Sensor Shield V5.0 for Arduino UNO as follows:
Bluetooth Module | Sensor Shield V5.0 for Arduino UNO |
RXD | TX |
TXD | RX |
GND | – |
VCC | + |
More information about this module please refer to:
HC-02 Bluetooth 4.0 BLE Slave Module to UART Transceiver Arduino Compatible with Android and iOS
Please search “OSOYOO BLUETOOTH ROBOT CAR” in GOOGLE PLAY
Note: Android APP Source code:https://osoyoo.com/driver/BTcar-master.zip (This APP is just compatible with Android OS)
Please search “OSOYOO Arduino ROBOT CAR” in APP STORE
You can refer to this link: https://osoyoo.com/2018/08/17/how-to-use-ios-phone-control-the-robort-car/
The following code is used to receive the instructions sent by the APP, and then send the information back to the APP.
void do_Uart_Tick() { char Uart_Date=0; if(Serial.available()) { size_t len = Serial.available(); uint8_t sbuf[len + 1]; sbuf[len] = 0x00; Serial.readBytes(sbuf, len); //parseUartPackage((char*)sbuf); memcpy(buffUART + buffUARTIndex, sbuf, len);//ensure that the serial port can read the entire frame of data buffUARTIndex += len; preUARTTick = millis(); if(buffUARTIndex >= MAX_PACKETSIZE - 1) { buffUARTIndex = MAX_PACKETSIZE - 2; preUARTTick = preUARTTick - 200; } } if(buffUARTIndex > 0 && (millis() - preUARTTick >= 100))//APP send flag to modify the obstacle avoidance parameters { //data ready buffUART[buffUARTIndex] = 0x00; Uart_Date=buffUART[0]; buffUARTIndex = 0; } switch (Uart_Date) //serial control instructions { case '2': Drive_Status=MANUAL_DRIVE; Drive_Num=GO_ADVANCE;Serial.println("forward"); break; case '4': Drive_Status=MANUAL_DRIVE; Drive_Num=GO_LEFT; Serial.println("turn left");break; case '6': Drive_Status=MANUAL_DRIVE; Drive_Num=GO_RIGHT; Serial.println("turn right");break; case '8': Drive_Status=MANUAL_DRIVE; Drive_Num=GO_BACK; Serial.println("go back");break; case '5': Drive_Status=MANUAL_DRIVE; Drive_Num=STOP_STOP;Serial.println("stop");break; case '1': Drive_Status=AUTO_DRIVE_LF; Serial.println("line follow...");break; default:break; } }
Step 1) Turn on the switch on the battery box
Put 2 fully-charged 18650 battery into battery box (check the box instruction and make sure polar direction is correct). Open the power switch in the battery box.
Step 2) Turn on bluetooth of your phone
Please turn on bluetooth of your phone which you have installed APP and scan bluetooth (different bluetooth module will scan different bluetooth name), click connect and enter password “1234” or “0000” if no change:
Step 3) Open app>> select bluetooth mode>> then you can controller the robot car through bluetooth:
Working Mode
There are two working mode: manual control and tracking. Users can switch freely among two working mode.
1) Manual Cotrol Mode
In manual control mode, you can click buttons (∧) (∨) (<) (>) to control the Robot car to move forward and backward, turn left and turn right. Meanwhile, the APP can observe the car real time movement.
2) Tracking Mode
Click “tracking” button of App to switch the current mode to tracking mode. The Robot car will move forward along the black line in white background. Meanwhile, the APP can observe the car real time movement. Press “||” button to stop moving and click other button to change Robot car working mode. To learn more about this mode, please review our lesson 3.
The rest of the buttons are for the reservation function, you can develop them by yourself.
DownLoad Url osoyoo.com