Mood Lighting

Mike Hansell

Issue 17, November 2018

This article includes additional downloadable resources.
Please log in to access.

Log in

Set the lighting in the room to match your mood with this remote controlled LED strip light controller.


Way back in Issue 8, we created a multi-coloured acrylic lamp. It looked amazing and produced some nice lighting effects, but it wasn’t remote controlled to change the colours. It only used two short LED strips too. We decided to design a project that was remote controlled, and more versatile for our readers to adapt to their own needs.

The staff in the DIYODE office mused over modern lighting solutions, and what kind of light would be needed for different areas of their home. One the staff members suggested that before going to sleep it would be helpful to have a calming warm white glow in the bedroom. Unlike cool white, warm white has less blue light, which can interrupt circadian rhythms.

Someone on the DIYODE team wanted party mood lighting in their “man cave” for when they entertained. After a quick brainstorm, we came up with other light patterns to brighten up an entertaining area or kids bedroom, such as twinkle and rainbow light effects.

Everybody agreed that a remote controlled light would be more convenient, so with all that in mind, we designed a remote controlled, multi-purpose LED strip light controller.


LED strip lighting has become an affordable and convenient lighting solution in the home, office, and workshop.

To change the brightness or colours of a LED strip light though, you usually need to invest in remote controlled RGB strip lights, but many commercial units have limited control over the colours and lighting patterns.

Creating your own remote controlled RGB light strip also has its challenges, so we found out. It takes a higher spec light strip to operate smoothly, if you want to control it from a microprocessor, or an Arduino.

By combining a DotStar LED light strip from Core Electronics, with an ATmega328P, Infrared remote with receiver, and a handful of components, we have designed a LED light strip controller with programmable colour, brightness and pattern combinations to set the right mood.


It doesn't seem that long ago that red LEDs became available. They were quite remarkable at the time. They only needed a few volts, lit up instantly, and didn’t get hot. The early ones were very inconsistent with light intensity though, which were even more obvious when a row of a dozen LEDs was put together. Then along came green and yellow LEDs, which was a big deal at the time. Now we have large, small and in-between sizes, rectangular, bi-coloured, tri-coloured, flashing, colour sequencing LEDs and extremely bright LEDs in all different colours.

We should note that an LED produces 1 colour of light, be it red, green or chartreuse. Bi-colour LEDs actually have 2 LEDs in the 1 package. Of course, this follows for tri-colour, colour sequencing etc. These types of LEDs have multiple individual LEDs, each capable of producing one of the colours, and have some level of extra intelligence built in to provide the switching between the individual LEDs.

LED strips are available in many colours, including warm or cool white, red, green, blue, yellow, RGB (red, green and blue) and RGBW (red, green blue and white), etc. Many strips have a microcontroller in each LED package, producing a spectacular colour range with variable levels of red, green and blue light.

LED strips typically come in 30, 60 or 144 LEDs per metre, in different brightnesses. The cost and the power requirements increase remarkably depending on what you choose.

Not all strip lights are made equal either. As you read on, you’ll find out why some perform differently to others.


Use of LED lighting in the home has become very common. It is generally used in 2 ways:

  • LED strip lighting used to highlight skirting boards, cupboards, etc. This is generally a standard white light of some shade with limited control required.
  • Intelligent room lighting. You’ve probably seen the demonstrations of Amazon’s Alexa or Philips Hue lighting systems. These globes are typically relatively expensive compared to a run-of-the-mill white LED bulb, which in turn is quite expensive compared to the old incandescent globes. With these systems, at your slightest whim, you can change the light colour to any shade you like. Control mechanisms may be voice commands, remote control or mobile phone app. Some systems allow setting schedules and many other features.


Incandescent lights are relatively inefficient, turning electricity into some light but also a lot of heat. They have a relatively short life, and will fail if air should get inside the glass envelope. Common sense and mass production of quality LEDs have seen incandescents pretty much a thing of the past. By contrast, LEDs don't get as hot, have a very long life, and are very efficient. A typical LED globe uses about 1/8th of the power of a like-rated incandescent.

Note: Incandescent bulbs have been phased out by law for global warming reasons.


While it is easy enough to press a switch to change the lighting display, we’ve designed a remote control solution to suit the “lounge lizard” in all of us. Compared to a simple on/off switch, a remote also allows us to select the right lighting effect at the touch of a button, instead of having to cycle through all of them to get to the one you actually want.

With trial and error, we have also learned that a NeoPixel LED strip isn’t suitable. The NeoPixel strip looked great, however, we found that the remote control was sluggish at best to change modes. They need a lot of attention from the controlling electronics (Arduino) and, in fact, using them interferes with the use of the remote control.

We have found that the new DotStar LED strip from Adafruit is much more suitable. The clock and data lines are separated, so virtually any processor speed or type can control these strips. A quick look at the Adafruit website indicates that the strip can be used with Arduino, Raspberry Pi, BeagleBone, Propeller, SparkCore, etc. We should add that the colour blending is much better with the DotStar too.

We have kept the electronics for this project simple and cost effective. We use a ATmega328P, the same MCU or brain of an Arduino UNO, an Infrared receiver module, and a compatible remote control. Like the built-in intelligence in some LEDs, the IR sensor we’re using is quite intelligent too. It doesn’t just detect infrared light, it demodulates (strips the data from) the signal sent from the remote control.


As we’ve elected to use an Infrared Remote Control to set the display mode, we either have to signal the CPU that it has a signal via an interrupt, or alternatively, we poll it.

An interrupt is a mechanism to force the CPU to temporarily stop what it was doing and attend to a specific time-sensitive task. The code that is executed when the interrupt is received is generally referred to as an Interrupt Service Routine, ISR for short. The code in the ISR should be as quick as possible to allow the CPU to attend to other code. At the end of the ISR, the sketch continues running the code at the point it was interrupted.

Polling refers to checking regularly for a signal. The IR detector module has no specific “I have data” pin to use as an interrupt source, so we initially tried to generate an interrupt directly from the data stream when a signal is received. This didn’t work out, so we adopted a hybrid approach of causing a timed interrupt that then polls the sensor.

To achieve our timed interrupt we have the Arduino generate a stream of pulses via PWM on a digital pin that is fed back to the ATmega328P, which causes an interrupt for each pulse. As the Arduino generates these pulses at about 1kHz we check for a signal from the remote control about every 1ms.

Note: The Arduino Mega’s PWM output signal is about half of the UNO rate. To generate a stream of pulses as we have done is a simple matter of using digitalWrite() with a pin that is capable of generating a PWM signal. On an UNO these are digital pins 3, 5, 6, 9 10 and 11.


One thing that is common to all LED strips is that they can require a lot of electrical current. The maximum for each ‘dot’ is 60mA. As there are actually 3 LEDs (1 red, 1 green and 1 blue) in each dot, that’s 3 × 20mA each. The strip we are using has 30 dots, let’s call them LEDs though. That makes for a maximum of 1800mA or 1.8Amps at full brightness.

An Arduino UNO using an external power supply (not the USB connector) can supply about 900mA. If being powered by the USB connector the available current is about 500mA. This means that you are pushing the limits powering the LED strip from an Arduino, however, we can confirm that is possible, but we do not recommend doing this long-term. Note that powering the LED strip in this way may cause odd effects such as flickering, etc.

It is recommended to wire a 1000uF/6.3V or higher voltage electrolytic capacitor across the power pins of the LED strip, and at each metre (assuming you are using more than a 1 metre strip) of LED strip. Another recommendation is to insert a resistor of between 300 and 500 ohms (so 330, 390, 470 ohms, we opted for 390 ohms) in series with the data and clock pins of the LED strip. You could conceivably drive 5 metres of LED strips if you’d like, but beware of the power requirements.

With the supplied sketch running in any mode, an UNO powered via USB or an external regulated 5V power supply can comfortably power 1 metre of LED strip. If you intend to use multiple or longer strips you will want to consider powering it/them from an external power supply.

Note: While powering an Arduino from an external power supply it is not recommended to have a USB cable from your computer connected at the same time. This helps to avoid damaging the power circuitry on the Arduino.


The DotStar LED strips have a 4 wire interface including 2 pins for power and ground. They run on 5V, which is convenient and require 2 data pins on your Arduino. They come cabled to JST SM connectors. We chose to remove this connector and solder breadboard jumper wires (with the metal pins trimmed to help prevent short circuits) directly to the copper pads on the LED strip. Provision is made on the strips for a cut to be made between each LED package. You could have a single LED if you wanted.

One thing you can be sure of is that one LED strip may well be wired differently to the next. Online images show the strip with the ground at the top, then clock, data and 5 volts at the bottom. Our strip is configured as 5 volts at the top then clock, data, and ground at the bottom. Ensure you verify by visual inspection the configuration of your strip before connecting it.

Another inconsistency is the colour order. You’ve probably heard of RGB being red, green and blue. We were expecting RGB colour order but this resulted in very odd colours. Some experiments showed that our strip is actually configured as BGR ‘COLOR_ORDER’. We’ve provided a simple sketch (COLOR_ORDER.ino) which you can run to identify the correct ‘COLOR_ORDER’ for your strip.

The strips themselves are flexible, to a degree. We would not recommend tying them in knots ‘just to see’, but certainly they can follow a curved surface. The strips we have used are sealed in a silicone rubber sleeve making them weatherproof to some degree.


As we have an LED strip that is capable of a broad range of colour, we have implemented a number of animated display sequences we call modes. The available modes can be selected with the numeric keypad on the remote control.

MODE 1 - CHILLAX: This is a relaxing sequence of cyan to mid blue to mid magenta and repeat.

MODE 2 - COLOUR BARS: Yellow, Cyan, Green, Magenta, Red, Blue cycling up the strip and repeating

MODE 3 - SURPRISE ME: A random pattern of colours.

MODE 4 - OVER THE RAINBOW: A beautiful display of the range of colours available with DotStar LEDs.

MODE 5 - CALMING WHITE: Kinda warm white. This is the mode that started the development of this project. This is a low blue white-ish light that helps to signal your brain that it is now sleeping time.

MODE 6 - THINK PINK: This is a pale pink shade that you may find relaxing as a background light.

MODE 7 - RELAXING TEAL: This is a relaxing ambient light shade.

MODE 8 - TWINKLE, TWINKLE: This mode simulates twinkling stars. Every few seconds some of the LEDs have their brightness levels changed, lighter or darker. Keep an eye out for the appearance of Mars.

MODE 9 - LIGHTS OUT: this simply turns the LEDs off.

Along with the above display modes, you can also adjust the brightness and the speed of colour changes, if any. The + and - keys control the brightness. The |<< (rewind) and the >>| (fast forward) keys control the colour transistion speed.

We have written a small sketch to identify the codes corresponding to the signals produced by your remote control. Refer to the IRDecoder.ino in our digital resources. This should be helpful if you use a remote control that works differently compared to the one we've used on this build.


To help you remember the modes, we have designed a small chart that you can print, laminate and stick over the remote, so the buttons show the new functions of the remote. A blank one is also included if you make your own patterns.

The Fundamental Build:

The Prototype

Parts Required:JaycarAltronicsCore Electronics
1 × Arduino UNO or SimilarXC4410Z6240CEO5629
1 × Mini BreadboardPB8817P1020POLOLU-350
1 × IR Receiver Module#XC4427Z1611A015-PL-IRM0101-3
1 × Remote Control^XC3718-DFR0107
1 × 1m DotStar LED Strip--ADA2237
2 × 390Ω ¼W Resistors*RR0562R7548-
1 × 1000μf/6.3V Electrolytic Capacitor*RE6220R5182COM-08982

Parts Required:

* Quantity shown, may be sold in packs. Some prototyping hardware is also required.

# The IR receiver modules from Altronics and Core Electronics is a 3 pin device but not mounted on a PCB to form a module.

^ We have used the Jaycar remote control for this project. The Core Electronics model is untested and may produce different codes than the Jaycar unit.

We built our prototype on a tiny breadboard and interfaced that to an Arduino UNO. In our tests, the UNO powered the LED strip without obvious issue.

We looked at moving to an ATtiny85 to reduce the size and cost of the package but the code with libraries didn’t fit into its limited memory.

We have provided a parts list and Fritzing diagram if you want to make your own prototype similar to ours.

Make sure you pay attention to the polarity of the electrolytic capacitor to ensure it gets inserted the right way.

Our fritzing shows an infrared module, but you could of course, substitute this for just the IR receiver component on its own, matching the same orientation.

With the components and wiring in place, we can go ahead and program the UNO. Connect the UNO to your computer via USB and upload the sketch.

With the sketch uploaded you can now connect the power supply. Within a few seconds, you should be greeted with a colourful display. Check each of the display modes by pressing the number keys on the remote control.


Like most Arduino sketches, we are using some libraries to provide some functionality. For those new to Arduino, a library is a tested package of code that you can use to add functionality to your sketch. Libraries are often written by the manufacturers of a hardware item. We use 3 libraries, namely FastLED, IRremote and the EEPROM libraries.

Our ISR is called approximately every millisecond to poll the IR receiver. We test whether a valid signal has been received, and if it has, we set a variable ‘mode’ to the appropriate value. The Arduino will call the loop() function as regularly as possible. loop() will change the actual mode and display shown on the LEDs. Meanwhile, without obvious intervention, the system continues generating interrupts to check for any received data from the remote control.

With each change of mode, we save the mode value into the Arduino’s EEPROM. EEPROM is a small amount of memory that can store data when the power is turned off. When our display is restarted, this last used mode is read from the EEPROM and sets the initial display mode.

If you prefer a particular mode to be displayed at each start then you simply set it and forget it, knowing that is what you will see next time. While EEPROM is a very useful storage medium, it does exhibit a phenomenom called ‘wear’. Wear is caused by each write to the EEPROM.

The EEPROM cell (the part we are writing to) can actually become unusable after about 100,000 writes. It is unlikely that we’ll do anything like that, so it is safe to use as we are. In any case, if a cell became unusable, we could simply modify the sketch to use another.

