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

The OSOYOO building bricks  is mechanically compatible with leading building bricks. In this lesson, we will use OSOYOO Bricks to build a robot crab which can use its eyes (Ultrasonic Sensor) to detect objects and use pincers (finger servo) to catch object.


Please prepare the following parts to complete this project


Note: ALL OSOYOO Products for Arduino are Third Party Board which is fully compatible with Arduino

Before you build an elevator with blocks, please according to the Preparation before class 2: https://osoyoo.com/2021/12/01/preparation-before-class-2

Note:the color of the building block is subject to the actual product, which does not affect the use.

Please follow the PDF instruction to building blocks: https://osoyoo.com/picture/Block_kit/lesson6/lesson6.pdf

Or follow this video to Building Blocks:

 

Connect wires as per following picture:
Motor(Red) to L1 or L2
Servo(Grey) to D9 port
IN1 to D12
IN2 to D11
ENA to D5
Ultrasonic Sensor to D7D8 port


Note: In this kit, we use mblock as programming tool, if you want to learn more about mblock, please visit preparation before class 1: https://osoyoo.com/2021/12/01/preparation-before-class-1
Step 1) Download mBlock PC from https://mblock.makeblock.com/en-us/download/, select the download file as per your computer OS type:

Step 2) Download OSOYOO_UNO.mext device file from https://osoyoo.com/driver/mblock/osoyoo_uno.mext
Step 3) Run the mBlock PC software by double click the lovely Panda icon. you will see mBlock UI as following picture. Please delete the default device CyberPi by click the cross in the red circle.

Step 4) Drag and Drop osoyoo_uno_mext file(downloaded in Step 2) 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 make our Robot Crab into reality.
Step 1: Click Events, add when Arduino Uno starts up block to programming area:

Step 2: Click Action, drag set servo pin 9 Angle as 0 block twice and change angle to 0 and 45 as following:

Step 3: Click Control, drag wait 1 seconds block twice under set servo pin 9 Angle as 0 block and change 1 to 0.5 as following :

Step 4: Click Control, then Drag and drop Forever block under wait x seconds block as following:

Step 5: Click Control, drag if-then-else block to forever loop as following:

Step 6: Click Operation, drag X < 50 block on the placeholder of the if-then-else block, and change 50 to 8 as following:

Step 7: Click Sensor, drag read ultrasonic sensor trig pin 1 echo pin 1 block on the first placeholder of the X < 8 block as following:

Step 8: Click Control, drag Wait 1 seconds block five times inside the “then” section of the if-then-else block as following:

Step 9: Click Action , then drag set Servo Pin blocks twice to between wait 1 seconds blocks and change angles to 0 and 45 as following:

Step 10: Click Action , then drag Forward Left Speed 100 Right Speed 100 block and  Backward Left Speed 100 Right Speed 100 block and change Left Speed to 0 as following:

Step 11: Click Action , then drag Stop Moving block twice under wait x seconds as following:

Step 12: Click Action , then drag Stop Moving block and set Servo Pin block inside the “else” section and change the angle to 45 as following:

Step 13: Click Control , then drag wait 1 seconds block and change time to 0.5 seconds as following:

Now all the programming blocks have been completed! From above picture, the logic is pretty straight forward:

When OSOYOO basic board  is started, the crab will close at the beginning and then open (my servo 0 degree is closed and 45 degree is opened ). Computer will enter a dead loop which will check the distance between object and ultrasonic sensor. When the ultrasonic sensor “see” the object under 8cm distance, the crab close to catch the object and the motor move the crab to right, then the crab open to throw the object away, then the motor move the crab back. If the distance is over 8cm, the crab will stay still.

Upload the program to OSOYOO basic board

1)you need connect your OSOYOO basic board to your PC with a USB cable first. Then click the Connect button in the bottom of the mBlock software, you will see a USB window pop up,
2) select Show  all connectable device check box , then a device drop-down menu will show up,
3) select your  port from device drop-down menu
4) click Connect button to  connect your PC to OSOYOO basic board.

5)After you PC is connected toOSOYOO basic board,  please click Upload button in the bottom of your software, then the code will be uploaded to OSOYOO basic board:

Now turn on the power switch in the Magic board, the OSOYOO basic board will start to work. Press the button on D2, your fan begins to rotate and servo start to oscillate. When you release the button, fan and servo will stop moving.

 

No. Picture Device Qty. Link
1 OSOYOO Basic R3 Board for Arduino 1 Click here to buy
2 OSOYOO Magic I/O Shield for Arduino 1 Click here to buy
3 OSOYOO Ultrasonic Detector Module 1 Click here to buy
4 OSOYOO IR Receiver Module 1 Click here to buy
5 OSOYOO Red button module 1 Click here to buy
6 IR remote controller 1 Click here to buy
7 9V Battery Box 1 Click here to buy
8 9V Battery 1 Click here to buy
9 Servo 1 Click here to buy
10 Motor 1 Click here to buy
11 Acrylic plate for Arduino UNO 1 Click here to buy
12 Acrylic plate for 9V battery case 1 Click here to buy
13 OSOYOO Ultrasonic Sensor Block 1 Click here to buy
14 3 pin 10cm PnP cable 1 Click here to buy
15 3 pin 20cm PnP cable 1 Click here to buy
16 4 pin 20cm PnP cable 1 Click here to buy
17 B117 4 Click here to buy
18 B115 15 Click here to buy
19 B113 10 Click here to buy
20 B111 10 Click here to buy
21 B109 10 Click here to buy
22 B107 4 Click here to buy
23 B105 12 Click here to buy
24 B103 12 Click here to buy
25 T040 6 Click here to buy
26 T024 4 Click here to buy
27 T016 4 Click here to buy
28 L024 14 Click here to buy
29 LT33 8 Click here to buy
30 L035 12 Click here to buy
31 X044 20 Click here to buy
32 F057 26 Click here to buy
33 T033 8 Click here to buy
34 PS11 40 Click here to buy
35 P021 60 Click here to buy
36 P011 160 Click here to buy
37 Z005 30 Click here to buy
38 Z010 16 Click here to buy
39 Z101 12 Click here to buy
40 Z1S1 8 Click here to buy
41 A024 8 Click here to buy
42 A013 2 Click here to buy
43 A050 12 Click here to buy
44 A05S 6 Click here to buy
45 A080 4 Click here to buy