当前位置:网站首页>智能垃圾桶(九)——震动传感器(树莓派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 代码效果展示

边栏推荐
- 多主复制的适用场景(1)-多IDC
- Insert into data table to insert data
- jeecg master-slave database read-write separation configuration "recommended collection"
- ML.NET相关资源整理
- 6-22漏洞利用-postgresql数据库密码破解
- tensorflow2.0 cnn(layerwise)
- t-sne 数据可视化网络中的部分参数+
- Browser's built-in color picker
- 多主复制的适用场景(2)-需离线操作的客户端和协作编辑
- Qt实战案例(54)——利用QPixmap设计图片透明度
猜你喜欢

6-22漏洞利用-postgresql数据库密码破解

6-22 Vulnerability exploit - postgresql database password cracking

What is the difference between BI software in the domestic market?

BGP综合实验(建立对等体、路由反射器、联邦、路由宣告及聚合)

js的toString方法

2022年必读的12本机器学习书籍推荐

【C语言】LeetCode27.移除元素

C程序是如何跑起来的01 —— 普通可执行文件的构成

How to switch remote server in gerrit

.NET 20th Anniversary Interview - Zhang Shanyou: How .NET technology empowers and changes the world
随机推荐
Handling write conflicts under multi-master replication (4) - multi-master replication topology
BGP综合实验(建立对等体、路由反射器、联邦、路由宣告及聚合)
Graham's Scan method for solving convex hull problems
The new BMW 3 Series is on the market, with safety and comfort
i.MX6ULL driver development | 33 - NXP original network device driver reading (LAN8720 PHY)
TypeError: unhashable type: ‘list‘
百度网盘网页版加速播放(有可用的网站吗)
Deployment application life cycle and Pod health check
[TypeScript] In-depth study of TypeScript type operations
tensorflow2.0 cnn(layerwise)
ML.NET related resources
复制延迟案例(3)-单调读
Applicable scenario of multi-master replication (2) - client and collaborative editing that require offline operation
How Redis handles concurrent access
MySQL多表联合查询
Website vulnerability repair service provider's analysis of unauthorized vulnerability
2.索引及调优篇【mysql高级】
Premiere Pro 2022 for (pr 2022)v22.5.0
Emmet syntax
After the form is submitted, the page does not jump [easy to understand]