add in the led light code
This commit is contained in:
parent
82ff492417
commit
8671363ee4
@ -1,4 +1,5 @@
|
||||
import time
|
||||
from machine import Pin
|
||||
from umqtt.simple import MQTTClient
|
||||
|
||||
|
||||
@ -6,9 +7,20 @@ import network
|
||||
import time
|
||||
from math import sin
|
||||
|
||||
led = Pin("LED", Pin.OUT)
|
||||
led.value(1)
|
||||
|
||||
button = Pin(14, Pin.IN, Pin.PULL_UP)
|
||||
|
||||
# Received messages from subscriptions will be delivered to this callback
|
||||
def sub_cb(topic, msg):
|
||||
print((topic, msg))
|
||||
if msg == b'on':
|
||||
print("turn LED on")
|
||||
led.value(1)
|
||||
elif msg == b'off':
|
||||
print("turn LED off")
|
||||
led.value(0)
|
||||
|
||||
|
||||
def main(server="192.168.1.59"):
|
||||
|
Loading…
Reference in New Issue
Block a user