There is a little more to using the EEPROM. EEPROM that has not been used before may contain random data but will probably contain 0’s. At the initial run of the sketch, it will determine if the EEPROM has valid data stored.

We do this by checking for a ‘signature’ or a specific value in the first 2 bytes of the EEPROM. If this is found then the mode is read, otherwise, the signature is written and the mode data will be stored whenever it is changed. The brightness and colour transition rate parameters are also stored when changed and read at startup.

As we are using DotStar LED strip we’ve opted to use the FastLED library. FastLED requires an array, not surprisingly called ‘leds[]’ to store the value of the colour to be displayed for each LED. A call to then transfers the data (colour info) from the array into the LEDs, quickly. The FastLED library provides a large number of functions that we may use in future projects. It has fast maths functions, colour conversion functions and much more.

Note: As a stored brightness value of 0 may make the display appear defective (“where’s the lights?”), if this is detected then a low brightness value will be used instead.

Build 2:

The Main Build

Additional Parts Required:JaycarAltronicsCore Electronics
1 × Prototyping BoardHP9570H0701-
1 × ATmega328P MCUZZ8727Z5126ATMEGA328+UNO+CAPS
1 × 16MHz Crystal (if not supplied with the ATmega328P)-V1289A-
1 × 3mm Red LEDZD0100Z0700POLOLU-1070
1 × 1N4004 Diode*ZR1004Z0109COM-14884
1 × 28pin Machined IC SocketPI6466P0541-
1 × 5VDC 1A Power SupplyMP3144M8903AM8904
1 × 2.1mm DC Input JackPS0519P0620PRT00119
3 × 390Ω ¼W Resistors*RR0562R7041-
1 × 1000uF 10V Electrolytic CapacitorRE6220R5182COM-08982
1 × 100nF Ceramic CapacitorRC5360R2865CE05188
2 × 22pF Ceramic CapacitorsRC5316R2814-

Additional Parts Required:

* Quantity shown, may be sold in packs.

Once the prototype was proven we moved to a small prototyping board. While it was a bit of a squeeze, it did fit and made for a small footprint.


Working with prototyping board is quite different from a purpose-built PCB or breadboard. The first thing to be aware of is that all components need to be soldered. If you are not confident with soldering this may be a good project to practice on.

As with all expensive IC’s, or those that may be inserted and removed a number of times, we recommend the use of quality machined pin IC sockets. If you have trouble locating a 28 pin IC socket for the 328P, then 2 × 14 pin sockets fit end to end quite nicely. Take care to orient the socket/s such that pin 1 is oriented to the left. IC sockets generally have a semi-circular gap at the pin 1 end. IC's have something similar or maybe a small ‘dimple’ in the package. As with all component placement, it is wise to double check the orientation of the components before soldering and applying power. As we always say, “keep the smoke in”.

In this case, it is best to wire in the resistors first. They are low profile and will stay in the board when you flip it over to solder the components. It is good practice to solder just 1 leg of a component or IC socket first, so you can verify the component is flush to the board before soldering the other legs. Go ahead and solder the remaining pins if the component is flush to the board. If the component is not flush then it is easy to heat 1 pin rather then try to wrangle a number of pins. Keep the leftover component pigtails as you will need them for interconnecting links. At this point, you could solder the IC socket in using the same technique. Solder 1 pin then check that the socket is flush. Continue with the ceramic capacitors near the crystal and then the rest of the components. Do not insert the 328P IC at this stage.

Follow our diagram shown here to ensure everything is wired correctly. You will also need to bridge some pads and cut two tracks as shown in the diagram above.

Some care needs to be given to the DC input jack. Its connecting pins do not suit the breadboard. We mounted it on its side and superglued it into place.

When you have completed the component installation it would be worthwhile to connect the power supply and measure the voltage across the electrolytic capacitor. It should be 5 volts with the correct polarity. Connect the black probe of your multimeter to the clearly marked negative terminal of the capacitor then touch the red probe to the positive terminal. You should measure close to +5 volts. If you don't, re-check your wiring. If the test looks good you can disconnect the power.

Next, we need to upload the supplied sketch to your ATmega328P. You can do this using an UNO.

Once the Atmega328 has been programmed, insert the programed ATmega328P into the IC socket, ensuring that it is oriented correctly.

You can now reconnect the power supply. Within a few seconds, you should be greeted with a colourful display. Check each of the display modes by pressing the number keys on the remote control.


You could install into a Jiffy box or design and print your own enclosure. Apart from making the project look like a complete product, it will keep all of the electronics protected. As your veroboard may differ from ours slightly, we haven't provided a 3D printable case for this build. As your veroboard may differ from ours slightly, we haven't provided a 3D printable case for this build.


It is relatively easy to use the example display modes to create your own, or you could modify the existing modes to show different colours. Why not add a real-time clock to produce a nice sunrise effect or turn off (set all LEDs to off) at night?