Ambient Blorb

Made by Leslie Liu

Work with neopixels to program ambient lighting.

Created: December 14th, 2024

0

Intention

Taking David Rose's Ambient Orb as precedent, I learned to work with neopixels to simulate calendar events-controlled ambient lighting.

0

Process

I made a small light using the 12-pixel ring and some scrap wood, having soldered on wires to the neopixel to ensure strong connections. I then added two small sliding potentiometers to control the lighting's hue and tone. Setting IFTTT logistics aside (though I'd like to revisit this in the future), I then matched various calendar events, namely "meeting," "focus," and "away," to different colors and called them via the Particle cloud console to simulate various events passing by throughout a workday.

0
// setup and neopixel
#include "Particle.h"
#include <neopixel.h>
SYSTEM_MODE(AUTOMATIC);
SerialLogHandler logHandler(LOG_LEVEL_INFO);

#define PIXEL_PIN SPI
#define PIXEL_COUNT 12
#define PIXEL_TYPE WS2812

Adafruit_NeoPixel strip(PIXEL_COUNT, PIXEL_PIN, PIXEL_TYPE);


// potentiometers to control color
int potPinR = A1;
int potPinB = A2;
uint32_t c = 0;
bool shouldChangeColor = false;
String calEvent = "";

void setup() {
    Serial.begin(9600);
    Particle.function("calendarEvent",handleCalendarEvent);
}

void loop() {
    updateColor();
    
    strip.begin();
    for ( int i=0; i<strip.numPixels(); i++ ) {
        strip.setPixelColor(i,c); // set a color
    }
    strip.show();
    // delay(2000);
}

void updateColor() {
    if (shouldChangeColor) {
        if (calEvent == "focus") { c = strip.Color(144,241,168,255);
        } else if (calEvent == "meeting") { c = strip.Color(255,30,0,255);
        } else if (calEvent == "away") { c = strip.Color(108,105,128,255); }
    } else {
        // set as whatever color user controls via red and blue potentiometers
        int potRdgR = analogRead(potPinR);
        int potRdgB = analogRead(potPinB);
        int rVal = map(potRdgR,0,4095,0,255);
        int bVal = map(potRdgB,0,4095,0,255);
        
        c = strip.Color(rVal,120,bVal,255);
    }
    
}

int handleCalendarEvent(String eventType) {
    if (eventType != "") { shouldChangeColor = true;
    } else { shouldChangeColor = false; }
    calEvent = eventType;
    
    if (shouldChangeColor) { return 1; }
    return -1;
}
Click to Expand
0

Outcome

My final setup includes a simple wiring of a neopixel ring and two potentiometers to the breadboard.

0

My wireup; the two potentiometers are for color customization should the calendar be open (i.e., no events scheduled).

0

Cycling through open/available, meeting, focus, away, and then back to open/available; with slight manual tweaks to the color.

0

Small notch at the bottom in the back to accommodate neopixel wires.

0

Ambient Blorb in situ.

0

Reflection

I wish I implemented IFTTT, as this would better simulate "real life" uses of the device. However upon further consideration of the user flow of this at home, I wondered whether there could be a way to selectively turn the light on and off to conserve energy.

Overall this was an enjoyable exercise where I learned a couple soldering best practices.

x
Share this Project


About

Work with neopixels to program ambient lighting.