The nightlight contains 18 "NeoPixel" (WS-2812) LEDs, controlled by an ATtiny85 microcontroller. (The firmware for the microcontroller is in a separate repository.)
There is a tiny potentiometer on the back, which can be used to control the brightness. (This functionality is handled in software, so it could potentially be repurposed, such as to control speed or color instead.)
The nightlight plugs into a standard USB power adapter (phone charger), which handles the AC-to-DC conversion.
If you don't want to build your own, I am now selling fully assembled butterflies.
Bill of Materials
- D1-D18 (qty 18) - 5mm through-hole NeoPixel. SparkFun part no. COM-12986. Digi-Key part no. 1568-1213-ND.
- U1 (qty 1) - ATtiny85 microcontroller. Atmel part no. ATTINY85-20PU. Digi-Key part no. ATTINY85-20PU-ND.
- U1 (qty 1) - 8-pin DIP socket. Assmann part no. A 08-LC-TT. Digi-Key part no. AE9986-ND.
- J2 (qty 1) - USB A plug. Molex part no. 0480370001. Digi-Key part no. WM17117-ND.
- C1 (qty 1) - 0.1µF 0805 capacitor. AVX part no. 08055C104KAT2A. Digi-Key part no. 478-1395-1-ND.
- C2 (qty 1) - 10µF 0805 capacitor. Kemet part no. C0805C106K8PACTU. Digi-Key part no. 399-4925-1-ND.
- R1 (qty 1) - 470 Ohm 0805 resistor. Rohm part no. ESR10EZPJ471. Digi-Key part no. RHM470KCT-ND.
- POT1 (qty 1) - 10k Ohm potentiometer. Bourns part no. TC33X-2-103E. Digi-Key part no. TC33X-103ECT-ND.
- SW1 (qty 1; optional) - Pushbutton. Omron part no. B3S-1000. Digi-Key part no. SW415-ND.
- Bare wire, 20 AWG.
- USB power adapter with USB A receptacle.
- Standard soldering tools.
- Tiny AVR Programmer. SparkFun part no. PGM-11801. Digi-Key part no. 1568-1079-ND.
- Computer with Arduino IDE installed.
If you're not making any changes to the board, all you need to do is
zip up the files in the
gerber directory, and upload the zipfile to
Note that in the KiCad files and Gerber files, the "front" of the board is actually the back, and vice-versa. This is because JLCPCB adds a customer ID number to the front of the board, but I wanted the number to be on the actual back of the board, where it doesn't disrupt the esthetics of the nightlight. (It turns out it's possible to specify the location of the customer ID, but I hadn't read that when I first came up with this trick.)
Solder the surface-mount components C1, C2, R1, and POT1 onto the back of the board.
Solder the USB plug onto the back of the board. The plug is meant to be used at a right angle, so some surgery is required. Use needle-nose pliers to bend the pins so that they are straight, rather than at a right angle. Insert the pins through the holes in the board. Use Scotch tape to hold the plug in place. Trim the pins just a little bit, so they don't protrude quite so far through the board. Solder the pins to the board. Remove the Scotch tape from the back. Then, create a bead of solder all the way around where the plug touches the board on the back, to hold it in place firmly.
Solder the 8-pin DIP socket to the front of the board. The "U"-shaped indentation should point toward the top of the butterfly.
Solder the 18 LEDs to the front of the board. The LED should be positioned so that the square pad gets one of the longer legs, not one of the shorter ones.
Create the butterfly's antennae by inserting a length of bare wire into the holes on the butterfly's head. (These two holes are represented by J3 on the schematic.) It's a tight fit, so friction may be enough to hold the wire in place, but you can always solder it to be sure.
Program the firmware into the ATtiny85 chip.
Insert the ATtiny85 into the socket on the butterfly. The dot on the chip should be in the upper-left corner.
Plug the butterfly into the USB power adapter.
Plug the power adapter into the wall.
SW1 can optionally be populated with a surface-mount pushbutton, which is connected to physical pin 5 of the ATtiny85. (Arduino digital pin 0.) This is not used in the default firmware, and I don't normally populate it. But, you can populate it if you want to have an additional input in custom firmware that you write. The pushbutton pulls the pin to GND, so you'll need to activate the internal pullup.
This design is licensed under the Creative Commons Attribution-ShareAlike 4.0 International license.
Some of the footprints in
myLibrary.pretty are based on footprints
in the KiCad library, which is licensed under the
KiCad library license (which is now also CC-BY-SA-4.0, with an
exception). The footprint in
digikey-footprints.pretty is a
modified version of a footprint from the Digi-Key KiCad library,
which is licensed under the same terms as the KiCad library.