Tag Archive | "LED"

Experimenting with Arduino and IKEA DIODER LED Strips


A few weeks ago I found a DIODER LED strip set from a long-ago trek to IKEA, and considered that something could be done with it.  So in this article you can see how easy it is to control the LEDs using an Arduino or compatible board with ease… opening it up to all sorts of possibilities.

This is not the most original project – however things have been pretty quiet around here, so I thought it was time to share something new with you. Furthermore the DIODER control PCB has changed, so this will be relevant to new purchases. Nevertheless, let’s get on with it.

So what is DIODER anyhow? 

As you can see in the image below, the DIODER pack includes four RGB LED units each with nine RGB LEDs per unit. A controller box allows power and colour choice, a distribution box connects between the controller box and the LED strips, and the whole thing is powered by a 12V DC plugpack:


The following is a quick video showing the DIODER in action as devised by IKEA:


Thankfully the plugpack keeps us away from mains voltages, and includes a long detachable cable which connects to the LED strip distribution box. The first thought was to investigate the controller, and you can open it with a standard screwdriver. Carefully pry away the long-side, as two clips on each side hold it together…

IKEA DIODER Arduino tronixstuff
… which reveals the PCB. Nothing too exciting here – you can see the potentiometer used for changing the lighting effects, power and range buttons and so on:

ikea dioder tronixstuff arduino

Our DIODER has the updated PCB with the Chinese market microcontroller. If you have an older DIODER with a Microchip PIC – you can reprogram it yourself.

ikea dioder arduino tronixstuff

The following three MOSFETs are used to control the current to each of the red, green and blue LED circuits. These will be the key to controlling the DIODER’s strips – but are way too small for me to solder to. The original plan was to have an Arduino’s PWM outputs tap into the MOSFET’s gates – but instead I will use external MOSFETs.

ikea dioder arduino tronixstuff

So what’s a MOSFET?

In the past you may have used a transistor to switch higher current from an Arduino, however a MOSFET is a better solution for this function. The can control large voltages and high currents without any effort. We will use N-channel MOSFETs, which have three pins – Source, Drain and Gate. When the Gate is HIGH, current will flow into the Drain and out of the Source:


A simplistic explanation is that it can be used like a button – and when wiring your own N-MOSFET a 10k resistor should be used between Gate and Drain to keep the Gate low when the Arduino output is set to LOW (just like de-bouncing a button). To learn more about MOSFETS – get yourself a copy of “The Art of Electronics“. It is worth every cent.

However being somewhat time poor (lazy?), I have instead used a Freetronics NDrive Shield for Arduino – which contains six N-MOSFETs all on one convenient shield  – with each MOSFET’s Gate pin connected to an Arduino PWM output.
freetronics ndrive shield tronixlabs

So let’s head back to the LED strips for a moment, in order to determine how the LEDs are wired in the strip. Thanks to the manufacturer – the PCB has the markings as shown below:

ikea dioder tronixstuff arduino

They’re 12V LEDs in a common-anode configuration. How much current do they draw? Depends on how many strips you have connected together…

ikea dioder arduino tronixstuff

For the curious I measured each colour at each length, with the results in the following table:


So all four strips turned on, with all colours on – the strips will draw around 165 mA of current at 12V. Those blue LEDs are certainly thirsty.

Moving on, the next step is to connect the strips to the MOSFET shield. This is easy thanks to the cable included in the DIODER pack, just chop the white connector off as shown below:

ikea dioder arduino tronixstuff

By connecting an LED strip to the other end of the cable you can then determine which wire is common, and which are the cathodes for red, green and blue.

The plugpack included with the DIODER pack can be used to power the entire project, so you will need cut the DC plug (the plug that connects into the DIODER’s distribution box) off the lead, and use a multimeter to determine which wire is negative, and which is positive.

Connect the negative wire to the GND terminal on the shield, and the positive wire to the Vin terminal.  Then…

  • the red LED wire to the D3 terminal,
  • the green LED wire to the D9 terminal,
  • and the blue LED wire to the D10 terminal.

Finally, connect the 12V LED wire (anode) into the Vin terminal. Now double-check your wiring. Then check it again.

ikea dioder tronixstuff arduino


Now to run a test sketch to show the LED strip can easily be controlled. We’ll turn each colour on and off using PWM (Pulse-Width Modulation) – a neat way to control the brightness of each colour. The following sketch will pulse each colour in turn, and there’s also a blink function you can use.

Success. And for the non-believers, watch the following video:

Better LED control

As always, there’s a better way of doing things and one example of LED control is the awesome FASTLED library by Daniel Garcia and others. Go and download it now – https://github.com/FastLED/FastLED. Apart from our simple LEDS, the FASTLED library is also great with WS2812B/Adafruit NeoPixels and others.

One excellent demonstration included with the library is the AnalogOutput sketch, which I have supplied below to work with our example hardware:

You can see this in action through the following video:

Control using a mobile phone?

Yes – click here to learn how.


So if you have some IKEA LED strips, or anything else that requires more current than an Arduino’s output pin can offer – you can use MOSFETs to take over the current control and have fun. And finally a plug for my own store – tronixlabs.com – offering a growing range and Australia’s best value for supported hobbyist electronics from adafruit, DFRobot, Freetronics, Seeed Studio and much much more.

visit tronixlabs.com

As always, have fun and keep checking into tronixstuff.com. Why not follow things on twitterGoogle+, subscribe  for email updates or RSS using the links on the right-hand column, or join our forum – dedicated to the projects and related items on this website.

Posted in arduino, freetronics, Ikea, MOSFET, tronixlabs, tronixstuff, tutorialComments (3)

Project – LED Cube Spectrum Analyzer


A few weeks ago I was asked about creating a musical-effect display with an RGB LED cube kit from Freetronics, and with a little work this was certainly possible using the MSGEQ7 spectrum analyser IC. In this project we’ll create a small add-on PCB containing the spectrum analyser circuit and show how it can drive the RGB LED cube kit.

Freetronics CUBE4 RGB LED cube kit

Assumed knowledge

To save repeating myself, please familiarise yourself with the MSGEQ7 spectrum aanalyserIC in Chapter 48 of our Arduino tutorials. And learn more about the LED cube from our review and the product page.

You can get MSGEQ7 ICs from various sources, however they had varying results. We now recommend using the neat module from Tronixlabs.

The circuit

The LED cube already has an Arduino Leonardo-compatible built in to the main PCB, so all you need to do is build a small circuit that contains the spectrum analyzer which connects to the I/O pins on the cube PCB and also has audio input and output connections. First, consider the schematic:

MSGEQ7 CUBE4 spectrum analyser schematic

For the purposes of this project our spectrum analyser will only display the results from one channel of audio – if you want stereo, you’ll need two! And note that the strobe, reset and DCOUT pins on the MSGEQ7 are labelled with the connections to the cube PCB. Furthermore the pinouts for the MSGEQ7 don’t match the physical reality – here are the pinouts from the MSGEQ7 data sheet (.pdf):

MSGEQ7 pinouts

The circuit itself will be quite small and fit on a small amount of stripboard or veroboard. There is plenty of room underneath the cube to fit the circuit if so desired:


With a few moments you should be able to trace out your circuit to match the board type you have, remember to double-check before soldering. You will also need to connect the audio in point after the 1000 pF capacitor to a source of audio, and also pass it through so you can connect powered speakers, headphones, etc.

One method of doing so would be to cut up a male-female audio extension lead, and connect the shield to the GND of the circuit, and the signal line to the audio input on the circuit. Or if you have the parts handy and some shielded cable, just make your own input and output leads:

MSGEQ7 input output leads

Be sure to test for shorts between the signal and shield before soldering to the circuit board. When finished, you should have something neat that you can hide under the cube or elsewhere:

MSGEQ7 RGB cube LED spectrum analyzer board

Double-check your soldering for shorts and your board plan, then fit to the cube along with the audio source and speakers (etc).

Arduino Sketch

The sketch has two main functions – the first is to capture the levels from the MSGEQ7 and put the values for each frequency band into an array, and the second function is to turn on LEDs that represent the level for each band. If you’ve been paying attention you may be wondering how we can represent seven frequency bands with a 4x4x4 LED cube. Simple – by rotating the cube 45 degrees you can see seven vertical columns of LEDs:

MSGEQ7 LED cube spectrum analyzer columns

So when looking from the angle as shown above, you have seven vertical columns, each with four levels of LEDs. Thus the strength of each frequency can be broken down into four levels, and then the appropriate LEDs turned on.

After this is done for each band, all the LEDs are turned off and the process repeats. For the sake of simplicity I’ve used the cube’s Arduino library to activate the LEDs, which also makes the sketch easier to fathom. The first example sketch only uses one colour:

… and a quick video demonstration:

For a second example, we’ve used various colours:

… and the second video demonstration:

A little bit of noise comes through into the spectrum analyser, most likely due to the fact that the entire thing is unshielded. The previous prototype used the Arduino shield from the tutorial which didn’t have this problem, so if you’re keen perhaps make your own custom PCB for this project.

visit tronixlabs.com

Have fun and keep checking into tronixstuff.com. Why not follow things on twitterGoogle+, subscribe  for email updates or RSS using the links on the right-hand column, or join our forum – dedicated to the projects and related items on this website.

Posted in analyzer, arduino, com-10468, cube, freetronics, LED, MSGEQ7, projects, rgb, RGB LED, spectrum, tronixlabs, tronixstuff, tutorial

