虚谷号

 找回密码
 立即注册
搜索
热搜: 活动 交友
查看: 357|回复: 0

当Yeelight遇上虚谷号#07 人体红外感应灯

[复制链接]

16

主题

40

帖子

161

积分

注册会员

Rank: 2

积分
161
发表于 2019-3-20 09:14:57 | 显示全部楼层 |阅读模式
人体红外释电传感器同样是返回高低电平
当检测到有人走过时亮起60秒

源代码

#从xugu库中导入Pin类
from xugu import Pin
from yeelight import Bulb
import time
#xugu库中的创建Pin对象
pin = Pin(5,Pin.IN)
bulb = Bulb("192.168.31.39")

while 1:
        value = pin.read_digital()
#如果电平为1
        if value:
                bulb.turn_on()
                time.sleep(60)
#通过返回值确认程序的运行状况
                print(1)
        else:
                bulb.turn_off()
                time.sleep(1)
#通过返回值确认程序的运行状况
                print(0)


针脚连接方式与按钮相同

回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

虚谷号

GMT+8, 2024-4-19 07:46 , Processed in 0.056651 second(s), 18 queries .

Powered by Discuz! X3.4

© 2001-2017 Comsenz Inc.

快速回复 返回顶部 返回列表