// This #include statement was automatically added by the Particle IDE.
#include <neopixel.h>
// IMPORTANT: Set pixel COUNT, PIN and TYPE
#define PIXEL_PIN D2
#define PIXEL_COUNT 16
#define PIXEL_TYPE WS2812
Adafruit_NeoPixel strip = Adafruit_NeoPixel(PIXEL_COUNT, PIXEL_PIN, PIXEL_TYPE);
int setRed(String str) {
int level = str.toInt();
for(int i=0; i< strip.numPixels(); i++) {
strip.setPixelColor(i, strip.Color(level, 0, 0));
strip.show();
}
return 1;
}
int setGreen(String str) {
int level = str.toInt();
for(int i=0; i< strip.numPixels(); i++) {
strip.setPixelColor(i, strip.Color(0, level, 0));
strip.show();
}
return 1;
}
int setBlue(String str) {
int level = str.toInt();
for(int i=0; i< strip.numPixels(); i++) {
strip.setPixelColor(i, strip.Color(0, 0, level));
strip.show();
}
return 1;
}
void setup() {
strip.begin();
strip.show();
Particle.function("setRed", setRed);
Particle.function("setGreen", setGreen);
Particle.function("setBlue", setBlue);
}
void loop() {
}
Click to Expand
Content Rating
Is this a good/useful/informative piece of content to include in the project? Have your say!
You must login before you can post a comment. .