Tutorial – Arduino and the MAX7219 LED Display Driver IC

Use the Maxim MAX7219 LED display driver with Arduino in Chapter 56 of our Arduino Tutorials. The first chapter is here, the complete series is detailed here.


Sooner or later Arduino enthusiasts and beginners alike will come across the MAX7219 IC. And for good reason, it’s a simple and somewhat inexpensive method of controlling 64 LEDs in either matrix or numeric display form. Furthermore they can be chained together to control two or more units for even more LEDs. Overall – they’re a lot of fun and can also be quite useful, so let’s get started.

Here’s an example of a MAX7219 and another IC which is a functional equivalent, the AS1107 from Austria Microsystems. You might not see the AS1107 around much, but it can be cheaper – so don’t be afraid to use that instead:

MAX7219 AS1107

 At first glance you may think that it takes a lot of real estate, but it saves some as well. As mentioned earlier, the MAX7219 can completely control 64 individual LEDs – including maintaining equal brightness, and allowing you to adjust the brightness of the LEDs either with hardware or software (or both). It can refresh the LEDs at around 800 Hz, so no more flickering, uneven LED displays.

You can even switch the display off for power saving mode, and still send it data while it is off. And another good thing – when powered up, it keeps the LEDs off, so no wacky displays for the first seconds of operation. For more technical information, here is the data sheet: MAX7219.pdf. Now to put it to work for us – we’ll demonstrate using one or more 8 x 8 LED matrix displays, as well as 8 digits of 7-segment LED numbers.

Before continuing, download and install the LedControl Arduino library as it is essential for using the MAX7219.

Controlling LED matrix displays with the MAX7219

First of all, let’s examine the hardware side of things. Here is the pinout diagram for the MAX7219:

MAX7219 pinout

The MAX7219 drives eight LEDs at a time, and by rapidly switching banks of eight your eyes don’t see the changes. Wiring up a matrix is very simple – if you have a common matrix with the following schematic:

LED matrix pinoutsconnect the MAX7219 pins labelled DP, A~F to the row pins respectively, and the MAX7219 pins labelled DIG0~7 to the column pins respectively. A total example circuit with the above matrix  is as follows:

MAX7219 example LED matrix circuit

The circuit is quite straight forward, except we have a resistor between 5V and MAX7219 pin 18. The MAX7219 is a constant-current LED driver, and the value of the resistor is used to set the current flow to the LEDs. Have a look at table eleven on page eleven of the data sheet:

MAX7219 resistor tableYou’ll need to know the voltage and forward current for your LED matrix or numeric display, then match the value on the table. E.g. if you have a 2V 20 mA LED, your resistor value will be 28kΩ (the values are in kΩ). Finally, the MAX7219 serial in, load and clock pins will go to Arduino digital pins which are specified in the sketch. We’ll get to that in the moment, but before that let’s return to the matrix modules.

In the last few months there has been a proliferation of inexpensive kits that contain a MAX7219 or equivalent, and an LED matrix. These are great for experimenting with and can save you a lot of work – some examples of which are shown below:

MAX7219 LED matrix modules

At the top is an example from tronixlabs.com, and the pair on the bottom are the units from a recent kit review. We’ll use these for our demonstrations as well.

Now for the sketch. You need the following two lines at the beginning of the sketch:

The first pulls in the library, and the second line sets up an instance to control. The four parameters are as follows:

  1. the digital pin connected to pin 1 of the MAX7219 (“data in”)
  2. the digital pin connected to pin 13 of the MAX7219 (“CLK or clock”)
  3. the digital pin connected to pin 12 of the MAX7219 (“LOAD”)
  4. The number of MAX7219s connected.

If you have more than one MAX7219, connect the DOUT (“data out”) pin of the first MAX7219 to pin 1 of the second, and so on. However the CLK and LOAD pins are all connected in parallel and then back to the Arduino.

Next, two more vital functions that you’d normally put in void setup():

The first line above turns the LEDs connected to the MAX7219 on. If you set TRUE, you can send data to the MAX7219 but the LEDs will stay off. The second line adjusts the brightness of the LEDs in sixteen stages. For both of those functions (and all others from the LedControl) the first parameter is the number of the MAX7219 connected. If you have one, the parameter is zero… for two MAX7219s, it’s 1 and so on.

Finally, to turn an individual LED in the matrix on or off, use:

which turns on an LED positioned at col, row connected to MAX7219 #1. Change TRUE to FALSE to turn it off. These functions are demonstrated in the following sketch:

And a quick video of the results:

How about controlling two MAX7219s? Or more? The hardware modifications are easy – connect the serial data out pin from your first MAX7219 to the data in pin on the second (and so on), and the LOAD and CLOCK pins from the first MAX7219 connect to the second (and so on). You will of course still need the 5V, GND, resistor, capacitors etc. for the second and subsequent MAX7219.

