X
Home > Blog > STEM for Arduino > HOW to Build a Smart Trash Can (Drop Alarm) with KidsIOT
HOW to Build a Smart Trash Can (Drop Alarm) with KidsIOT
By r September 25th, 2024 52 views
In this experiment, we will add a drop alarm system to the trash can with an SC7A20TR three-axis acceleration sensor and an active buzzer.

Flow

4601

Assembly

line1

Required:

46_00

line1

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.

line1

Step 1

46_01

line1

Step 2

46_02

line1

Step 3

46_03

line1

Step 4

46_04

line1

Step 5

46_05

line1

Step 6

46_06

line1

Step 7

46_07

line1

Completed!

46_08

line1

Wiring Diagram

4602

Test Code

Open KidsBlock and connect to the board, click File –> Load from your computer.

3111

Choose D:\Code\2.Code_kidsIOT to open 4.6Smart bin_Drop alarm.sb3

4603

Click 3209 to connect to port and then 2210.

Explanation

5top

Code Blocks

Blocks

Code block

Events

begin

P

setmode

P

setout

Serial

serialbegin

Operators

=

SC7A20

tumble

Control

forever

Control

ifelse

Control

wait

line5

Build blocks:

  1. Initialization

    Set pin mode and initialize the serial port.

    4604

line3

  1. Main Code

    Loop: determine whether there is a fall, and print the result on serial monitor.

    4605

    tumble 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.

5bottom

Test Result
4top
Place the trash can flatwise.
Upload code and tilt the trash can, the buzzer will alarm.
4606
Straighten it, and the buzzer stops alarming.
4607
4bottom
HOW to Build a Smart Trash Can (Automatic Mode) with KidsIOT
Previous
HOW to Build a Smart Trash Can (Automatic Mode) with KidsIOT
Read More
HOW to Simulate Rainwater Detection with KidsIOT
Next
HOW to Simulate Rainwater Detection with KidsIOT
Read More
Message Us