In this lesson, we will show how to assemble a simple robot car with OSOYOO Building Blocks and use mBlock to program its movement.

Notice:

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

https://osoyoo.com/driver/miniblock/basic-car/4.png

前后定义,万向轮为前方,双轮为后方

由于积木电机旋转方向与黄色电机相反,因此左右电机接法与传统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

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:

Step 2: Click Action, add 5 action blocks below when Arduino Uno starts up block as following picture:

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

how_to_play.png (1150×56)

Disconnect Arduino from PC, put a 9V battery into battery pox(make sure polar direction is correct, otherwise it can destroy your device and cause fire hazard).

Put the car on the ground, press the Motor Power switch on the OSOYOO Magic I/O Shield for Arduino, the car should go forward 1 seconds, then go backward 1 seconds, then right turn for 1 seconds, then left turn for 1 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).

If you want to use Arduino IDE to compile the program, here is the Arduino source code download link:
https://osoyoo.com/driver/miniblock/basic-car/basic-car.zip