Last active
April 18, 2016 01:11
-
-
Save gelicia/cbd4fab1b1478c7eecf256bcf8d16546 to your computer and use it in GitHub Desktop.
iotfuse presentation
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
// This #include statement was automatically added by the Particle IDE. | |
#include "neopixel/neopixel.h" | |
Adafruit_NeoPixel strip = Adafruit_NeoPixel(4, D3, WS2812); | |
int red = 0; | |
int green = 0; | |
int blue = 0; | |
void setup() { | |
strip.begin(); | |
Particle.function("setColor", setColor); | |
} | |
void loop() { | |
displayColor(); | |
} | |
void displayColor(){ | |
for(int i=0; i<strip.numPixels(); i++) { | |
strip.setPixelColor(i, red, green, blue); | |
} | |
strip.show(); | |
} | |
int setColor(String command){ | |
int commaIndex1 = command.indexOf(','); | |
int commaIndex2 = command.indexOf(',', commaIndex1+1); | |
red = command.substring(0, commaIndex1).toInt(); | |
green = command.substring(commaIndex1+1, commaIndex2).toInt(); | |
blue = command.substring(commaIndex2+1).toInt(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment