Introduction                                      Next

NOTE: ALL OSOYOO PRODUCTS FOR ARDUINO ARE THIRD PARTY BOARD WHICH IS FULLY COMPATIBLE WITH ARDUINO

Contents

Authorized Online Retailers

Objective

Welcome to the first lesson of OSOYOO 2WD Robot Car Starter Kit!

In this “Hello World” version lesson, we will install the most important framework of the robot car and program the car to do some simple movements. If you have passed the test movement of this lesson, it means Arduino, motor control module, motors, batteries, chassis, and wire connections between these parts are all functioning well.

As your experiments in future lessons are all based on the framework of Lesson 1, it is very essential to test the installation and sample code in this Lesson properly.

top

Hardware Installation

Remove the protective film from the back of the chassis.

1 )Motors

Accessories:

  • Motor Holder Set x2

Install 2 motors on the chassis with the motor holders

Notice

Please install it on the side of the motor wires

Keep the end with the screw holes facing up

2) Universal Wheel and Wheels

Accessories:

  • M3*10 Double Pass Copper Pillar x 4
  • M3*5 Hex Screw x 8
  • Screws for wheels x 2

Install the wheel on the chassis with M3*10 Double Pass Copper Pillars and M3*5 Hex Screws, then install the two wheels onto the motors.

3) Install OSOYOO UNO Board

Accessories:

  • M3*6 Plastic Screw  x 3
  • M3 Plastic Nut  x 4
  • M3*5+6 Plastic Pillar x 4

Fixed the OSOYOO UNO board on the surface of the chassis with the M3 screws and nuts

4) OSOYOO Model-X Motor Driver Module

Accessories:

  • M3*6 Plastic Screw  x 4
  • M3 Plastic Nut  x 4
  • M3*5+6 Plastic Pillar x 4

Fixed the OSOYOO Model-X motor driver module on the surface of the chassis with the M3 screws and nuts

5) Battery Box

Accessories:

  • M3*10 Screw  x 4
  • M3 Nut  x 4

Fixed the battery box on the surface of the chassis with the M3 screws and nuts.

6) Insert Wifi Shield into UNO Board

7 ) IR Receiver

Accessories:

  • M3*6 Plastic Screw  x 2
  • M3 Plastic Nut  x 2
  • M3*5+6 Plastic Pillar x 2

8 )  Tracking Sensor Module

Accessories:

  • M3*6 Plastic Screw  x 4
  • M3*12 Plastic Pillar x 2

9 ) Battery

Notice: check the box instruction and make sure polar direction is correct, otherwise it can destroy your device and cause fire hazard.

Please keep the switch of the battery box to OFF.

Wire Connection

  1.  Connect Battery Box to Wi-Fi Shield

2. Connect the OSOYOO Model-X and WiFi Shield for Arduino UNO as shown below:

3. Connect OSOYOO Model-X Motor Driver Module with 2 motors

The right motor connected to K1 or K2, the left motor connected to K3 or K4 as shown below:

4. Connect OSOYOO UART Wi-Fi Shield with IR Receiver:

5. Connect OSOYOO UART Wi-Fi Shield with the tracking sensor:

The Lest Tracking Sensor
Tracking Sensor Sensor Shield V5.0 for Arduino UNO
VCC 5V
GND GND
DO S2
AO Not Connected
The Right Tracking Sensor
Tracking Sensor Sensor Shield V5.0 for Arduino UNO
VCC 5V
GND GND
DO S3
AO Not Connected

top

Software Installation

Notice: Shut off your battery or Unplug your power adapter when upload sketch code to Arduino.

Step 1:

