// This #include statement was automatically added by the Particle IDE.
#include <neopixel.h>
#define PIXEL_PIN D2
#define PIXEL_COUNT 8
#define PIXEL_TYPE WS2812
Adafruit_NeoPixel strip = Adafruit_NeoPixel(PIXEL_COUNT, PIXEL_PIN, PIXEL_TYPE);
int turnRed(String command) {
return 1;
}
void setup() {
strip.begin();
strip.show(); //Initialize all pixels to "off"
Particle.function("alert",turnRed);
}
void loop() {
// Exercise 2
uint16_t i;
uint32_t cBlue = strip.Color(0, 0, 255);
uint32_t cRed = strip.Color(255, 0, 0);
uint32_t cGreen = strip.Color(0, 255, 0);
uint32_t cWhite = strip.Color(255, 255, 255);
uint32_t cPeach = strip.Color(200, 50, 0);
uint32_t cCyan = strip.Color(10, 150, 70);
uint32_t cPurple = strip.Color(180, 3, 180);
uint32_t cOff = strip.Color(0,0,0);
for(i=0; i<strip.numPixels(); i++) {
strip.setPixelColor(i, cBlue);
strip.show();
delay(100);
}
for(i=0; i<strip.numPixels(); i++) {
strip.setPixelColor(i, cRed);
strip.show();
delay(100);
}
for(i=0; i<strip.numPixels(); i++) {
strip.setPixelColor(i, cGreen);
strip.show();
delay(100);
}
for(i=0; i<strip.numPixels(); i++) {
strip.setPixelColor(i, cWhite);
strip.show();
delay(100);
}
for(i=0; i<strip.numPixels(); i++) {
strip.setPixelColor(i, cPeach);
strip.show();
delay(100);
}
for(i=0; i<strip.numPixels(); i++) {
strip.setPixelColor(i, cCyan);
strip.show();
delay(100);
}
for(i=0; i<strip.numPixels(); i++) {
strip.setPixelColor(i, cPurple);
strip.show();
delay(100);
}
}
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. .