Skip to content

Instantly share code, notes, and snippets.

@gelicia
Last active April 18, 2016 01:11
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 gelicia/cbd4fab1b1478c7eecf256bcf8d16546 to your computer and use it in GitHub Desktop.
Save gelicia/cbd4fab1b1478c7eecf256bcf8d16546 to your computer and use it in GitHub Desktop.
iotfuse presentation
// 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