光敏
概述
内置光敏电阻,可实现光电转换。一般用于光线测量、光线控制。
技术参数
工作电压: VCC 3.3V -5V
模块尺寸:24*48mm
固定安装:2个兼容塑料积木通孔
数据类型:模拟采样值
引脚定义
引脚 |
定义 |
|---|---|
GND |
地 |
VCC |
电源 |
AO |
模拟采样值 |
NC |
空 |
示例程序
1.AO口输出模拟值,DO口输出数字值0/1。
2.DO口数字值触发阈值可通过模块正面电位器进行调节,当红色LED亮,表示触发数字输出1,反之代表数字输出0。
3.当模拟光线传感器的测量值大于500时,掌控板RGB灯亮。
from mpython import *
import math
p0 = MPythonPin(0, PinMode.ANALOG)
import time
while True:
oled.fill(0)
oled.DispChar(str('模拟光线'), 0, 0, 1)
oled.DispChar(str(str('模拟值:') + str(p0.read_analog())), 0, 16, 1)
oled.show()
if p0.read_analog() > 500:
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)