Created
October 8, 2018 03:39
-
-
Save shikarunochi/c827180dfc9d89230926fce0200ded61 to your computer and use it in GitHub Desktop.
M5Stack Photocell Receiver
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from m5stack import lcd | |
import utime | |
import machine | |
lcd.clear() | |
lcd.setCursor(0, 0) | |
lcd.setColor(lcd.WHITE) | |
pin = machine.ADC(machine.Pin(35, machine.Pin.IN)) | |
pin.atten(machine.ADC.ATTN_11DB) | |
#スピーカー音を消す | |
#http://t-yosh.hatenablog.com/entry/2017/12/28/235947 | |
dac = machine.DAC(machine.Pin(25)) | |
dac.write(0) | |
lcd.font(lcd.FONT_Comic) | |
lcd.clear() | |
lcd.setCursor(0, 0) | |
while True: | |
value = pin.read() | |
if value > 600: | |
lcd.print("1") | |
else: | |
lcd.print("0") | |
print(str(value) + "\n") | |
#1秒待ち | |
utime.sleep(1) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment