Skill Dev 3
Made by Tyler White
Made by Tyler White
Created: December 16th, 2023
Reflect on the process of making this project. What did you learn? What would you do differently?
This one was pretty interesting because I could see a lot of application for IFTTT and the ambient light notification. Everyone has a million calendar events and having something set up like this could be really helpful. I wish there was applet in IFTTT for canvas that you could hook up to notify you if there were assignments do that day. I struggled and ultimately couldn't figure out the bug with IFTTT. I got the function to work once, but it failed before it worked and then went back to failing after it worked. Seemed like I just got lucky the one time. I dont think it would've made much of difference but I have the Neopixel stick with 8 LEDs instead of the larger circle one most folks had. It would've been cool to play around with it too.
The IFTTT bug was had something to do with the header so I tried figuring that out for a while online and adjusting the way I'd written my code, both in order and construction but nothing seemed to work. From the first set of code to the second set of code I inserted a bool and and a long set the code to show green if the function wasn't called and I added mills to slow down the duration. I didn't try to do anything extravagant with the color mapping. My neopixel has had a couple moments though where it goes from following the code to randomly flashing rainbow, which was interesting, but I couldn't figure out why that was occurring.
// This #include statement was automatically added by the Particle IDE.
#include <neopixel.h>
//IMPORTANT:Set pixel COUNT, PIN, and TYPE
#define PIXEL_PIN D3
#define PIXEL_COUNT 8
#define PIXEL_TYPE WS2812
Adafruit_NeoPixel strip = Adafruit_NeoPixel (PIXEL_COUNT, PIXEL_PIN, PIXEL_TYPE);
bool LightUp = false;
void setup() {
strip.begin();
strip.show();
Particle.function("LightUp", HandleLightUp);
}
void loop() {
if (LightUp == true){
for(int k =0; k<256; k++){
for(int i=0; i<strip.numPixels();i++){
strip.setPixelColor(i, k/2, k, k);
strip.show();
delay(150);
}
}
for (int k = 256; k>=0; k--){
for(int i=0; i<strip.numPixels();i++){
strip.setPixelColor(i, k/2, k, k);
strip.show();
delay(10);
}
}
}
}
int HandleLightUp(String cmd){
LightUp=true;
return -1;
}
Click to Expand
// 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
Adafruit_NeoPixel strip = Adafruit_NeoPixel(PIXEL_COUNT, PIXEL_PIN, PIXEL_TYPE);
int fadeTime = 1000 * 60 * 1;
long timeStart = -1;
bool timerStarted = false;
void setup() {
strip.begin();
strip.show();
Particle.function("LightUp", handleLightUp);
}
void loop() {
if (timerStarted == true) {
long timeNow = millis();
long timeElapsed = timeNow - timeStart;
if (timeElapsed < fadeTime) {
int colorValue = map(timeElapsed, 0, fadeTime, 0, 255);
int r = colorValue;
int g = 25;
int b = 25;
for (int i = 0; i < strip.numPixels(); i++) {
strip.setPixelColor(i, r, g, b);
}
strip.show();
} else {
timerStarted = false;
for (int k=256; k>=0; k--){
for (int i=0; i<strip.numPixels();i++){
strip.setPixelColor(i,255,0,0);
strip.show();
delay(150);
}
}
}
}
else {
for (int i = 0; i < strip.numPixels(); i++) {
strip.setPixelColor(i, 0, 0, 255);
strip.show();
delay (150);
}
}
}
int handleLightUp (String cmd) {
timeStart = millis();
timerStarted = true;
return 1;
}
Click to Expand
A hands-on introductory course exploring the Internet of Things and connected product experiences.
~