门磁开关
概述
当有磁铁靠近时,干簧管合拢,输出高电平,否则输出低电平。
技术参数
工作电压: VCC 3.3V -5V
模块尺寸:24*48mm
固定安装:2个兼容塑料积木通孔
数据类型:触发--1 未触发--0
引脚定义
引脚 |
定义 |
|---|---|
GND |
地 |
VCC |
电源 |
DO |
数字输出 |
NC |
空 |
示例程序
用具有磁性的物体(如磁铁)靠近磁控开关,即可触发。
from mpython import *
p0 = MPythonPin(0, PinMode.IN)
import time
def boolean_P0():
return p0.read_digital() == 1
while True:
if boolean_P0():
rgb.fill((int(255), int(0), int(0)))
rgb.write()
time.sleep_ms(1)
time.sleep(1)
else:
rgb.fill( (0, 0, 0) )
rgb.write()
time.sleep_ms(1)