Skip to content

Instantly share code, notes, and snippets.

@SwitchScienceCode
Last active June 7, 2017 00:59
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 SwitchScienceCode/1a6d4590f438e141655d67a0eed1bc77 to your computer and use it in GitHub Desktop.
Save SwitchScienceCode/1a6d4590f438e141655d67a0eed1bc77 to your computer and use it in GitHub Desktop.
Electric Imp Explorer Kit Sample Code: Hello World
// Import Electric Imp’s WS2812 library
#require "WS2812.class.nut:3.0.0"
// Set up global variables
spi <- null;
led <- null;
state <- false;
// Define the loop flash function
function flash() {
state = !state;
local color = state ? [0,0,255] : [0,0,0];
led.set(0, color).draw();
imp.wakeup(1.0, flash);
}
// Set up the SPI bus the RGB LED connects to
spi = hardware.spiAHSR;
spi.configure(MSB_FIRST, 6000);
// Set up the RGB LED
led = WS2812(spi, 1);
hardware.pinH.configure(DIGITAL_OUT, 1);
// Start the flash loop
flash();
@SwitchScienceCode
Copy link
Author

2017/6/7 10:00 update

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment