In this lesson, we will show how make the robot dog do obstacle avoidance movement.


Not much is needed for this lesson, Make sure you have a good quality syncing cable, do not pick a ‘charge only’ USB cable.


由于积木电机旋转方向与黄色电机相反,因此左右电机接法与传统Model 3小车相反

左轮电机接 R1 or R2

右轮电机接L1 or L2

IN1 —D12 //L1 L2 motor direction
IN2 —D11 //L1、L2 motor direction
IN3 —D9 //R1、R2 motor direction
IN4 —D10 //R1、R2 motor direction
ENA —D5 // Needs to be a PWM pin to be able to control motor speed ENA
ENB —D6 // Needs to be a PWM pin to be able to control motor speed ENB

Then connect the Ultrasonic module sensor to the D7D8 port of the Magic I/O shield with a 4-pin PNP cable as below:

Step 1) If you haven’t install mBlock software in your PC, please read Lesson 1, download and install the software.
Step 2) Run the mBlock PC software by double click the lovely Panda icon.   Drag and Drop osoyoo_uno_mext file(downloaded in Step 1) to mBlock software as following:

Now you will see a new device firmware in mBlock, see following picture:

Now mBlock software and OSOYOO_UNO device firmware have been successfully installed in our PC!

Now we will show you how to use blocks to turn above idea into reality.

Step 1: Click Events,   add when Arduino Uno starts up block to coding area:


Now we have completed the block programming.  The final blocks look like following:

how_to_play.png (1150×56)

Disconnect Arduino from PC,  turn on battery power.

Put the car on the ground, press the Motor Power switch on the OSOYOO Magic I/O Shield for Arduino, the dog will automatically walk. When there is an obstacle in front of the dog, the dog will automatically change direction.

If you want to use Arduino IDE to compile the program, here is the Arduino source code download link: