This code drives a string of four Adafruit Neopixel LEDs connected to an AdaFruit 5V Trinket causing the four LEDs to glow white with varying brightness that emulates the rhythm of human breathing.
It's used to power four LEDs hidden inside a collection of sea glass found on a beach and kept inside an old glass jar. It makes a simple night light.
This little project was made from things I had lying around or found:
- An AdaFruit 5V Trinket
- Four LEDs cut from a strip ot AdaFruit Neopixel
- An old wall wart adapter giving 5V @ 2000mA
- A glass that had previously held a candle
- Sea glass picked up on a beach
- Some Kintsu Glue
I first drilled a hole in the glass using a ceramic drill. The hole is there do that the cable from the wall wart can pass through. To protect the cable once in place I use the Kintsu Glue to make a little strain relief grommet. It also covers the sharp edges of the drilled glass.
The code is pretty simple. It uses the AdaFruit Neopixel library to drive the four LEDs. The LEDS are literally cut with scissors from a strip and then bent into a circle and super-glued together.
There are just three wires to solder:
- +5V from wall wart goes to the Neopixel strip and BAT+ on the Trinket
- GND goes to the Neopixel strip and GND on the Trinket
- A single wire goes from PIN #0 on the Trinket to the Neopixel data line
The electronics are simply buried in the sea glass.
The breathing is based on the old "sleep LED" on Macs and the explanation found here. The formula for the LED brightness is
where x is the number of milliseconds since start. It looks like this when plotted (there's a sharper intake of breath than exhalation):