haas506 2.0开发教程-example-bodyDetect
- 1.模块介绍
- 2.人体存在检测
1.模块介绍
该模块可以用来检测人体存在/移动目标感应。
PIN | 功能 | 备注 |
VCC | 供电 | 2.7-4.8V |
GND | 接地 | - |
OUT | 信号输出 | 输出高低电平(0/2.2V) |
P2 | GPIO2 | 接收增益档位选择(悬空/拉低选择) |
P3 | GPIO3 | 延时时间档为选择(悬空/拉低) |
- 硬件接线
2.人体存在检测
- 案例说明
使用该模块实现人体检测,当检测到有人活动时,会播报语音,同时会点亮led灯,当没有人活动时,熄灭小灯。当前音频文件被放在工程文件中,也可以放在SD卡中。 - main.py
from driver import GPIO
import utime as time
import audio
led=GPIO()
led.open("led1")
radar=GPIO()
radar.open('radar')
aud=audio.Audio()
aud.set_pa()
aud.setVolume(5)
while True:
#当检测到人体活动,相应的引脚会输出高电平
if radar.read()==1:
print("detect body")
aud.play('/data/pyamp/detect_body.mp3')
led.write(1)
else:
print("no body")
led.write(0)
time.sleep(1)
- board.json
{
"name": "haas506",
"version": "2.0.0",
"io": {
"ADC0": {
"type": "ADC",
"port": 0,
"sampling": 12000000
},
"ADC1": {
"type": "ADC",
"port": 1,
"sampling": 12000000
},
"ADC2": {
"type": "ADC",
"port": 2,
"sampling": 12000000
},
"qma8981": {
"type": "I2C",
"port": 1,
"addrWidth": 7,
"freq": 400000,
"mode": "master",
"devAddr": 18
},
"KEY1": {
"type": "GPIO",
"port": 44,
"dir": "irq",
"pull": "pullup",
"intMode": "rising"
},
"led1": {
"type": "GPIO",
"port": 7,
"dir": "output",
"pull": "pulldown"
},
"led_g": {
"type": "GPIO",
"port": 32,
"dir": "output",
"pull": "pulldown"
},
"cs": {
"type": "GPIO",
"port": 15,
"dir": "output",
"pull": "pullup"
},
"radar":{
"type":"GPIO",
"port": 31,
"dir": "input",
"pull":"pullup"
},
"SPI0": {
"type": "SPI",
"port": 0,
"mode": "master",
"freq": 2000000
},
"serial1": {
"type": "UART",
"port": 0,
"dataWidth": 8,
"baudRate": 115200,
"stopBits": 1,
"flowControl": "disable",
"parity": "none",
"timeout": 1000
},
"serial2": {
"type": "UART",
"port": 1,
"dataWidth": 8,
"baudRate": 9600,
"stopBits": 1,
"flowControl": "disable",
"parity": "none",
"timeout": 1000
},
"serial3": {
"type": "UART",
"port": 2,
"dataWidth": 8,
"baudRate": 115200,
"stopBits": 1,
"flowControl": "disable",
"parity": "none",
"timeout": 1000
}
},
"debugLevel": "ERROR",
"repl": "enable",
"replPort": 0
}