In the last week of previous year I decided to build lighting behind my bed. I don't like lamps, so basic idea was to use LED strip. Initially, I wanted to use NodeMCU and control light using phone or tablet with HomeKit. However, that still requires me to build server that emulates HomeKit API like a homebridge or HAP-NodeJS and Orange Pi Zero is better hardware choice for this. You get full operating system on that board and can run node server and control LED strip on same hardware. Not having any Orange Pi board around and with wish to make something to test colors and effects, even temporary, I end up using Arduino Nano. I'm planning to revisit this project (hopefully) during this year, but with Orange Pi Zero. It also depends on results of this project and amount of lighting provided.

Project requirements

  • Different "modes" for lighting, solid light colors, different effects
  • On/off hardware switch
  • Button for toggling between modes
  • indicator LED that lights only during start-up or when i toggle between modes
  • Easy way to modify Arduino software
  • Easy way to modify hardware and/or disassemble whole thing
  • Must support 100 LEDs

Schematics and build

Schema Breadboard Build

Please note that I'm not using any resistor before indicator LED. The reason is that blue LED diodes require 3.4V and those are more resistant to 5V. In my case that LED will burn only for a short amount of time and I don't expect it to burn out. However, this is not good practice and adding 220Ω resistor is much better choice.

For building I used anything that was around, industrial electric box with IP45 rating, small 5x7cm perfboard, through hole components,… Jumper wires will help if I need to disassemble whole thing. Also, I left short USB cable attached to the board. This way i can easily change Arduino software.

Every LED in strip uses 0.060 mA when fully bright. That means that for 100 LEDs in strip we need at least 6A power supply to support full brightness. At least, because Arduino board will also use some power. Best thing that I had was 5V/5A power supply and that was good enough for this project. Even this limit when I set all 100 LEDs to white, it's still too bright for my taste.

Software

To build this I used standard Arduino IDE, version 1.8.0. I don't like it at all, but didn't want to spend any time to configure Emacs for Arduino for this simple (and probably temporary) project.

You can see source code here. Please keep in mind that I may change a lot in this code and this article may not be following same code version any more when you read this. In that case see 1.0.0 tag in git.

Only library used in this project is FastLED and it can be installed using "Library Manager" inside Arduino IDE. Great thing is that you can specify colors using RGB or HSV and it's fast.

There are 7 solid color modes: black , white, red, green, blue, yellow and purple. Black is basically "off", makes all LEDs 0x000000. I'll probably remove green and yellow and make white color less bright.

Current effects are:

  • one_at_a_time - Loops from first to the last LED with only one LED on at the same time, red, green or blue. I'll or remove this effect or change it.
  • bars - Sets all LEDs off and than loops from first to the last LED in strip setting that diode on in red, green or blue. I'll or remove or change this effect in the future.
  • fade - Sets slowly all LEDs in strip from off to red, green or blue ate the same time and than slowly sets all LEDs off. Fade in -fade out effect, looks a lot like a "breed" LED on MacBook Pro. It's nice, but probably stick with only one color in the future.
  • fire - Creates flickering fire effect. Looks great, but because of strip position and distance between bed and wall looks too yellow. Need to change this one.
  • twinkle - Lights slowly up to 40 random LEDs with red color. After that starts switching off those LEDs and every time one LED is switched off, another one random LED becomes lit. Sometimes looks more like a fire than fire effect.
  • twinkle_random - Same as twinkle, but colors are also random. Works better with higher saturation.
  • twinkle_single - Same as twinkle, but only one LED is lit red.
  • sparkle - Sets all LEDs off and than sets random single to 0xFFFFFF, sets it off and select next random LED for same effect. Very similar to twinkle_single, but faster. Maybe even too fast and that make this one annoying. I may remove it or merge it with twinkle_single.
  • snow_sparkle - Same as above, but all other LEDs are not off but set to 0x101010. I like this one more.
  • strobe - Strobe effect. Annoying and disabled.

Please keep in mind that color choices and effects used in this version are not final. I used red, green and blue just as a test in many cases to get code and desired effect working. I'm going to change a lot in the future, based on testing in real situations. Also, speed, brightness and colors depend on some external factors, like other lights in the room or distance between back of my bed (where LED strip is located) and the wall. Some effects may look different when you try them.

Share on: