Skills Dev 3-Amal

Made by Amal Jafrani

Created: November 18th, 2021

0

Outcome

The goal of this skills dev was to create an ambient calendar alert, so the neopixel would fade to red 15 mins before a meeting and fade to white when the meeting was over

0

Process

The process of working with a neopixel was pretty straightforward in terms of the circuit and code. I had the most difficulty making the light fade in and out, and even now I think I could come up with more efficient code in comparison to what I currently have. Additionally working with the IFTTT was initially confusing because I wasn't sure how to initially set it up, but once I got familiar with the website it was easier.

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

#include "neopixel.h"

#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'
    
    Particle.function("red", changeRed);
    


}




int changeRed(String color) 
  {
    uint32_t c;  
    uint16_t i;
    int r;
    int g;
    int b;
    
    
    
    if(color == "red"){
        r = 255;
        g = 255;
        b = 255;
        c = strip.Color(r, g, b);
        while ( g > 0) {
            c = strip.Color(r, g, b);
            for(i=0; i< strip.numPixels(); i++) {
                strip.setPixelColor(i, c);
                strip.show();
            }
	        g = g - 10;
	        b = b- 10;
	        delay (100);
        }
        return -1;
    }
    else if (color != "red") { 
	    r = 255;
        g = 0;
        b = 0;
        c = strip.Color(r, g, b);
        while ( g < 256) {
            c = strip.Color(r, g, b);
            for(i=0; i< strip.numPixels(); i++) {
                strip.setPixelColor(i, c);
                strip.show();
            }
	        g = g + 10;
	        b = b + 10;
	        delay (100);
        }
        return -1;
   }
   else {
       return 1;
   }
 }
  
  
void loop() {


}
Click to Expand
0

Reflection

Overall, I thought this was an interesting skills dev cause I was able to connect it to my google calendar making it seem like a useful device. As I mentioned earlier I would want to clean up the code regarding the fading in and out of the neopixel. While the code I have right now does the job, I definitely think there are cleaner and more efficient ways to do so. I would also want to experiment with IFTTT more and see what else I can connect.

x