Skill Dev III: Ambient Orb

Made by Junke Zhao

For this project, I'll be using IFTTT to connect the Particle device to my Google Calendar. This device will alert me with a light 15 minutes before the start of the meeting, while the light gradually changes during those 15 minutes to remind me that the time is approaching, and finally when the meeting starts, the light of the device fades.

Created: December 18th, 2023

0

Product

The Neopixel device used to remind the schedule in Google Calendar, which appears white in its normal state, turns green 15 minutes before the schedule starts and gradually changes each LED to red over the next 15 minutes to remind the schedule that it is about to start, and then fades from red to white and returns to its initial state once the schedule has started.

0

Process

Firstly, following the instructions in DIoTLab will create the app on IFTTT and connect it to my Particle account.

Then write code to connect the Argon microcontroller to the Neopixel strip and set its initial state to bright white light.

0

When IFTTT is ready, it receives information about the schedule in Google Calendar and sends the data to Particle Cloud when it reaches the 15-minute countdown. Our Neopixel strip will change from white to green as soon as it receives this message.

0

At the same time, during the next 15 minutes, the LEDs on the strip will turn red in sequence to remind the time is approaching.

0
0

At the beginning of the schedule, the strip turns completely red, and from this time on, the light on the strip fades to white and returns to its initial status.

0
0
#include "neopixel.h"

#define PIXEL_PIN D2
#define PIXEL_COUNT 16
#define PIXEL_TYPE WS2812

Adafruit_NeoPixel strip(PIXEL_COUNT, PIXEL_PIN, PIXEL_TYPE);

int fadeInDuration = 1000 * 60 * 10; // 10 minutes
int fadeToRedDuration = 1000 * 60 * 5; // 5 minutes
int fadeOutDuration = 1000 * 60 * 5; // 5 minutes
long timeStart = -1;
int stage = 0; // 0: idle, 1: fading to white, 2: fading to red, 3: solid red, 4: fading out

void setup() {
    strip.begin();
    strip.show();
    setCoolWhite(); 

    Particle.function("Reminder", LEDReminder);
}

void loop() {
    if (stage > 0) {
        long timeNow = millis();
        long timeElapsed = timeNow - timeStart;

        if (stage == 1 && timeElapsed < fadeInDuration) {
            fadeToWhite(timeElapsed);
        } else if (stage == 2 && timeElapsed < fadeInDuration + fadeToRedDuration) {
            fadeToRed(timeElapsed - fadeInDuration);
        } else if (stage == 3 && timeElapsed < fadeInDuration + fadeToRedDuration) {
            setSolidRed();
        } else if (stage == 4 && timeElapsed < fadeInDuration + fadeToRedDuration + fadeOutDuration) {
            fadeOut(timeElapsed - fadeInDuration - fadeToRedDuration);
        } else {
            setCoolWhite();
            stage = 0; // Reset stage
        }
    }
}

int LEDReminder(String cmd) {
    timeStart = millis();
    stage = 1; // Start fading to white
    return 1;
}

void setCoolWhite() {
    for (int i = 0; i < strip.numPixels(); i++) {
        strip.setPixelColor(i, strip.Color(0, 255, 0)); // Cool white color
    }
    strip.show();
}

void fadeToWhite(long timeElapsed) {
    int brightness = map(timeElapsed, 0, fadeInDuration, 0, 255);
    for (int i = 0; i < strip.numPixels(); i++) {
        strip.setPixelColor(i, strip.Color(brightness, brightness, brightness));
    }
    strip.show();
    if (timeElapsed >= fadeInDuration) {
        stage = 2; // Next stage: fade to red
    }
}

void fadeToRed(long timeElapsed) {
    int redValue = map(timeElapsed, 0, fadeToRedDuration, 255, 255);
    int greenBlueValue = 255 - map(timeElapsed, 0, fadeToRedDuration, 0, 255);
    for (int i = 0; i < strip.numPixels(); i++) {
        strip.setPixelColor(i, strip.Color(redValue, greenBlueValue, greenBlueValue));
    }
    strip.show();
    if (timeElapsed >= fadeToRedDuration) {
        stage = 3; // Next stage: solid red
    }
}

void setSolidRed() {
    for (int i = 0; i < strip.numPixels(); i++) {
        strip.setPixelColor(i, strip.Color(255, 0, 0)); // Solid red color
    }
    strip.show();
    stage = 4; // Next stage: fade out
}

void fadeOut(long timeElapsed) {
    int brightness = 255 - map(timeElapsed, 0, fadeOutDuration, 0, 255);
    for (int i = 0; i < strip.numPixels(); i++) {
        strip.setPixelColor(i, strip.Color(brightness, 0, 0));
    }
    strip.show();
}
Click to Expand
0

Reflection

Along the way, I mastered the use of external libraries and multiple coding methods to control the lighting of LED strips on and off, while through an IFTTT connection I was able to connect Particle Cloud to an external application, which greatly increased the design possibilities. Also next I'll be looking at adding buttons and knobs to turn the light off or change its brightness when alerted that it's on.

x
Share this Project

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

For this project, I'll be using IFTTT to connect the Particle device to my Google Calendar. This device will alert me with a light 15 minutes before the start of the meeting, while the light gradually changes during those 15 minutes to remind me that the time is approaching, and finally when the meeting starts, the light of the device fades.