// Final Exercise: Using calendar meeting to turn Nop
// 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 meetingFunc(String args);
unsigned long initialized = 0;
unsigned long timing = 0;
unsigned long now = 0;
void setup() {
strip.begin();
strip.show(); // Initialize all pixels to 'off'
Particle.function("Calendar Reminder", meetingFunc);
}
void loop() {
now = millis();
uint32_t c = strip.Color(0, 0, 0); // All Red
while (initialized == 1 && (now - timing) <= 900000) {
int set = map((now - timing), 0, 900000, 0, 255);
c = strip.Color(set, 0, 0);
for( int i = 0; i < strip.numPixels(); i++ ){
strip.setPixelColor(i, c); // set a color
}
strip.show();
Serial.print(set);
Serial.print(" ");
Serial.print(now);
Serial.print(" ");
Serial.println(timing);
delay(1000);
now = millis();
if ((now - timing) == 300000) {
initialized = 0;
Serial.println("Exit the while");
}
}
c = strip.Color(0, 0, 0);
for( int i = 0; i < strip.numPixels(); i++ ){
strip.setPixelColor(i, c); // set a color
}
strip.show();
delay(100);
}
int meetingFunc(String args) {
initialized = 1;
timing = millis();
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. .