3.6 haas506开发教程-example-bodyDetect

haas506开发教程-example-bodyDetect

1.模块介绍

该模块可以用来检测人体存在/移动目标感应。

PIN功能备注
VCC供电2.7-4.8V
GND接地-
OUT信号输出输出高低电平(0/2.2V)
P2GPIO2接收增益档位选择(悬空/拉低选择)
P3GPIO3延时时间档为选择(悬空/拉低)
  • 硬件接线
    在这里插入图片描述

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
  }
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值