Buy from US Buy from UK Buy from DE Buy from IT Buy from FR Buy from ES Buy from JP

In this lesson, we will use Mobile to control our robot car and make an imitation driving. Since is a mock driving, we will use a virtual steering wheel and gear in our APP to imitate their counterparts in real car.

In this lesson,Mecanum Omni wheel will allows robot car make omni-directional movement( parallel shift to left and right).

OSOYOO Mecanum Wheels Robotic Car Chassis x 1 (2x left-wheels/2x right-wheels and 4x motor)
OSOYOO Mega2560 board fully compatible with Arduino
OSOYOO V1.0 WIFI Shield x 1
OSOYOO Model X motor driver x 2
OSOYOO HC02 bluetooth module
OSOYOO Battery box x 1
18650 Batteries(3.7V) x 2

You must complete lesson 1 (assembling the car) before you continue on with this lesson.No need change anything, just keep the hardware wire connection as it is.

STEP1: Connect B_TX and B_RX to D19 and D18.

(Note: You need split 2 pcs of male-to-female jumper wires from our 10-pc jumper wire bundle. Any color from the bundle will be ok.  If there are jumper caps in the B_TX, B_RX pin, please remove the jumper caps firstly)

STEP2:Bluetooth Module should be inserted into bluetooth 6-pin slot in OSOYOO WIFI Board

Open-source Arduino
Software(IDE)
Download Arduino IDE here:
https://www.arduino.cc/en/Main/Software?setlang=en
7 zip is a free zip
utility that un-zips zip files
Download 7zip here for free
https://www.7-zip.org/

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 https://osoyoo.com/driver/mecanum/mecanum-2560-lesson4.zip , unzip the download zip file lesson4.zip, you will see a folder called lesson4 .

Step 3: Connect Mega2560 board to PC with USB cable, Open Arduino IDE -> click file -> click Open -> choose code “lesson4.ino” in lesson4 folder, load the code into arduino.

Step 4: Choose corresponding board/port for your project,upload the sketch to the board.

Mobile APP:
Go to your Google Play or Apple APP store and search APP name “OSOYOO imitation driving”, Download the APP as following and install it in your smart phone.

Power on the robot, and open APP.

1)  Connect APP to HC-02 Bluetooth Moduel
Connect with Android device:
If you use Android device and have not paired Bluetooth module with your cell phone, please pair the bluetooth module first before open the APP. In your cell phone Setting->Bluetooth ,find a Bluetooth device called HC02, pair it with password 1234.

After bluetooth HC02 device is paired, open the APP.   Click BT Search Button to connect APP to HC02 device.

Connect with iOS device:
If you use iOS device, simply open the APP, click Connect button, you will see a Bluetooth list, select the HC02 device .

2)Click Engine Switch to start/stop the car

3)Click Speed +/- button to accelerate or reduce speed

4)Rotate the mobile phone to change direction(steering wheel will rotate while you are turning the phone).

5)click Gear button to change gear to Forward or Backward direction.

6)press F1 to Shift to left way, F5 to shift to right way, F3 to up left diagonal, F4 to up right diagonal.

Motor Speed Tuning for better performance

To get better running performance result, motor power(speed) value should be adjusted properly as per battery level. If motor power(speed) value is too high, your car might run too fast and easy to out of control. If motor power(speed) is too low, the car might not even move.

To adjust the motor power value, you need change the 3 constants line 27,28,29 in mecanum-2560-lesson4.ino sketch file:

#define MIN_SPEED  50
#define TURN_SPEED  70
#define SLOW_TURN_SPEED  50
#define BACK_SPEED 60

MIN_SPEED is the minimum power required to start the car. If when APP engine toggle is switched to RED, but your car does not move, you need increase this value , if the car runs too fast at engine start moment, you need reduce this value.

TURN_SPEED AND, SLOW_TURN_SPEED value determines the turning speed of your car. If your car turning too fast, you need reduce these two values, if turning too slow or not turning, increase these two values. Always make SLOW_TURN_SPEED about 20 to 30 lower than TURN_SPEED value.

BACK_SPEED value determines the reverse back running speed.

After batteries are running low, you might need to increase the value of these 3 constants. You can gradually add or reduce 10 each time on these values and compare which values have best tracking performance.