当前位置:网站首页>智能垃圾桶(九)——震动传感器(树莓派pico实现)
智能垃圾桶(九)——震动传感器(树莓派pico实现)
2022-07-31 16:13:00 【光追雨】
一、模块展示


二、模块说明
此传感器有3个引脚,其中VCC需要接3.3-5V的电压,中间引脚接地,DO引脚是信号输出引脚,我们通过其进行倾斜感应。如上图所示,此传感器自带电源和开关两个LED灯,接通电源后,电源LED灯发光,当传感器触发倾斜时,开关LED灯发光。对于DO引脚,当开关LED发光时,其输出低电平,表示开关打开,当开关LED灯不亮时,其输出高电平,表示开关断开。用其我们可以很方便的实现倾斜断电保护功能。如上图中,此传感器还提供了一个灵敏度的电位调节单元,其工作原理电路图如下所示:
2.1 使用说明
1、产品不震动时,震动开关呈闭合导通状态,输出端输出低电平,绿色指示灯亮;
2、产品震动时,震动开关瞬间断开,输出端输出高电平,绿色指示灯不亮;
三、代码展示
由于震动传感器板载的LED的闪烁太快,以至于肉眼无法识别,所以本部分调用pico上自带的LED进行延迟显示,使得效果更明显,但是延时时间过长,会导致震动传感器的灵敏度下降,所以本次测试采用50ms延时
from machine import Pin
import utime
key = Pin(0, Pin.IN)
led_onboard = Pin(25, Pin.OUT)
while True:
while key.value() == 0:
print("没有震动")
led_onboard.value(0)
utime.sleep(0.05)
while key.value() == 1:
print("感应到震动")
led_onboard.value(1)
utime.sleep(0.05)
四、效果展示
4.1 实物展示
emmm……灵敏确实太差了,但是延时再下调,pico上LED就不能看,将就点看吧,反正用的时候,不会加延时了,这里只是为了实验现象更加明显而加上延时的

4.2 代码效果展示

边栏推荐
- TypeError: unhashable type: ‘list‘
- How Redis handles concurrent access
- mysql black window ~ build database and build table
- ASP.NET Core generates continuous Guid
- BGP综合实验(建立对等体、路由反射器、联邦、路由宣告及聚合)
- After the form is submitted, the page does not jump [easy to understand]
- 入职一个月反思
- Single-cell sequencing workflow (single-cell RNA sequencing)
- MySQL multi-table union query
- ansible学习笔记02
猜你喜欢
随机推荐
MySQL数据库操作
贪吃蛇项目(简单)
【TypeScript】深入学习TypeScript类型操作
Replication Latency Case (1) - Eventual Consistency
mongo enters error
The new BMW 3 Series is on the market, with safety and comfort
what exactly is json (c# json)
MySQL的相关问题
LevelSequence源码分析
Website vulnerability repair service provider's analysis of unauthorized vulnerability
SHELL内外置命令
The normal form of the database (first normal form, second normal form, third normal form, BCNF normal form) "recommended collection"
Applicable Scenarios of Multi-Master Replication (1) - Multi-IDC
Premiere Pro 2022 for (pr 2022)v22.5.0
Character pointer assignment [easy to understand]
复制延迟案例(3)-单调读
6-22漏洞利用-postgresql数据库密码破解
Insert into data table to insert data
6-22 Vulnerability exploit - postgresql database password cracking
MySQL常用语句整理









