Ambient Orb

Made by Stephanie Ho ·

* Build your understanding of ambience through hands-on exploration * Build familiarity with adding libraries and extending functionality in your project * Build familiarity with for loops and conditional logic * Gain understanding of how to program advanced outputs and feedback for your projects

Created: November 16th, 2023

0

Outcome

    • Goals: Create an ambient calendar alert using a neopixel strip. By the end of the project, you’ll have connected your Particle device to your Google Calendar through IFTTT and display an alert using a Neopixel LED array

    0

    Reflection

    After testing different NeoPixel light settings with the number of pixels, I started with testing if the IFTT webhook worked with my particle board, experiencing learnings around the following:

    * 'else' functions do not require an ==

    * utilizing bool and adding that variable above the setup and loop function

    * setting a distinct Pixel color - RGB - when the IFTT is not called as an 'on/off' distinction

    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 is the class, or library that is called, for the variable ‘strip’ (similar to int, bool)
    Adafruit_NeoPixel strip = Adafruit_NeoPixel (PIXEL_COUNT, PIXEL_PIN, PIXEL_TYPE);
    
    bool eventLightUp=false; 
    
    void setup() {
        strip.begin ();
        strip.show();  
        
        Particle.function("eventLightUp",handleHandleLightUp);
    }
    
    void loop() {
        if (eventLightUp==true){
            for (int k=0; k<256; k++){
                for (int i=0; i<strip.numPixels(); i++){
                    strip.setPixelColor(i, k/2,k,k);
                
                    strip.show();
                    delay(100);
                    }
             }
        
            for (int k=256; k>=0; k--){
                for (int i=0; i<strip.numPixels(); i++){
                    strip.setPixelColor(i, k/2,k,k);
                
                    strip.show();
                    delay(10);
                    }
            }
        
        delay(100);
        
        }
        else{
            for(int i=0;i<strip.numPixels();i++){
                strip.setPixelColor(i,250,0,0);
            
            strip.show();
            delay(10);
            }
        }
    }
    
    int handleHandleLightUp (String cmd){
       
        eventLightUp=true;
        
        return -1;
    }
    Click to Expand
    0
    0

    I then utilized the 'millis' function to delay the timing. Since I was experiencing difficulties with IFTT, I opted to set the 'reverse' of the TimerStarted, checking if timerStarted =false and calling the fade if timerStarted==true to test the fade. 

    If this were functioning with IFTT, the code would fade to red once the webhook is called, and then fade to blue. If the function was not running, it would set to grey. This way, I could tell if it was on or running.

    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 is the class, or library that is called, for the variable ‘strip’ (similar to int, bool)
    Adafruit_NeoPixel strip = Adafruit_NeoPixel (PIXEL_COUNT, PIXEL_PIN, PIXEL_TYPE);
    
    int durationFade = 1000*60*15;
    long timeStart = -1; //when the action starts
    bool timerStarted = false; //whether the timer for fading has started or not
    
    void setup() {
        strip.begin ();
        strip.show();  
        
        //Particle.function("eventLightUp",handleHandleLightUp);
        Particle.function("fadeUp", handleFadeUp);
    }
    
    void loop() {
        if (timerStarted==true){
            
            long timeNow = millis();
            long timeElapsed = timeNow - timeStart;
            
            if(timeElapsed < durationFade){
                int colorValue = map(timeElapsed, 0, durationFade, 0, 255); //scales timeElapsed from the range 0 to durationFade, to  0 to 255
                
                int r=colorValue;
                int g=0;
                int b=0;
                
                for(int i=0; i<strip.numPixels();i++){
                    strip.setPixelColor(i,r,g,b);
                    
                }
                strip.show();
            }else{
                timerStarted = false;
                 for(int k=256; k>=0; k--){
                     for(int i=0;i<strip.numPixels();i++){
                        strip.setPixelColor(i,0,0,250);
                        strip.show();
            
                   delay(10);
                    }
                 }
            }
        }
    
        else{
            for(int i=0;i<strip.numPixels();i++){
                strip.setPixelColor(i,10,10,10);
            
            strip.show();
            delay(10);
            }
        }
    }
    
        
    int handleFadeUp(String cmd){
        
        timeStart = millis(); //storing the value at which the particlefunction was triggered
        timerStarted =true;
        return 1;
    }
    Click to Expand
    x
    Share this Project

    This project is only accessible by signed in users. Be considerate and think twice before sharing.


    Courses

    48-675 Designing for the Internet of Things

    · 11 members

    A hands-on introductory course exploring the Internet of Things and connected product experiences.


    About

    * Build your understanding of ambience through hands-on exploration
    * Build familiarity with adding libraries and extending functionality in your project
    * Build familiarity with for loops and conditional logic
    * Gain understanding of how to program advanced outputs and feedback for your projects