-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathboard_wemos_RF315Mhz.py
More file actions
51 lines (43 loc) · 972 Bytes
/
board_wemos_RF315Mhz.py
File metadata and controls
51 lines (43 loc) · 972 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#####################
try:
import cmd
machine.reset()
except:
pass
#####################
from webduino import *
from machine import Pin,I2C
from utime import ticks_us, ticks_diff
from array import array
from RFBtn import RFBtn
import time,os
def beep(t=1):
beep = Pin(12,Pin.OUT)
for i in range(t):
beep.off()
time.sleep(0.05)
beep.on()
time.sleep(0.05)
# wemos
wemos = Board('RF318Mhz')
wemos.connect("KingKit_2.4G","webduino")
# btn
btn1 = "5556565a5556"
btn2 = "5566959a5556"
btn3 = "5559565a5556"
btn4 = "555aa5aa5556"
btn315_blue = "659aaaaa5959"
btn315_red = "6559a6996959"
btn315_yellow = "556a6555a959"
def runCode(msg):
beep(2)
publishTopic = "wa5499/btn"
print("start...",wemos.deviceId)
wemos.onMsg(publishTopic,runCode)
pin5 = Pin(5,Pin.IN)
beep(1)
while True:
data = RFBtn.listener(pin5,wemos.check)
if(len(data)==12):
beep(1)
wemos.mqtt.pub(publishTopic,data)