Created
December 8, 2020 19:52
-
-
Save cmsunu28/6f320649dca11dd2dda0995e0cd42d0f to your computer and use it in GitHub Desktop.
imp001 impExplorer device code: control an LED from the internet
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// turn the LED a color | |
#require "WS2812.class.nut:3.0.0" | |
local spi = hardware.spi257; | |
spi.configure(MSB_FIRST,7500); | |
hardware.pin1.configure(DIGITAL_OUT,1); | |
local led = WS2812(spi,1); | |
function setRGB(colorcode) { | |
local rgb = split(colorcode,","); | |
led.set(0,[rgb[0].tointeger(),rgb[1].tointeger(),rgb[2].tointeger()]); | |
led.draw(); | |
} | |
agent.on("set.led",setRGB); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment