Skills Dev III: Ambient Orb

Made by Yi Sun

Created: December 10th, 2022

0

Outcome

    • In this project, I connected the neopixel lights with IFTTT. 15 minutes before an event in google calender happens, lights will be triggered and fade from white to red. After the meeting happen, lights will fade from red to white in 15 minutes. In the video, I set the fading time as 10 seconds to make it easier to demonstrate. But in the code it is 15 minutes.

1
// This #include statement was automatically added by the Particle IDE.
#include <neopixel.h>

#define PIXEL_PIN D3
#define PIXEL_COUNT 8
#define PIXEL_TYPE WS2812

int otherColor;
unsigned long lastFade = 0;
int timeInterval = 15*60000;
// int timeInterval = 10000;

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

void setup() {
    strip.begin();
    strip.show(); // Initialize all pixels to 'off'
    Particle.function("eventStart", fadeToRed);
    lastFade = millis();
}

void loop() {
    // fadeToWhite();
}

void setPixels(int intensity) {
    uint16_t i;
    uint32_t c = strip.Color(255, intensity, intensity);

    for(i=0; i< strip.numPixels(); i++) {
        strip.setPixelColor(i, c );
		strip.show();
    }
	delay(100);
}

int fadeToRed(String command) {
    // fade to red
    otherColor = 255;
		unsigned long now = millis();
		while(otherColor>0) {
		    if ((now - lastFade) >= timeInterval/255) {
		        otherColor--;
		        lastFade = now;
		    }
		    setPixels(otherColor);
		    now = millis();
		}
	
	// fade to white
	otherColor = 0;
		while(otherColor<=255) {
		    if ((now - lastFade) >= timeInterval/255) {
		        otherColor++;
		        lastFade = now;
		    }
		    setPixels(otherColor);
		    now = millis();
		}
		
    return 1;
}
Click to Expand
0

Process & Next Steps

I first built the circuit, wrote a single function to let the neopixels fade to red. After this function passed the test, I subscribed to a cloud function, converted the fading function to a responding function to that cloud function. Then I created the integration on IFTTT and let it trigger the cloud function. 

Challenges: I set an event happening 15 minutes later on google calendar for testing, but the IFTTT failed to catch that event and gave any response. I thought there are some problems with my setting and I checked many times but found nothing incorrect. In the end I found that the service will be triggered about 16 minutes before the event happens, not exactly 15 minutes.

I also found that there was a delay when the neopixels began to turn to red. But at last I found that it is because at first the color value in other two channels is so big (255), that the light color is nearly white, so although it is fading, it is hard to be distinguished by our eyes.

0

Reflection

In this project, I learned how to get services in IFTTT and connect it Particle functions. I also learned how to control neopixels and generate some beautiful effects using it. If I will do it again, I will first test whether IFTTT can correctly send signals to Particle, so that I do not need to doubt whether there are bugs in other components.

In the future, I will explore more services in IFTTT and apply it to implement more useful products to remind people of some kind of information or to physicalize other kinds of data.

x