I.Objective
II.Parts and Devices
III.Hardware Installation
IV.Circuit Connection
V.Software Installation
VI.How to play


Mecanum Wheel Robot Car Full Package (with 18650 batteries)

Buy from US Buy from UK Buy from DE Buy from IT Buy from FR Buy from ES ここでご購入を!

The above robot cars are controlled by Arduino. If you have Raspberry Pi board, actually the robot car can also be controlled by Raspberry Pi. You can visit the following link to learn basic movement with Raspberry Pi.
Tutorial link- https://osoyoo.com/?p=31428


In this lesson, you must complete lesson 1 before you continue on with this lesson. We use the ultrasonic module to “see” the obstacle and measure the distance. If the distance is less than the predefined threshold value, the buzzer will beep and the car will turn around from the obstacle automatically.

OSOYOO Mecanum Wheels Robotic Car Chassis x 1 (2xleft-wheels/2xright-wheels and Motor x 4)
OSOYOO Mega2560 board, fully compatible with Arduino x 1
OSOYOO Wi-Fi shield x 1
OSOYOO Model Y motor driver x 1
OSOYOO MG90 servo motor x 1
OSOYOO Ultrasonic sensor module x1
OSOYOO Ultrasonic mount holder
OSOYOO Battery box x 1
OSOYOO 3pin female to female jumper wire x1
OSOYOO 6pin male to female jumper wire x2
OSOYOO 2 pin XH.25 female to female x1
OSOYOO 10 pin jumper wire male to female x1
18650 Batteries(3.7V) x 2

You must complete lesson 1 (assembling the car) before you continue on with this lesson.In this lesson3, we will add a mg90 servo motor and to the robotic car built in Lesson 1.

Step1: Install Ultrasonic Module to mount holder with 4pcs M1.4*8 screw and M1.4 nuts

Step 2: Install mount holder for ultrasonic module on servo motor with M2*4 Self Tapping screw.

When placing the ultrasonic underneath, as the self-tapping screws easily strip.
A.Support the motor from underneath, as the self-tapping screws easily strip.
B.Do not insert the screw until after the alignment process.


You must complete lesson 1 (assembling the car) circuit connection. No need to change anything, just keep the hardware wire connection as it is.

Step3:Please keep all lesson 1 connections same as it is.Before connecting wires, make sure that you have connect SG90 servo motor to model Y board and OSOYOO Uart Wi-Fi shield as follows.

(Note: You need to split 1 pcs of male-to-female jumper wires from our 10-pc jumper wire bundle. Any color from the bundle will be ok. The rest   wires are as spare parts for potential broken or damaged wires.)


Step4: Connect VCC, Trig, Echo, GND of ultrasonic module to 5V,D30,D31,GND of Wi-Fi shield with 4 pcs of male-to-female jumper wires.

(Note: You need to split 4 pcs of male-to-female jumper wires from our 10-pc jumper wire bundle. Any color from the bundle will be ok. The rest   wires are as spare parts for potential broken or damaged wires.)



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 unzips 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_metal_chassis_m2/m2-lesson2.zip, unzip the download zip file m2-lesson2.zip, you will see a folder called m2-lesson2.)

Step 3: Connect Mega2560 board to PC with USB cable, Open Arduino IDE → click file → click Open → choose code “m2-lesson2” in lesson folder, load the code into Arduino as following.

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

Step 5:Ultrasonic sensor servo initial direction alignment

After turning on the battery, the servo will make some movement and finally stops at a direction for 5 seconds.

During this first 5 seconds, you must make sure the Ultrasonic sensor (two eyes) is facing straight forward.

If it is not straight forward, you should turn off battery immediately and remove the sensor from servo, reinstall it and make it facing straight forward direction as following picture. Otherwise, the obstacle avoidance program will not work properly.

After adjusting sensor direction, turn on battery again. If its direction is not straight forward, turn off battery and do direction alignment again.



If the ultrasonic module turn to front view position, that means you don’t need to adjust sensor position anymore. Just wait 5 seconds. If no obstacle is detected, the car will go forward. If any obstacles are detected, the car will stop, the ultrasonic module will turn from right to left to detect surrounding obstacle. The robot car will decide to make left turn, right turn or backward according to obstacle sensor data and our obstacle avoidance algorithm.

Sometimes your car might have collision and make your Ultrasonic sensor position change, you must remember to do sensor direction alignment again.

The robot car will decide to make left turn, right turn or backward according to obstacle sensor data and our obstacle avoidance algorithm. Sometimes your car might have collision and make your Ultrasonic sensor position change, you must remember to do sensor direction alignment again.

Important parameters in the sketch file

Following parameters in Line 35 to 39 of m2-lesson2.ino are very important to make performance tuning. See the comments in the #define statements:

#define FAST_SPEED 170 //both sides of the motor speed
#define SPEED 100 //both sides of the motor speed
#define TURN_SPEED 150 //both sides of the motor speed
#define BACK_SPEED1 150 //back speed
#define BACK_SPEED2 100 //back speed