Required:
The block appearance is similar to that in chapter 4.4 and 4.5. If you’ve already built one of them, you don’t have to dismantle it all and reassemble it, just follow these steps.
The blocks in 4.4:
① Remove the servo and the lid
② Assemble from step 4
The blocks in 4.5
① Remove the servo and the lid
② Assemble from step 5
Yet if you have not assemble the building blocks, please start from step 1.
Step 1
Step 2
Step 3
Step 4
Step 5
Step 6
Step 7
Completed!
Open KidsBlock and connect to the board, click File –> Load from your computer.
Choose D:\Code\2.Code_kidsIOT to open 4.6Smart bin_Drop alarm.sb3
Click to connect to port and then .
Code Blocks
Blocks |
Code block |
---|---|
Build blocks:
Initialization
Set pin mode and initialize the serial port.
Main Code
Loop: determine whether there is a fall, and print the result on serial monitor.
is a fall detection code block. When the SC7A20 acceleration sensor is detected in a non-horizontal position (fall), the output value is 1; When the sensor is detected in a horizontal position (none falling), the output value is 0.