Skip to content

Instantly share code, notes, and snippets.

@cwyark
Created June 12, 2017 07:20
Show Gist options
  • Save cwyark/4bfc8ff7e95b4606e3f4c11a0fc75c17 to your computer and use it in GitHub Desktop.
Save cwyark/4bfc8ff7e95b4606e3f4c11a0fc75c17 to your computer and use it in GitHub Desktop.
from umachine import Pin, UART, WDT
import utime, ameba
relay_ctrl_pin = Pin("PD_4", mode=Pin.OUT)
uart = UART(0, rx="PA_6", tx="PA_7")
uart.init()
wdt = WDT()
utime.sleep(3)
print("start ")
while True:
while True:
chr = uart.read(1)
print("get")
print(chr)
if chr == b'1':
ameba.mem16[0x40040008] = 0b111
relay_ctrl_pin.value(1)
utime.sleep(60*7)
#utime.sleep(5)
relay_ctrl_pin.value(0)
while (ameba.mem16[0x40040014] & 0b01):
n = uart.read(1)
elif chr == b'0':
relay_ctrl_pin.value(0)
else:
print("get {}".format(chr))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment