Skills Dev III: Ambient Orb - Jody
Made by jmadala
Made by jmadala
This project will attempt to create an ambient calendar using a Neopixel ring. My Particle device will be connected to my Google calendar through IFTTT and display an alert using a Neopixel array.
Created: December 12th, 2020
The goal of this project was to create an ambient calendar alert with my Neopixel ring connected to my Particle device and my Google Calendar through IFTTT. If successful, the Particle device will send an alert vie a color change to green when my appointment to alert me that my appointment is coming up. Once the event starts, it will fade back down to white. Both the fade up and fade down function use millis ()
// 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 light_ring = Adafruit_NeoPixel(PIXEL_COUNT, PIXEL_PIN, PIXEL_TYPE);
void setup() {
light_ring.begin();
light_ring.show(); // initialize everything to off.
}
void loop() {
// version 2
// turn the neopixel on one by one
for( int i = 0; i < light_ring.numPixels(); i++ ){
light_ring.setPixelColor( i, 0, 100, 0 );
// as this appears IN the loop
// the changes appear one by one
light_ring.show();
delay( 500 ); // with a pause of 1/2 a second between them
}
// turn the neopixels off one by one
for( int i = 0; i < light_ring.numPixels(); i++ ){
light_ring.setPixelColor( i, 0, 0 , 0 );
// as this appears IN the loop
// the changes appear one by one
light_ring.show();
delay( 500 ); // with a pause of 1/2 a second between them
}
light_ring.show();
delay( 2000 );
}
Click to Expand
// 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 light_ring = Adafruit_NeoPixel(PIXEL_COUNT, PIXEL_PIN, PIXEL_TYPE);
void setup() {
light_ring.begin();
light_ring.show(); // initialize everything to off.
}
void loop() {
// Version 1 - all blue
for( int i = 0; i < light_ring.numPixels(); i++ ){
light_ring.setPixelColor( i, 0, 0, 255);
}
// as this appears after the loop
// all of the changes are presented at once
light_ring.show();
delay( 2000 );
{
// Version 1 - all red
for( int i = 0; i < light_ring.numPixels(); i++ ){
light_ring.setPixelColor( i, 255, 0, 0);
}
// as this appears after the loop
// all of the changes are presented at once
light_ring.show();
delay( 2000 );
{// Version 1 - all green
for( int i = 0; i < light_ring.numPixels(); i++ ){
light_ring.setPixelColor( i, 0, 255, 0);
}
// as this appears after the loop
// all of the changes are presented at once
light_ring.show();
delay( 2000 );
{
// Version 1 - all white
for( int i = 0; i < light_ring.numPixels(); i++ ){
light_ring.setPixelColor( i, 255, 255, 255);
}
// as this appears after the loop
// all of the changes are presented at once
light_ring.show();
delay( 2000 );
// turn the neopixels off
for( int i = 0; i < light_ring.numPixels(); i++ ){
light_ring.setPixelColor( i, 0, 0 , 0 );
}
light_ring.show();
delay( 2000 );
}
}
}
}
Click to Expand
// 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 light_ring = Adafruit_NeoPixel(PIXEL_COUNT, PIXEL_PIN, PIXEL_TYPE);
void setup() {
light_ring.begin();
light_ring.show(); // initialize everything to off.
}
void loop() {
// Version 1 - all blue
for( int i = 0; i < light_ring.numPixels(); i++ ){
light_ring.setPixelColor( i, 0, 0, 255);
// as this appears IN the loop
// will change one-pixel at a time
light_ring.show();
delay( 500 );
}
{
// Version 1 - all red
for( int i = 0; i < light_ring.numPixels(); i++ ){
light_ring.setPixelColor( i, 255, 0, 0);
// as this appears IN the loop
// will change one-pixel at a time
light_ring.show();
delay( 500 );
}
{// Version 1 - all green
for( int i = 0; i < light_ring.numPixels(); i++ ){
light_ring.setPixelColor( i, 0, 255, 0);
// as this appears IN the loop
// will change one-pixel at a time
light_ring.show();
delay( 500 );
}
{
// Version 1 - all white
for( int i = 0; i < light_ring.numPixels(); i++ ){
light_ring.setPixelColor( i, 255, 255, 255);
// as this appears IN the loop
// will change one-pixel at a time
light_ring.show();
delay( 500 );
}
// turn the neopixels off
for( int i = 0; i < light_ring.numPixels(); i++ ){
light_ring.setPixelColor( i, 0, 0 , 0 );
}
light_ring.show();
delay( 1000 );
}
}
}
}
Click to Expand
This practice exercise was broken down into several parts with the end goal of sending an alert to my Neopixel a few minutes before a calendar appointment was beginning. The goal is to have it fade up slowly (using millis()) and then change color as the event approached. After the event started, it would fade down (also using millis()).
First, I wired my the Neopixel circuit and used the same corresponding code for the outer loop example above and included the Particle.function code so I could call it using the Particle console.
Next, I updated my code to include the fade up to red over a 15 minute period using milis() and then begin a fade down to white after the event began also using millis(). I checked this with the Particle Console first to make sure it worked as intended.
Finally, I used IFTTT to connect my Google calendar and my Particle device to set-up an event to test over the internet. I used green instead of red since the red is too glaring for me even and also indicates "stop" while green tells me something is about to begin.
// Auto added when pulling in library (remember to do this!)
include <neopixel.h>
// 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);
bool meetStatus = false;
bool GreenOn = false;
unsigned long timeAtStart = 0;
unsigned long timeToFade = (60*15000); //15 minutes
float redVal = 255.0;
float greenVal = 255.0;
float blueVal = 255.0;
void setup() {
strip.begin();
strip.show(); // Initialize all pixels to 'off'
Particle.function("meeting_soon", meetingSoon);
}
int meetingSoon(String arg){
timeAtStart = millis();
if (arg == "yes"){
meetingStatus = true;
} else if (arg == "no") {
meetingStatus = false;
}
return 0;
}
void loop() {
uint32_t white = strip.Color(255, 255, 255); // white
uint32_t red = strip.Color(0, 0, 255); // green
uint32_t currentColor;
if (meetStatus == true) {
unsigned long now = millis();
while (now - timeAtStart <= timeToFade){
now = millis();
redVal -= (255/60);
blueVal -= (255/60);
currentColor = strip.Color(255, redVal, blueVal);
for( int i=0; i< strip.numPixels(); i++) {
strip.setPixelColor(i, currentColor);
strip.setBrightness(20);
}
strip.show();
delay(15000);
}
Click to Expand
This was hard and I needed to work with others to figure out how to get the code to work. Also the Neopixel very, very frustrating to work with. My first pixel was broken out of the bag (two of the three wires were disconnected) and after SparkFun sent me a new one, that too fell apart! I had to track down someone to help me solder it back together since I do not have those tools and it took a long time - I think the Neopixel is beautiful but being as delicate as it is, I'm wary about using it as a component. I did like the easy way IFTTT can connect functionalities though it does make me a little nervous giving third party systems access to my calendar. Some of the privacy discussions we had around IoT in class and from the readings really hit home for me with this particular exercise.