Last active
June 7, 2017 00:59
-
-
Save SwitchScienceCode/1a6d4590f438e141655d67a0eed1bc77 to your computer and use it in GitHub Desktop.
Electric Imp Explorer Kit Sample Code: Hello World
This file contains 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
// 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(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
2017/6/7 10:00 update