The OSOYOO building bricks is mechanically compatible with leading building bricks. In this lesson, we will use OSOYOO Bricks to build an Oscillating Pedestal Fan.
Firstly, please plug Osoyoo Magic I/O shield into UNO board as following：
Secondly, Connect wires as per following picture:
Motor Fan to L1
Button to D2 port
Servo to D9 port
IN1 to D12
IN2 to D11
ENA to D5
Finally, use the USB cable to connect your PC to the OSOYOO UNO board
Step 1) Download mBlock PChttps://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 Oscillating Pedestal Fan into reality.
Step 1: Click Control, then Drag and drop Forever block to programming area as following:
Step 2: Click Events, add when Arduino Uno starts up block to the top:
Step 3: Click Control , drag if else block to forever loop,
Step 4: Click Sensor, Add Button Pressed block to if condition area, change Pin number to 2:
Step 5) Click Action , then drag Move Left Right Speed block, set Servo Pin block, and Stop Moving block as following:
Step 6: Click Control , then add 6 pcs wait block under each set servo pin block, change wait time to 0.2 seconds
Now all the programming block have been completed! From above picture, the logic is pretty straightforward:
When Arduino is started, computer will enter a dead loop which will check the button status, when button is pressed, the Fan will rotate at speed 150, at the same time servo will oscillate from 60 degree position to 140 degree position. Each location will stop 0.2 seconds.
When you release the button, the servo and fan will stop after a short time.
1)you need connect your Arduino 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 Arduino port from device drop-down menu
4) click Connect button to connect your PC to Arduino
5)After you PC is connected to Arduino UNO board, please click Upload button in the bottom of your software, then the code will be uploaded to Arduino UNO board:
Now turn on the power switch in the Magic board, the Arduino 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.
DownLoad Url osoyoo.com