// This #include statement was automatically added by the Particle IDE.
#include <neopixel.h>
// This #include statement was automatically added by the Particle IDE.
#include <neopixel.h>
// IMPORTANT: Set pixel COUNT, PIN and TYPE
#define PIXEL_PIN D3
#define PIXEL_COUNT 16
#define PIXEL_TYPE WS2812
Adafruit_NeoPixel strip = Adafruit_NeoPixel(PIXEL_COUNT, PIXEL_PIN, PIXEL_TYPE);
void setup() {
strip.begin();
strip.show(); // Initialize all pixels to 'off'
Particle.function("alarm_15", alarm_15);
uint32_t w = strip.Color(10, 10, 10); // White
for( int i = 0; i < strip.numPixels(); i++ ){
strip.setPixelColor(i, w);
}
strip.show();
}
void loop() {}
int alarm_15(String command)
{
// int R = R1.toInt();
int W = 0;
int n = 0;
int m = 0;
// unsigned long now = 0;
// Particle.publish( "new-event", String(now) );
unsigned long stamp = millis();
for(unsigned long now = 0; now <= 99999999999999999999;)
{
now = millis();
if (now - stamp <= 60000)
{
uint32_t w = strip.Color(W, W, W); // Red
for( int i = 0; i < strip.numPixels(); i++ )
{
strip.setPixelColor(i, w); // set a color
}
strip.show();
W = W + 255/60;
delay(1000);
} else if (now - stamp <= 90000)
{
uint32_t r = strip.Color(255, 255 - n,255 - n);
// uint32_t w = strip.Color(W,W-n,W-n);
for( int i = 0; i < strip.numPixels(); i++ )
{
strip.setPixelColor(i, r);
}
strip.show();
n = n + 255/30;
delay(1000);
}
else if (now - stamp <= 120000)
{
uint32_t o = strip.Color(255 - m, 0,0);
// uint32_t w = strip.Color(W,W-n,W-n);
for( int i = 0; i < strip.numPixels(); i++ )
{
strip.setPixelColor(i, o);
}
strip.show();
m = m + 255/30;
delay(1000);
}
else
{
uint32_t o = strip.Color(0, 0,0);
// uint32_t w = strip.Color(W,W-n,W-n);
for( int i = 0; i < strip.numPixels(); i++ )
{
strip.setPixelColor(i, o);
}
strip.show();
return now - stamp;
}
// return now - stamp;
}
return millis();
}
Click to Expand