import time from machine import Pin import neopixel import json class Led: pin = Pin(13) # Pico GPIO13 (number 17) count = 39 # Number of LEDs on the strip state = {"command": "state", "state": 0, "r": 0, "g": 0, "b": 0, "brightness": 0} initialState = state strip = neopixel.NeoPixel(pin, count) def on(self, R: int, G: int, B: int, brightness: int = 100): strip = self.strip for i in range(self.count): strip[i] = (round(R * brightness / 100), round(G * brightness / 100), round(B * brightness / 100)) strip.write() time.sleep(0.02) self.state = {"command": "state", "state": 1, "r": R, "g": G, "b": B, "brightness": brightness} def off(self): strip = self.strip for i in range(39): strip[i] = (0, 0, 0) strip.write() strip = self.initialState def status(self): return json.dumps(self.state)