Ski dev 3

Made by ziyuh

Created: December 4th, 2021

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

void setup() {
    strip.begin();
    
    uint32_t c1 = strip.Color(0, 255, 0);
    uint32_t c2 = strip.Color(0, 0, 0);
    
     int numPixels = strip.numPixels();
    
    for( int i = 0; i < numPixels; i++ ){
        strip.setPixelColor(i, c1); // set a color 
                
        strip.show(); // set updates to the strip
        delay(300); 
    }


    for( int i = numPixels; i >= 0; i-- ) {
        strip.setPixelColor(i, c2); // remove the color

        strip.show();
                
        delay(300);
    }
}
Click to Expand
0
// 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);

void setup() {
    strip.begin();
    
    uint32_t blue = strip.Color(0, 0, 255);
    uint32_t red = strip.Color(255, 0, 0);
    uint32_t green = strip.Color(0, 255, 0);
    uint32_t white = strip.Color(255, 255, 255);
    uint32_t black = strip.Color(0, 0, 0);
    
    uint32_t colors[] = {blue, red, green, white};
    
    int numPixels = strip.numPixels();
    
    for (int j = 0; j < 4; j++) {
    
        for( int i = 0; i < numPixels; i++ ){
            strip.setPixelColor(i, colors[j]); // set a color 
                
        }
        
        strip.show(); // set updates to the strip
        delay(1200); 
        
        for( int i = numPixels; i >= 0; i-- ) {
            strip.setPixelColor(i, black); // remove the color
        }   
        strip.show();
        delay(500);
    }
    
}
Click to Expand
0
SKI dev
Ziyu Han - https://youtu.be/T4NoYT8O_RA
0
// 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);

void setup() {
    strip.begin();

}

void loop() {
    uint32_t white = strip.Color(255, 255, 255);
    uint32_t black = strip.Color(0, 0, 0);
    
    int numPixels = strip.numPixels();
    
    for( int i = 0; i < numPixels; i++ ){
        strip.setPixelColor(i, white); // set a color 
        
        strip.show();
        delay(500);
        
        strip.setPixelColor(i, black); // remove the color
        strip.show();
        delay(500);
    }
}
Click to Expand
0
// This #include statement was automatically added by the Particle IDE.
#include <neopixel.h>

//Set pixel COUNT, PIN, and TYPE 
#define PIXEL_COUNT 16
#define PIXEL_PIN D4
#define PIXEL_TYPE WS2812

Adafruit_NeoPixel strip = Adafruit_NeoPixel(PIXEL_COUNT, PIXEL_PIN, PIXEL_TYPE);


int red = 25;        //to track the value of Red color
int green = 25;        //to track the value of Green color
int blue = 25;        //to track the value of Blue color

bool calAlert_Status = false;       //to check if the calender alert occured
unsigned long lastUpdate;       //to check track the time usin millis()
unsigned long now =0;           //to check track the time usin millis()

void setup() {

    strip.begin();
    strip.show();   //Initialize all pixels to 'off'
    
    //Particle function on cloud
    Particle.function("Cal_Alert", setCalAlert);
    
    //Switch on each pixel all at once with cool white color
    for(int i=0; i<strip.numPixels(); i++){
        strip.setPixelColor( i, red, green, blue);
    }
    strip.show();

}

void loop() {
    
    
    if (calAlert_Status == true){
        //Fade to red
        now = millis();
        if ((now - lastUpdate) <= 900000){
            
            red = map((now - lastUpdate), 0, 900000, 20, 255); 
            green = map((now - lastUpdate), 0, 900000, 0, 25); 
            blue = map((now - lastUpdate), 0, 900000, 0, 25); 
            if(green<0){
                green = 0;
                blue = 0;
            }
            
            if (red <= 255) {
                for(int i=0; i<strip.numPixels(); i++){
                   strip.setPixelColor( i, red, (25-green), (25-blue));
                }
                strip.show();
            }
        }
        else{
           //Reinitiailizing the calender alert variable after the meeting time reached     
           calAlert_Status = false; 
           Particle.publish("MeetingStarted-FadingtoWhite");    ////publishing meeting started notification on cloud
        }
    }
    else{
        //Back to cool white
        now = millis();
        if (((now - lastUpdate) >= 900000) && ((now - lastUpdate) <= 1800000)){
            
            red = map((now - lastUpdate), 900000, 1800000, 0, 230); 
            green = map((now - lastUpdate), 900000, 1800000, 0, 25); 
            blue = map((now - lastUpdate), 900000, 1800000, 0, 25); 
            
            if (red > 25){
                for(int i=0; i<strip.numPixels(); i++){
                   strip.setPixelColor( i, (255-red), green, blue);
                }
                strip.show();
            }
        }
        
    }
}


//Function to get calender alert from IFTTT throgh cloud
int setCalAlert(String command){
    
    if(command == "True") {
        calAlert_Status = true;
        lastUpdate = millis();
        Particle.publish("CalenderAlert-FadingtoRed");      //publishing alert recieved notification on cloud
        return 1;
    }
    return -1;
}
Click to Expand
x