Back to Parent

// 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);

bool meetingStatus = false;
bool orbState = false;
uint32_t color;
int green = 255;
int blue = 255;
uint32_t white = strip.Color(255, 255, 255); 
uint32_t red = strip.Color(255, 0, 0); 

unsigned long startTime = 0;
unsigned long fadeDuration = 15 * 60 * 1000;

void setup() {
    
    for( int i=0; i< strip.numPixels(); i++) {
        strip.setPixelColor(i, white);
    }

  strip.begin();
  strip.show();
  
  Particle.function("meetingStart", meetingStart);
}


void loop() {

  if (meetingStatus == true) {
      
    unsigned long now = millis();
    
    while (now - startTime <= fadeDuration){
        now = millis();
        green -= (255/60);
        blue -= (255/60);
        color = strip.Color(255, green, blue);
        for( int i=0; i< strip.numPixels(); i++) {
            strip.setPixelColor(i, color);
        }
        strip.show();
        delay(1000);
    }
    orbState = true;

  }else if (meetingStatus == false && orbState == true){
    green = 0;
    blue = 0;
    
    unsigned long now = millis();
    
    while (now - startTime <= fadeDuration){
        now = millis();
        green += (255/60);
        blue += (255/60);
        color = strip.Color(255, green, blue);
        for( int i=0; i< strip.numPixels(); i++) {
            strip.setPixelColor(i, color);
        }
        strip.show();
        delay(1000);
    }
    orbState = false;
  }
}

int meetingStart(String command){
    
    startTime = millis();
    if (command == "true"){
        meetingStatus = true;
    } else if (command == "false") {
        meetingStatus = false;
    }
    return 0;
}
Click to Expand

Content Rating

Is this a good/useful/informative piece of content to include in the project? Have your say!

0