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 4.6Smart bin_Drop alarm.py and click .
'''
* 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)
Conceive:
Initialization: set the pins of IIC and the active buzzer.
Loop:
Determine whether the trash can is in a horizontal position.
If no, the buzzer alarms.
If yes, the buzzer stays quiet.