X
Home > Blog > STEM for Arduino > HOW to Build a Smart Trash Can (Drop Alarm) with Kidspico

HOW to Build a Smart Trash Can (Drop Alarm) with Kidspico

By r October 9th, 2024 43 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 4.6Smart bin_Drop alarm.py and click 1407.

'''
 * Filename    : Smart bin_Drop alarm
 * Thonny      : Thonny 4.1.4
 * Auther      : http//www.keyestudio.com
'''
from machine import Pin
from SC7A20 import sc7a20
import time

Buzzer = Pin(2,Pin.OUT)
scl = Pin(5) 
sda = Pin(4)
bus = 0
Triaxial = sc7a20(bus, scl, sda)
while True:
    tumble_count = Triaxial.tumble_handle()
    if tumble_count >= 3:  #Overturn the trash can.
        Buzzer.on()        #The buzzer alarms.
    else:                  #Place trash can flatwise.
        Buzzer.off()       #The buzzer stops emitting sounds.
    time.sleep(0.01)

Explanation

5top

Conceive:

  1. Initialization: set the pins of IIC and the active buzzer.

  2. Loop:

    Determine whether the trash can is in a horizontal position.

    • If no, the buzzer alarms.

    • If yes, the buzzer stays quiet.

5bottom

Test Result
4top
Place the trash can flatwise.
Upload code and tilt the trash can, the buzzer will alarm.
4603
Straighten it, and the buzzer stops alarming.
4604
4bottom
HOW to Build a Smart Trash Can (Automatic Mode) with Kidspico
Previous
HOW to Build a Smart Trash Can (Automatic Mode) with Kidspico
Read More
Comprehension! HOW to Monitor Smart Home Environment with ESP32
Next
Comprehension! HOW to Monitor Smart Home Environment with ESP32
Read More
Message Us