Skip to content


Making an Ikea Mood Lamp

Since I first got my Arduino and some RGB LEDs I’d wanted to build myself a mood lamp with some funky features (note that I used the word funky and not useful).  Well, I’ve finally done it, and here is the blog post describing how.

For this project I used the Ikea Grönö, which was £4.99 when I bought it.  It quite a nice matt glass finish, which helps to diffuse light, and also it comes with the glass shade and the actual light fitting separate from one another (I put the light fitting to one side as I won’t be using it in this project).

As well as that I used…

  • 3 x NPN Transistors – TIP122 5A
  • 3 x 47 Ohm Resistors
  • 1 x 100 Ohm Resistor
  • 2 x 330 Ohm Resistors
  • 2 x RJ45 connectors
  • 2 x 16000mcd Red LEDs
  • 2 x 18000mcd Green LEDs
  • 2 x 9000mcd Blue LEDs
  • 1 x Arduino Duemilanove
  • Some breadboard, wire and solder…

The brightnesses above were only chosen because they were the highest that were available at a fairly reasonable cost.  It might be better to match the brightnesses of all LEDs, although if memory serves, human eyes aren’t as sensitive to blue light as they are red and green, so it might be worth getting a brighter blue LED (I advise doing some more research).

Anyway, on with the build…

Firstly, LEDs tend to be highly directional (i.e most light goes in front of the led).  There seem to be lots of diffusing and mixing lenses available at various shops, but I decided I’d have a go at just scuffing the LEDs with some sandpaper.  I was quite happy with the diffusion of light after having done that, so my next step was to breadboard the LEDs out.  I arranged them into a triangular shape with a common ground rail on the breadboard, and individual positive rails for each diode.

In this project I’ve used the 5V supply from the arduino, my LEDs however were expecting

  • Red: 1.9V 50mA
  • Green, Blue: 3.4V 20mA

Therefore resistors must be added to stop the components from being ‘popped’ (trust me, blown up LEDs stink).  The required resistance can be easily calculated using Ohms Law – V = IR.

V = The potential difference across the resistor (Volts).

I = The current in the circuit in series with the resistor (Amps).

R = The resistance of the resistor (Ohms).

So, we need the following values.

  • Red: R = V/I = (5.0 – 1.9) / .050 = 3.1 / .050 = 62 Ohms
  • Green, Blue: (5.0 – 3.4) / .020 = 1.6 / .02 = 80 Ohms

Simple… Here’s a video of the lamp shade placed over the breadboarded leds.

Although you can’t see it in that video, with only one LED of each colour it was far too hard to see when the surrounding light levels were high so I decided I’d add another led of each colour so they were arranged as in the following diagram.

LED Arrangement in Arduino mood lamp

LED Arrangement in Arduino mood lamp

I used three TIP122 NPN Transistors to allow the LEDs to draw more current than if I were just feeding them directly from the PWM outputs on the Arduino. The diagram below shows the circuit design as it was breadboarded out.  This is in fact basically the same as the final circuit diagram (except with an Cat 5 patch cable separating the transistors from the resistors and LEDs).

Circuit diagram for breadboarded ikea mood lamp

The breadboarded mood lamp circuit. Numbers in circles correspond to the digital output pins on the Arduino. R1 = 100 Ohms, R2 = 47 Ohms, R3 = 330 Ohms.

Note the resistors and LEDs in parallel.  Now that the LEDs are in parallel, the series part of the circuit must have twice the current required by the LEDs (Red: 100mA, Green and Blue 40mA).  Therefore we require the following resistances.

  • Red: 31 Ohms
  • Green, Blue: 40 Ohms

You could of course just go to the next resistor size up, but I like to make things complicated so I decided I’d try to get as close as I can with the resistors that I had at my disposal.  When combining resistors in parallel, the total resistance of the resistors in parallel is  1/R = 1/R1 + 1/R2 + … + 1/Rn

In the above diagram, R1 = 100 Ohms, R2 = 47 Ohms, R3 = 330 Ohms, meaning that the resistances above are

  • Red: 1/R = 1/100 + 1/47.  R = 32 Ohms
  • Green, Blue: 1/R = 1/47 + 1/330.   R = 41 Ohms

So, after breadboarding that and finding everything worked, I soldered everything to two breadboards.  One containing the LEDs and Resistors, another containing the transistors and leads to connect to the arduino.  I also soldered some RJ45 sockets on to the boards, to allow me to connect the two components together over long distances (I could have used other means, but I have miles of patch cable lying around).  Something to remember when soldering the RJ45 sockets is that if you don’t plan on using crossover cable, you should solder the two sockets in reverse to one another as in the diagram below.

RJ45 socket pins

An example of how you could solder the connections on your RJ45 sockets.

Once you’ve done that, connect everything up and make sure everything works before glueing the LEDs to the bottom of your lamp.  Then you’re pretty much done (except for coding the actual Arduino).  The code I have so far is very simple, it simply fades between colours.

const int led[] = {3,5,6};
const int delayTime = 10;

#define RG 0
#define GB 1
#define BR 2

void setColour(const int * led, const int * colour)
{
	for(int i = 0; i < 3; i ++)
	{
		analogWrite(led[i],colour[i]);
	}
}

void cycle(int which, const int * led)
{
	int a;
	int b;

	switch(which)
	{
		case RG:
			a = led[0];
			b = led[1];
		break;

		case GB:
			a = led[1];
			b = led[2];
		break;

		default:
			a = led[2];
			b = led[0];
	}

	for(int i = 0; i <= 255; i ++)
	{
		analogWrite(b, i);
		analogWrite(a, 255 - i);
		delay(delayTime);
	}
}

void setup()
{
	for(int i = 0; i < 3; i++)
	{
		pinMode(led[i],OUTPUT);
	}
}

void loop()
{
	cycle(RG, led);
	cycle(GB, led);
	cycle(BR, led);
}

And the moment you’ve all been waiting for – a video of the final product…

So there you have it.  I’m sure I’ve probably missed something out, so feel free to ask questions.  My next step is to add some code that lets me change the light over the network, so keep checking back for more updates.

Posted in Arduino, Electronics.

Tagged with , , , , , .


4 Responses

Stay in touch with the conversation, subscribe to the RSS feed for comments on this post.

  1. Thurizas says

    Sorry, antar att jag skall skriva på engelska men har svårt att formulera mig rätt just nu. jag bokstavligen älskar när folk gör eget eller gör om saker. Dina lampor är så häftiga!

  2. Freud says

    Hej. Tack för kommentaren. Jag kommer att skriva en ny artikel snart om vad jag har gjort med lampan sedan det här inlägget. Dessutom kommer jag att skriva något om en liten sensor nätverk jag har jobbat på, så se till att gå tillbaka:)

    Jag ska vara intressant att höra hur väl denna översättning fungerar. Jag använde Google översätta:)

  3. Andrew Hodson says

    As red LED’s need 1v8, green LED’s need 2v & blue LED’s need 3v then why blue & green 1s using same value of resistors?
    Why did you not use 2 × 16ohm risistors to = 32ohms? By having the 2=; then if they do not = quiet the correct values; then there =50% chance of 1=ing more & 1=ing less? But having 1=ing 2× the other then the larger 1 may =2× off what the smaller 1= off?

Continuing the Discussion

  1. Prototyping Project Research « Tiffpip79's Blog linked to this post on 25 October 2010

    [...] Alrighty then! Here is code for the NPN transisors and a link to the site I hacked from: http://beyondallrepair.com/2010/04/making-an-ikea-mood-lamp/ [...]



Some HTML is OK

or, reply to this post via trackback.