Skills Dev III - Akshay Soma

Made by Akshay Soma · UNLISTED (SHOWN IN POOLS)

Build an LED notification for upcoming calendar event

Created: December 4th, 2021

0

Outcome

    • I created a light notification that fades from white to red over the 15 minutes before a meeting is going to start and back to white during the first 15 minutes of the meeting, as triggered by IFTTT
            • I put a tissue over the light because it was so bright and the code used in the video below fades in/out much quicker than the final code provided, for example purposes.


0
Skills Dev 3 Video
Akshay - https://youtu.be/_gkpXxkbxi4
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);


long startTime = 0;
long endTime = 0;
long preTime = 0;
int event(String trigger);

//for light color iteration
int x = 255;

void setup() {
Particle.function("event", event);
strip.begin();
strip.show();
}

void loop() {

    if(millis() < startTime){
    
        for(int i = 0; i<16; i++){
         uint32_t c = strip.Color(255, x, x);   
         strip.setPixelColor(i, c);
        }
        
        strip.show();
        x--;
        delay(3529);
    }
    
     if(millis() > startTime && millis() < endTime){
    
        for(int i = 0; i<16; i++){
         uint32_t c = strip.Color(255, x, x);   
         strip.setPixelColor(i, c);
        }

        strip.show();
        x++;
        delay(3529);
    }
    
    if(endTime > 0 && millis() > endTime){
        strip.clear();
        strip.show();
        preTime = 0;
        startTime = 0;
        endTime = 0;
    }
    
}


int event(String trigger){

strip.Color(255,255,255);
strip.show();
preTime = millis();
startTime = preTime + 900000;
endTime = startTime + 900000;

return 1;
}
Click to Expand
0

Process

Describe the process you underwent to reach the outcome (problems encountered, how you resolved them, as well as, experiments, hacks, tests, refinments, iterations, failures)

I started the process by working through the guides to get the Neopixel to light up and learning how to manipulate the code to create interesting results. Next I signed up for IFTTT and got it setup to call the function for my code 15 minutes before an event started.

Finally, I started the first design of this project. I coded everything to work using the delay() command. There was no use of the loop section in the code. While that worked well, we discussed in class how this made the code difficult to interrupt for testing, so I went back to improve the design. I used the millis() command within the loop section, global variables, and multiple if statements to create something that was easier to test.

0

Reflection

Reflect on the process of making this project. What did you learn? What would you do differently?


In my first implementation of the project, I learned how to call a function using IFTTT and write the code to fade from white to red and back. This helped me learn more about how the code executes and where to place a delay to manipulate if colors change across the ring together or if each pixel moves independently. 

Moving from there, I learned how to use millis() to create better functioning code. It also taught me how I can compartmentalize pieces of a task into various sections using functions and if statements. If I were to do this differently, I would consider changing each pixel independently to make the transition from one color to the next even smoother. 

x
Share this Project

This project is only listed in this pool. Be considerate and think twice before sharing.


Courses

About

Build an LED notification for upcoming calendar event