Install latest Arduino IDE (If you have Arduino IDE version 1.18.19, 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/2wd/lesson1.zip , unzip it, you will see a folder called lesson1

Step 3:

Connect UNO R3 board to PC with USB cable, open Arduino IDE, choose corresponding board/port for your project

Step 4:

Click file -> click Open -> choose code “lesson1.ino”, load the code into Arduino, and then upload the sketch to the board.

top

Code Explanation

Below is the interface definition between OSOYOO Model-X and arduino

Notice: ENA and ENB should connect to PWM port,   IN1/IN2 control Right Motor rotating direction,
IN3/IN4 control Left Motor rotating direction

#define speedPinR 9 // RIGHT PWM pin connect MODEL-X ENA
#define RightMotorDirPin1 12 //Right Motor direction pin 1 to MODEL-X IN1 
#define RightMotorDirPin2 11 //Right Motor direction pin 2 to MODEL-X IN2
#define speedPinL 6 // Left PWM pin connect MODEL-X ENB
#define LeftMotorDirPin1 7 //Left Motor direction pin 1 to MODEL-X IN3 
#define LeftMotorDirPin2 8 //Left Motor direction pin 1 to MODEL-X IN4 
#define SPEED 140
#define RIGHT_SPEED 140

The below functions can control the car forward, backward, stop, turn right and turn left:

void go_Advance(void) //Forward
{
digitalWrite(RightMotorDirPin1, HIGH);
digitalWrite(RightMotorDirPin2,LOW);
digitalWrite(LeftMotorDirPin1,HIGH);
digitalWrite(LeftMotorDirPin2,LOW);
analogWrite(speedPinL,SPEED);
analogWrite(speedPinR,SPEED);
}
void go_Left(int t=0) //Turn left
{
digitalWrite(RightMotorDirPin1, HIGH);
digitalWrite(RightMotorDirPin2,LOW);
digitalWrite(LeftMotorDirPin1,LOW);
digitalWrite(LeftMotorDirPin2,HIGH);
analogWrite(speedPinL,SPEED);
analogWrite(speedPinR,SPEED);
delay(t);
}
void go_Right(int t=0) //Turn right
{
digitalWrite(RightMotorDirPin1, LOW);
digitalWrite(RightMotorDirPin2,HIGH);
digitalWrite(LeftMotorDirPin1,HIGH);
digitalWrite(LeftMotorDirPin2,LOW);
analogWrite(speedPinL,SPEED);
analogWrite(speedPinR,SPEED);
delay(t);
}
void go_Back(int t=0) //Reverse
{
digitalWrite(RightMotorDirPin1, LOW);
digitalWrite(RightMotorDirPin2,HIGH);
digitalWrite(LeftMotorDirPin1,LOW);
digitalWrite(LeftMotorDirPin2,HIGH);
analogWrite(speedPinL,SPEED);
analogWrite(speedPinR,SPEED);
delay(t);
}
void stop_Stop() //Stop
{
digitalWrite(RightMotorDirPin1, LOW);
digitalWrite(RightMotorDirPin2,LOW);
digitalWrite(LeftMotorDirPin1,LOW);
digitalWrite(LeftMotorDirPin2,LOW);
}

The below functions can change motor speed, viriable speed_L can change the left motor speed, variable speed_R can control the right motor speed.

The valid range for this function parameter is 0-255

void set_Motorspeed(int speed_L,int speed_R)
{
analogWrite(speedPinL,speed_L); 
analogWrite(speedPinR,speed_R); 
}

top

Testing

Disconnect Arduino from PC, put 2 fully-charged 18650 battery into battery box (check the box instruction and make sure polar direction is correct, otherwise it can destroy your device and cause fire hazard). Please install your battery as per the following instruction:

Put the car on the ground, open the power switch on the battery box, open the power switch on the Wi-Fi Shield.

The car should go forward 2 seconds, then go backward 2  seconds, then left turn for 2 seconds, then right turn for 2 seconds, then stop.

If the car does not move as per above-mentioned result, you should check your wire connection, battery voltage (must over 7.2v).

top

Parts and Devices:

No. Picture Device Qty. Data sheet Buy in Link
1 OSOYOO basic board 1 click here Click here to buy
2 OSOYOO UART Wi-Fi shield V1.3 1 click here Click here to buy
3 OSOYOO model X motor driver module 1 click here Click here to buy
4 IR receiver 1 click here Click here to buy
5 IR remote controller 1 click here Click here to buy
6 Tracking sensor module 2 click here Click here to buy
7 HC module 1 click here Click here to buy
8 Gear motor 2 Click here to buy
9 Metal Motor Holders with screws 2 Click here to buy
10 Wheel 2 Click here to buy
11 Universal Wheel 1
12 6pin male to 6pin female jumper wire 1 Click here to buy
13 OSOYOO 2pin PnP cable 20 cm 1 Click here to buy
14 20Pin jumper wire Male to female 15 cm 1 Click here to buy
15 Philips screwdriver 1 Click here to buy
16 Hex Screwdriver 1 Click here to buy
17 18650 battery box 1 Click here to buy
18 Battery charger for 18650 battery 1 Click here to buy
19 1Pair 18650 batteries 1 Click here to buy
20 M3*5 Hex Screws 10
21 M3*10 screw 4
22 M3 nut 4
23 Copper pillar 4
24 Screw for wheel 2
25 M3 plastic screw 15
26 M3 plastic pillar 15
27 M3 plastic nut 15

top

                                                                                              Introduction                                                                  Next