Kenny Harsono - Ambient Orb

Made by kharsono

Build proficiency in Neo Pixel & IFTTT

Created: November 18th, 2021

0

Outcome

    • Using Neopixel, along with its electrical connection & IDE interface, is explored in this lab.  
    • Connecting online apps and Particle IDE through IFTTT is also a major objective.
    • The setup is shown here while multiple functionality videos are detailed in the process below.
    0

    Process

    Different exercises are done to show different capabilities:

    • Ex 1. Turning Neopixel on
    • Ex 2. Turning Neopixel on & cycle through different colors
    • Ex 3. Turning Neopixel on & off one pixel at a time
    • Ex 4. Inputting RGB value the web interface
    • Final. Turning Neopixel on 15 minutes before calendar meeting starts

    0
    //EXCERCISE 1: Turning on Neopixel
    
    // 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();
        strip.show(); // Initialize all pixels to 'off'
    }
    
    void loop() {
        uint16_t i;
        uint32_t c = strip.Color(255,255,255);
    
        for(i=0; i< strip.numPixels(); i++) {
            strip.setPixelColor(i, c );
    		strip.show();
    		delay( 100 );
        }
    	delay( 500 );
    } 
    Click to Expand
    0
    NeoPixel Turning On
    Kenny Harsono - https://youtu.be/cuBCEb_lj0Y
    0
    // EXCERCISE 2: Turning on Neopixel different color
    
    // 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();
        strip.show(); // Initialize all pixels to 'off'
    }
    
    void loop() {
        uint16_t i;
        uint32_t c = strip.Color(0,0,0);
        
        for (int j=0; j<4; j++) {
            
            switch (j){
                case 0:
                    c = strip.Color(0,0,255);
                    break;
                case 1:
                    c = strip.Color(255,0,0);
                    break;
                case 2:
                    c = strip.Color(0,255,0);
                    break;
                case 3:
                    c = strip.Color(255,255,255);
                    break;
            }
            
            for(i=0; i< strip.numPixels(); i++) {
                strip.setPixelColor(i, c );
    		    strip.show();
    		    delay( 100 );
            }
    	    delay( 1000 );
        }
    }
    Click to Expand
    0
    NeoPixel Color Change Itteratively
    Kenny Harsono - https://youtu.be/v4wI4rxD9BQ
    0
    //EXCERCISE 3: Turning on & off Neopixel itteratively
    
    // 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();
        strip.show(); // Initialize all pixels to 'off'
    }
    
    void loop() {
        uint16_t i;
        uint32_t c = strip.Color(255,255,255);
    
        for(i=0; i< strip.numPixels(); i++) {
            strip.setPixelColor(i, c );
    		strip.show();
    		delay( 100 );
        }
    	delay( 500 );
    	
    	c = strip.Color(0,0,0);
    	for(i=0; i< strip.numPixels(); i++) {
            strip.setPixelColor(i, c );
    		strip.show();
    		delay( 100 );
        }
    } 
    Click to Expand
    0
    NeoPixel On & Off
    Kenny Harsono - https://youtu.be/Fco4gGUAH_w
    0
    // EXCERCISE 4: Inputting RGB value for Neopixel
    
    // 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 colorFunc(const char *args);
    
    void setup() {
        strip.begin();
        strip.show(); // Initialize all pixels to 'off'
        Particle.function("colorFunc", colorFunc);
    }
    
    void loop() {
        
    }
    
    int colorFunc(const char *args) {
        
        int R, G, B;
        sscanf(args, "%d,%d,%d", &R, &G, &B);
    
        uint16_t i;
        uint32_t c = strip.Color(R, G, B);
            
        for(i=0; i< strip.numPixels(); i++) {
            strip.setPixelColor(i, c );
    	    strip.show();
    	    delay( 100 );
        }
        delay( 1000 );
        return 1;
    }
    Click to Expand
    0
    NeoPixel Changing Color Through Particle Cloud
    Kenny Harsono - https://youtu.be/KjFfZh88Pao
    0
    // 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
    0
    IFTTT & Neopixel implementation: Calendar Reminder
    Kenny Harsono - https://youtu.be/vDaMU2Mh2GU
    0

    Reflection

    The takeaways through these experiments are valuable to be utilized for future use cases:

    • Interfacing with Neopixel is rather simple after uploading the library, and understanding how to turn on one LED at a time.
    • Having an external output power is slightly more desired so that there's not much power dependency from the particle.
    • IFTTT has a rather simple GUI, but would be challenging when the app is not integrated already.
    • IFTTT isn't always reliable. You need to select the 'check' button to make sure it reads the input.

    All in all, IFTTT is very handy in future use cases for IoT. It is the basis of connecting hardware devices to multiple cloud application connected to electronics (phone, laptop & etc.). 


    x
    Share this Project

    Courses

    About

    Build proficiency in Neo Pixel & IFTTT