Skills Dev III

Made by Nicole Korber ·

create an ambient calendar alert using a neopixel strip

Created: December 18th, 2022

0

Outcome

I created an ambient calendar alert using a neopixel strip.

0
0
#include <neopixel.h>

// IMPORTANT: Set pixel COUNT, PIN and TYPE
#define PIXEL_PIN D2
#define PIXEL_COUNT 8
#define PIXEL_TYPE WS2812
 
Adafruit_NeoPixel strip = Adafruit_NeoPixel(PIXEL_COUNT, PIXEL_PIN, PIXEL_TYPE);

void setup() {
    strip.begin();
    
    Particle.function("red", setRed);   
    Particle.function("blue", setBlue);   
    Particle.function("green", setGreen);   

}

void loop() {
    
}

int setGreen(String value) {
    int v = value.toInt();
    uint32_t green = strip.Color(v, 0, 0);
    int numPixels = strip.numPixels();
    
    if (v >= 0 && v < 256) {
        for( int i = 0; i < numPixels; i++ ){
            strip.setPixelColor(i, green); // set a color 
        }
        
        strip.show();
        delay(500);
        
        return 1;
    } else {
        return -1;
    }
}

int setBlue(String value) {
    int v = value.toInt();
    uint32_t blue = strip.Color(0, 0, v);
    int numPixels = strip.numPixels();
    
    if (v >= 0 && v < 256) {
        for( int i = 0; i < numPixels; i++ ){
            strip.setPixelColor(i, blue); // set a color 
        }
        
        strip.show();
        delay(500);
        
        return 1;
    } else {
        return -1;
    }
}

int setRed(String value) {
    int v = value.toInt();
    uint32_t Red = strip.Color(0, v, 0);
    int numPixels = strip.numPixels();
    
    if (v >= 0 && v < 256) {
        for( int i = 0; i < numPixels; i++ ){
            strip.setPixelColor(i, Red); // set a color 
        }
        
        strip.show();
        delay(500);
        
        return 1;
    } else {
        return -1;
    }
}
Click to Expand
0

Process

First, I soldered my neopixel strip.  This was fairly easy after Daragh's instructions. Then, I wired my breadboard.  It was a fairly easy circuit, similar to the LED wiring.  Then, I wrote my code.  I did have a bit of trouble with this.  I did not load the neopixel library at first, but I quickly realized I needed to add it after flashing the code and getting the error message.  I was proud of myself for notating the correct pin for the neopixel because I had did this erroneously previously.  I worked through the different exercises and was able to get my neopixels to change colors.

0

Next Steps

Next, I would like to work with a larger neopixel strip to connect to an API.  I would like to work to use certain colors to signal different events.

0

Reflection

Neopixels were a completely new concept for me.  They provide far more flexibility and functionality than LEDs.  I can see how they could be very useful to apply to different IoT projects because they can signal many different colors while taking up only a small space.

x
Share this Project

This project is only accessible by signed in users. Be considerate and think twice before sharing.


Courses

About

create an ambient calendar alert using a neopixel strip