You will also need to make a few changes in your sketch. The first is to tell it how many MAX7219s you’re using in the following line:

by replacing X with the quantity. Then whenever you’re using  a MAX7219 function, replace the (previously used) zero with the number of the MAX7219 you wish to address. They are numbered from zero upwards, with the MAX7219 directly connected to the Arduino as unit zero, then one etc. To demonstrate this, we replicate the previous example but with two MAX7219s:

And again, a quick demonstration:

Another fun use of the MAX7219 and LED matrices is to display scrolling text. For the case of simplicity we’ll use the LedControl library and the two LED matrix modules from the previous examples.

First our example sketch – it is quite long however most of this is due to defining the characters for each letter of the alphabet and so on. We’ll explain it at the other end!

The pertinent parts are at the top of the sketch – the following line sets the number of MAX7219s in the hardware:

The following can be adjusted to change the speed of text scrolling:

… then place the text to scroll in the following (for example):

Finally – to scroll the text on demand, use the following:

You can then incorporate the code into your own sketches. And a video of the example sketch in action:

Although we used the LedControl library, there are many others out there for scrolling text. One interesting example is Parola  – which is incredibly customisable.

Controlling LED numeric displays with the MAX7219

Using the MAX7219 and the LedControl library you can also drive numeric LED displays – up to eight digits from the one MAX7219. This gives you the ability to make various numeric displays that are clear to read and easy to control. When shopping around for numeric LED displays, make sure you have the common-cathode type.

Connecting numeric displays is quite simple, consider the following schematic which should appear familiar by now:

MAX7219 7-segment schematic

The schematic shows the connections for modules or groups of up to eight digits. Each digit’s A~F and dp (decimal point) anodes connect together to the MAX7219, and each digit’s cathode connects in order as well. The MAX7219 will display each digit in turn by using one cathode at a time. Of course if you want more than eight digits, connect another MAX7219 just as we did with the LED matrices previously.

The required code in the sketch is identical to the LED matrix code, however to display individual digits we use:

where A is the MAX7219 we’re using, B is the digit to use (from a possible 0 to 7), C is the digit to display (0~9… if you use 10~15 it will display A~F respectively) and D is false/true (digit on or off). You can also send basic characters such as a dash “-” with the following:

Now let’s put together an example of eight digits:

and the sketch in action:


We have only scratched the surface of what is possible with the MAX7219 and compatible parts. They’re loads of fun and quite useful as well. And finally a plug for our own store – tronixlabs.com – which along with being Australia’s #1 Adafruit distributor, also offers a growing range and Australia’s best value for supported hobbyist electronics from DFRobot, Freetronics, Seeedstudio and much much more.

visit tronixlabs.com

Posted in arduino, as1107, COM-09622, LED matrix, lesson, max7219, part review, tronixlabs, tronixstuff, tutorial

Kit Review – FriedCircuits LED Matrix Link


Time for another kit review, and in this instalment we’ve received some LED matrix modules and a matching Arduino-compatible controller board from friedcircuits.us. Behind the name is William Garrido – who some of you may know as “mobile will” from following his blog. Over time William has created a range of small and useful products, which are now available on the tindie online store.

The system comprises of two modules. The first is a small Arduino-compatible board with an ATmega328P microcontroller – the LED matrix master. It’s quite small and is designed to be the start of a chain of matching LED matrix link boards. Each of these holds an 8×8 LED matrix and is controlled by the AS1107 LED driver IC. This is a direct replacement IC for the popular MAX7219, works exactly the same and is a great find instead of using knock-off MAX7219s. You can chain up to 8 matrix modules from the one controller. We received a matrix master and two matrix link boards to examine, which arrived in solid packaging a fun Tindie sticker:



All the surface-mount soldering is done in advance, leaving you with some simple through-hole soldering for the LED matrix and the connectors between each module. The PCBs are clearly labelled with the silk screen and have mounting holes for permanent installations:

friedcircuits master module

friedcircuits matrix module rear

So after a few minutes of soldering it’s time to get the blinking on:

friedcircuits matrix modules rear

You may have noticed by now that the master board doesn’t have  a USB socket, so you’ll need a 5V FTDI cable or a USBasp programmer to upload your Arduino sketches or AVR .hex file to get things moving.

Controlling a matrix or more

As the system is basically an Arduino-compatible with one or more MAX7219-compatible modules you can find all sorts of example sketches to experiment with. If you haven’t used a MAX7219/AS1107 before there are a couple of starting points including the Arduino library and another random tutorial. Using an example sketch on the Arduino forum by member “danigom“, and after checking the data, clock and load pins it was ready to go. Here’s the sketch for your consideration: