当前位置:网站首页>智能垃圾桶(九)——震动传感器(树莓派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 代码效果展示
边栏推荐
- 百度网盘网页版加速播放(有可用的网站吗)
- 国内市场上的BI软件,到底有啥区别
- Website vulnerability repair service provider's analysis of unauthorized vulnerability
- Applicable Scenarios of Multi-Master Replication (1) - Multi-IDC
- MySQL多表联合查询
- Qt实战案例(54)——利用QPixmap设计图片透明度
- 2020 WeChat applet decompilation tutorial (can applet decompile source code be used)
- The normal form of the database (first normal form, second normal form, third normal form, BCNF normal form) "recommended collection"
- Replication Latency Case (1) - Eventual Consistency
- 基于ABP实现DDD
猜你喜欢
苹果官网样式调整 结账时产品图片“巨大化”
上传图片-微信小程序(那些年的坑记录2022.4)
Grafana安装后web打开报错
Foreign media right, apple on May be true in inventory
6-22漏洞利用-postgresql数据库密码破解
Use of radiobutton
Dialogue with Zhuang Biaowei: The first lesson of open source
11 pinia use
tooltips使用教程(鼠标悬停时显示提示)
"Autumn Recruitment Series" MySQL Interview Core 25 Questions (with answers)
随机推荐
Why don't you make a confession during the graduation season?
i.MX6ULL driver development | 33 - NXP original network device driver reading (LAN8720 PHY)
Doing things software development - the importance of law and understanding of reasonable conclusions
【7.29】代码源 - 【排列】【石子游戏 II】【Cow and Snacks】【最小生成数】【数列】
After Grafana is installed, the web opens and reports an error
How Redis handles concurrent access
The normal form of the database (first normal form, second normal form, third normal form, BCNF normal form) "recommended collection"
Emmet syntax
多主复制的适用场景(1)-多IDC
org.apache.jasperException(could not initialize class org)
jeecg master-slave database read-write separation configuration "recommended collection"
Premiere Pro 2022 for (pr 2022)v22.5.0
OPPO在FaaS领域的探索与思考
LevelSequence源码分析
第二届中国PWA开发者日
tensorflow2.0 cnn(layerwise)
动态规划之线性dp(上)
update data table update
tensorflow2.0 cnn(layerwise)
ML.NET related resources