感測器模組簡介
電路圖
Pycode程式列表
Blockly
Python
"""
EPY Sensor
-----------------
3V3 VCC
GND
1M
AIN0 OUT
-V
GND COM
"""
from machine import Pin,ADC
from machine import Switch
import utime
from machine import RTC
adc_buf = None
adc0 = None
KeyA = None
rtc = None
adc0 = ADC(Pin.board.AIN0)
KeyA = Switch('keya')
rtc = RTC()
while True:
adc_buf = adc0.read()
print('Analog Value (0 to 4095):' + str(adc_buf))
if (KeyA.value()) == True:
break
utime.sleep_ms( 400 )
執行結果
沒有亮光
有亮光