Skip to content

Instantly share code, notes, and snippets.

@cmsunu28
Created December 8, 2020 19:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cmsunu28/6f320649dca11dd2dda0995e0cd42d0f to your computer and use it in GitHub Desktop.
Save cmsunu28/6f320649dca11dd2dda0995e0cd42d0f to your computer and use it in GitHub Desktop.
imp001 impExplorer device code: control an LED from the internet
// 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