From 8671363ee437ae07c82bc70ca974584d5406a43b Mon Sep 17 00:00:00 2001 From: OddlyTimbot Date: Wed, 7 Aug 2024 20:18:07 -0400 Subject: [PATCH] add in the led light code --- rp2040_client/main.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/rp2040_client/main.py b/rp2040_client/main.py index 77014da..79e39d2 100644 --- a/rp2040_client/main.py +++ b/rp2040_client/main.py @@ -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"):