#include "Particle.h"
#include <neopixel.h>
#define PIXEL_PIN SPI
#define PIXEL_COUNT 8
#define PIXEL_TYPE WS2812B
Adafruit_NeoPixel strip(PIXEL_COUNT, PIXEL_PIN, PIXEL_TYPE);
unsigned long lastFade = 0;
int Interval = 9000;
int brightness = 0;
bool com = true;
void setup() {
strip.begin();
strip.show();
Particle.function("LightUp", handleHandleLightUp);
}
int handleHandleLightUp(String command) {
unsigned long now = millis();
uint16_t i;
uint32_t c = strip.Color(255, 255, 255);
if ((now - lastFade) >= Interval) {
for (int color = 255; color > 0; color--) {
for (uint16_t i = 0; i < strip.numPixels(); i++) {
uint32_t c = strip.Color(255, color, color);
strip.setPixelColor(i, c);
}
strip.show();
delay(20);
}
lastFade = now;
}
for (int color = 0; color <= 255; color++) {
for (uint16_t i = 0; i < strip.numPixels(); i++) {
uint32_t c = strip.Color(255, color, color);
strip.setPixelColor(i, c);
}
strip.show();
delay(20);
}
lastFade = now;
return 1;
}
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. .