Introduction: Color Changing Night Light
This project will help you create a night light that changes colors slowly.... smoothly drifting from one color to the next.
The electronics will be built from a tiny arduino based circuit board.
I selected a tiny digispark from digistump (or a clone is fine).
You can glue any sort of seashell or covering over the Neopixel light.
Step 1: Arduino IDE Set Up - Add Additional Boards
This is the toughest part of the project, and I will leave the details to the steps to the manufacturer of the boards.
Digispark is made by Digistump. The steps to add this circuit board to your Arduino IDE program can be found here. -
https://digistump.com/wiki/digispark/tutorials/con...
This board started off as a kickstarter project, and has been upgraded over time. As such, it may require a struggle to get the board added to your arduino.cc program. I used version 1.6.9 and pasted in the link it suggested into my additional board window inside the program, as described in the link above.
suggested board code to paste into window - http://digistump.com/package_digistump_index.json...
Once you get the board added, your screen should show the digispark board like this picture.
Step 2: Parts Required
You will need:
A tiny USB connected Arduino based circuit board.
I chose a - Digispark. They come in 2 types. Be sure you get the one with the USB connector. We will be powering the board by plugging it into a small phone charger module. I will post a link to Digistump, and also a store that sells Chinese made parts below.
Either will work. Digispark or Digispark
A Neopixel light to connect to our board. You can select any type of Neopixel that uses the WS2812 standard. I will post a link to Adafruit, and also a store that sells Chinese made parts below.
Either will work. Neopixel or Neopixel
A phone charger. You can get one at any convenience store. I found mine at CVS or Rite Aid drugstore for less than $10. We only need a 5v USB output for the digispark board.
A soldering iron with solder
A pair of wire cutter/strippers
Small piece of wire
A small sea shell
Some good glue to attach the shell to the plastic phone charger. I used a regular hot glue gun.
Step 3: Program the Digispark
I suggest you practice programming the Digispark to ensure it is actually working. You can use the BLINK example in the arduino.cc program.
From Digistump website:
The Digispark works a bit differently than some Arduino compatible products. The Digispark programs with a different procedure.
From the Tools menu select Board→Digispark (Default - 16.5Mhz) (The Tools→Programmer selection does not matter) Write some code, open your code, or open a Digispark example. You do not need to plug in your Digispark before invoking upload Hit the upload button. The bottom status box will now ask you to plug in your Digispark - at this point you need to plug it in - or unplug and replug it. You'll see the upload progress and then it will immediately run your code on the Digispark. If you unplug the Digispark and plug it back in or attach it to another power source there will be a delay of 5 seconds before the code you programmed will run. This 5 second delay is the Digispark Pro checking to see if you are trying to program it.
Step 4: Wiring Diagram
The digispark can only handle 5 volts on the 5 volt pin, so be careful. The Vin pin can handle more voltage.
Also be sure to wire our pins to the IN side of the neopixel, not the OUT. The 5v and gnd won't matter, but the signal must be soldered to just the signal IN pad.
5v - 5v to neopixel in
gnd - ground to neopixel in
D0 - signal to neopixel in
Step 5: Helpful Hints
If you are not sure how to get that tiny Digispark program to work, try it first on an UNO board. After you get your program tuned up how you want it (adjust the delay code timing near the end), then you can download it onto the Digispark board.
The Digispark versions have different pins for the on-board LED. Make sure you don't use the same pin. You can determine which pin your board uses, by testing it with the BLINK example code. Just change the pin number for the output pin you want to try. Most boards have an LED on pin 13. Digisparks have it on either pin ZERO or pin ONE.
Don't plug the digispark in to your usb port until after you pressed the download button, and the compiler asks for the board (read the code errors at the lower portion of the screen).
Black out the on board power led with a black sharpie pen if it shows.
Don't melt the wall wart with the hot glue. Glue just a bit at a time, and let it cool.
Good Luck and have fun !
6 Comments
Question 3 years ago on Step 3
Hey I know this a somewhat old project, but if possible, can you post the Arduino code? I can't tell in the picture you posted where spaces and such should be and I think it's messing up my formatting, Thank you.
Answer 3 years ago
In it, I say it's the rainbow example program with some timing variations.
Hope that helps.
Reply 3 years ago
/*
Design by Stephen O'Gara 2016 Digispark Neopixel Night Light
1 neopixel rotates slowly thru the Rainbow command from the
Adafruit_NeoPixel library.
Buy a 120v to 5v USB plug.
Plug in the USB Digispark board from Digistump.
*/
#include <Adafruit_NeoPixel.h>
#define PIN 0
// Parameter 1 = number of pixels in strip
// Parameter 2 = Arduino pin number (most are valid)
// Parameter 3 = pixel type flags, add together as needed:
// NEO_KHZ800 800 KHz bitstream (most NeoPixel products w/WS2812 LEDs)
// NEO_GRB Pixels are wired for GRB bitstream (most NeoPixel products)
Adafruit_NeoPixel strip = Adafruit_NeoPixel(1, PIN, NEO_GRB + NEO_KHZ800);
void setup() {
strip.begin();
strip.show(); // Initialize all pixels to 'off'
}
void loop() {
rainbow(20);
}
void rainbow(uint8_t wait) {
uint16_t i, j;
for(j=0; j<256; j++) {
for(i=0; i<strip.numPixels(); i++) {
strip.setPixelColor(i, Wheel((i+j) & 255));
}
strip.show();
delay(wait);
// adding in a long delay here so the color change is not obvious
delay(100);
}
}
// Input a value 0 to 255 to get a color value.
// The colours are a transition r - g - b - back to r.
uint32_t Wheel(byte WheelPos) {
WheelPos = 255 - WheelPos;
if(WheelPos < 85) {
return strip.Color(255 - WheelPos * 3, 0, WheelPos * 3);
}
if(WheelPos < 170) {
WheelPos -= 85;
return strip.Color(0, WheelPos * 3, 255 - WheelPos * 3);
}
WheelPos -= 170;
return strip.Color(WheelPos * 3, 255 - WheelPos * 3, 0);
}
Reply 3 years ago
Thank you so much :)
6 years ago
Here is the link to the video. It didn't seem to work within the above posting.
6 years ago
This is awesome. I should make one of these for out guest bathroom.