How To Make a Pulsating Arduino LED Cube That Looks Like It Came From The Future

arduino frequency ledIf you’ve dabbled with some beginner Arduino projects, but are looking for something a little permanent and on a whole other level of awesome, then the humble 4 x 4 x 4 LED cube is a natural choice. Construction is far easier than you might think, and using a multiplexing we can control all the LEDs directly from just a single Arduino Uno board. It’s great soldering practice, and the total cost of components shouldn’t come to more than about $40.

Today I’ll be thoroughly detailing the construction side of things, and providing some software to run on it that both looks impressive and teaches you the basics.

You Will Need

  • An Arduino. The code supplied assumes an Arduino Uno, but could be adjusted to a larger model too.
  • 64 LEDs – the exact choice is up to you, but I used these superbright 3mm Blue LEDs (3.2v 30ma) @ £2.64 for 50.
  • 16 Resistors of the appropriate value for your LEDs. For the LEDs above, 99 pence bought 100 of these. Use ledcalc.com – enter 5v for the supply voltage, the voltage of the LEDs (in my case 3.2) and the current in milliamps (3.2). Your desired resistor will be shown in the box labelled “Nearest higher rated resistor”, then just search for that value on eBay.
  • Some craft wire to strengthen basic structure and for decoration – I used 0.8mm thickness.
  • A prototyping board of some type that you can solder all your bits to. I used one which didn’t have full tracks along it as I don’t have a track cutter, but use whatever suits you. An Arduino prototyping shield is a little too small though, unless you really squeeze your LEDs together.
  • Random component wire – some network cable strands and some of the prototyping wires from a kit will work fine.
  • Crocodile clips or “helping hands” are useful for holding bits in place.
  • Soldering iron, and solder.
  • Some scrap wood.
  • A drill, with the same size bit as your LEDs.

Note: the 3D drawings in this tutorial were done in minutes using TinkerCAD. I followed an existing build detailed on Instructables by user forte1994, which you might also want to read through before attempting this. 

Make sure to read through all these instructions first before attempting this for yourself.

The Principle Of This Design

Before you begin construction, it’s important to have an complete overview of how this thing is going to work so you can improvise and identify errors as you go along. Some LED cubes use a single output pin for every single LED – however in a 4x4x4 cube, that would need 64 pins – which we certainly don’t have on an Arduino Uno. One solution would be to use shift registers, but this is unnecessarily complicated.

In order to control all those LEDs in just 20 pins, we’ll be using a technique called multiplexing. By breaking the cube down into 4 separate layers, we only need control pins for 16 LEDs – so to light a specific LED, we must activate both the layer, and the control pin, giving us a total requirement of 16+4 pins. Each layer has a common cathode – the negative part of the circuit – so all the negative legs are joined together, and connected to a single pin for that layer.

On the anode (positive) side, each LED will be connected to the corresponding LED in the layer above and below it. Essentially, we have 16 columns of the positive legs, and 4 layers of the negative. Here’s some 3D views of the connections to help you understand:

arduino frequency led

arduino led light program

Construction

Since we won’t be using a full metal structure to solder to, we want all the legs of the LEDs to overlap by about a quarter and give rigidity to the structure. Fold the cathode of your LEDs – the side with the flat notch in the head and the shorter leg – over as shown in the diagram. (It doesn’t really matter if you bend it left or right, so long as you’re consistent and it never touches the anode)

arduino led light program

The first critical part of this project is making a wooden jig. This will hold a layer of LEDs while you solder the legs together, so it needs to be accurate and not too loose. Using the same size drill bit as your LEDs, measure out and then drill a 4×4 matrix of equidistant holes. Bear in mind that you want about a quarter of the leg to overlap with its neighbour, and do use an actual ruler. Check each hole to ensure an LED can fit snugly , but not so tight that you won’t be able to get it out again, or you’ll have problems when trying to remove a fully soldered layer.

arduino led light program

Solder the cathodes of 4 rows of LEDs. Be careful not to burn out the LEDs – you want a good hot iron, and to be in and out. Here’s my first four rows completed.

arduino led

Now, to strengthen the rigidity of the layer, cut and solder two straight bits of craft wire to either end, making sure they connect with each row. This is your first layer complete. Leave all excess legs sticking out at the side for now.

Now would be a great time to test – just load up the default Arduino blink app, and with a resistor connected, put the ground to the layer frame, and press the positive lead to each LED in turn.

arduino led

Hopefully, they will all light up. If not, make sure you haven’t just missed a solder joint somewhere, and if neccessary replace the LED.

Remove that layer from the jig, and repeat the process 3 more times.

Don’t worry if your soldering isn’t perfect – as long it’s not going to break and the connection is solid, it won’t affect the final product. I admit, my soldering was pretty hopeless, my jig was off, and it all resembled the leaning tower of Pisa. Still, I’m proud of the finished cube, and when the LEDs are lit you aren’t going to be looking at the solder joints anyway!

Joining Layers

Once you have 4 completed layers, you’ll want to join all the vertical legs together. I found this to be the hardest part of the build, and to aid the process I cut a riser out of card.

arduino led

This kept the layers at the appropriate height, but a lot of the legs still wouldn’t align perfectly – for this, I used some crocodile clips to hold them in place.

1st Silly Mistake To Avoid

Only after completing a full layer did I realise my card riser was stuck in place, so I had to cut it out! Don’t make the same mistake I did – make the riser longer on the side, and join the pieces of card outside of the cube, so when you’ve completed the layer, you can deconstruct the riser and pull out the card.

2nd Silly Mistake To Avoid

Don’t solder the vertical leg to the cathode frame, obviously. Vertical legs should only connect to other vertical legs, and nothing else.

Again, test after each layer has been attached. Test all the layers, in fact, only touching the positive lead to the tip of the uppermost layer, thereby ensuring you’ve got good contact going through all layers.

When all 4 layers were soldered together, I set about cleaning up a bit – I left one single leg extended out of each layer in a kind of stepping stone fashion – this would be dropped down to the board later. Other extraneous bits of metal frame and legs were cut off. Obviously, don’t cut any of the vertical legs – we need to put these into our protoytping board.

Fixing To The Board

Remember when I said fixing each layer to itself was the hardest part? I lied. Trying to fit 16 LED legs into tiny holes on a prototyping board is actually harder. The easiest way I found was to poke through 4 at a time, secure them underneath with crocodile clips, then move on to the next row of 4. Use a marker pen to mark out spacing in advance if it helps.

In retrospect, I would have placed the resistors into the protoboard first, actually. As it is, I soldered all the legs of the cube into the board first, then tried to delicately squeeze resistors in between each one. Learn from my mistake, and place your resistors first.

I tried to space them equally in a stepping fashion so then I could use one entire side of the cube for all the final connections to the Arduino. Here’s the circuit diagram I went with:

For the four negative layers, I dropped a single wire down from each layer, then just pulled them off to the side, like this:

Finally, I added some plug wires that I could then place into the relevant Arduino pins. Use the longest kind you have. Note I messed the order up in places due to poor planning. Each row of LEDs was colour coded though.

That’s it. Finished!

Programming Your Cube

I know you can’t wait to get this thing fired up, so plug the 4 negative layers into Analog I/O ports A2 (bottom layer) through A5 (top layer) (these can also act as digital I/O). Then plug in the 16 LED control pins, starting with +1 on the far right to digital I/O port 0, with +15 and +16 going into analog A0 and A1. (Don’t use AREF and GND)

arduino frequency led

Download the demo patterns and code from instructable user forte1994. He’s also provided a helpful online tool for designing the byte patterns to customize your own sequence. Here’s a video of this code in action on my cube (I adjusted the speed to 5, instead of the default 20).

This isn’t the only way to program your cube, of course, so let me spend a few minutes teaching you the very basics of making your own patterns programmatically, rather than playing back preset patterns as the above demo does.

There are a few things you should know when attempting to program your cube:

  1. To address a single LED, you use a plane (layer) number 0–3, and a LED pin number 0–15. Turn the plane to LOW output (since this is the negative leg) and the LED pin number HIGH (the positive leg) to activate the LED.
  2. Before activiting a single LED, ensure all other planes are off – that means set them to HIGH output. Failure to do this will results in a column of LEDs being lit rather than a single LED.

With that in mind, I’ve made two very simple programmatic sequences for you to examine – download the code from here. The first simply lights every LED one by one, in sequence. We use two for loops for this, iterating over each layer and each control pin.

The second is a random loop (you’ll need to comment out the first and enable this in the main loop to test it). It simply picks a random layer, and random control pin, flashing them on and off.

Summary

Don’t be intimiated by this build – I’m seriously lacking soldering skills, and I managed this alright (I think?). The total build time was an hour or so a day for a week. Next time, I’ll be attempting to teach you some more ambitious programming for the cube, so I hope you’ll join me in building your own cube this week and loading some new code on next week – and if you do make your own awesome apps or sequences, please upload them to Pastebin and let us know in the comments!

More articles about:

13 Comments

James Bruce

James is a keen gamer with a passion for the iPad, and records Technophilia - an awesome but somewhat NSFW technology podcast - weekly with Justin and Dave.

The comments were closed because the article is more than 180 days old.

If you have any questions related to stuff mentioned in the article or need help with any computer issue, just ask it on MakeUseOf Answers.

Hide 13 Comments

  • denny Gl July 26, 2012
    0 likes

    thanks james for the arduino tutorial.just ordered my arduino with 6 servos hope to make something cool

    | Like
  • UD98 July 26, 2012
    0 likes

    thanks will have to do that

    | Like
  • Shakirah Faleh Lai July 26, 2012
    0 likes

    A fun project to be enjoy on weekend.

    | Like
  • Derrick September 5, 2012
    1 like

    Made this cube this weekend! Works great. Still trying to learn the code. I am also looking to use Shift registers to this design. I have added a few RGB led’s as background lighting on a separate circuit with a transistor and a photo sensor. Thanks so much for the excellent diagram instructions!

    | Like
  • Isaac October 12, 2012
    0 likes

    I love it! Other tutorials I have use additional power sources. Am I correct in assuming that those wires connect directly into the arduino which has one power supply? Thanks in advance

    | Like
    • muotechguy October 12, 2012
      1 like

      Yep. Multiplexing requires control of both the power and the signal lines, mixing them to together in order to turn things on; therefore, it has to come from the arduino. On this scale, should be fine, but I think a huge LED cube would draw too much power perhaps (or be not very bright when they’re all on)

      | Like
  • Robert November 14, 2012
    0 likes

    Hi, Ive been looking at making a 4x4x4 and trying to find the best guide. so far this is it.

    I am wondering though, your guide lacks Transistors with resistors for the negative layers compared to other guides. Is there a particular reason?

    Excuse my ignorance, First time playing with electronics.

    | Like
    • Muo TechGuy November 14, 2012
      1 like

      No problem Robert; transistors would be used in the case of an external power supply I believe to prevent shorting the control chip out – if you’re using the Arduino and schematics here, definitely not needed.

      | Like
  • Andras December 28, 2012
    1 like

    Hi! Thanks for this excellent tutorial. One of the best out there! I do have a question though. I don’t understand how the layers are aligned with the LEDs exactly above each other. I mean, you can’t put two LEDs exactly above each other because the vertical leg of the LED above can’t go through the head of the LED below. And still it seems there is a way to do it. How? Could you publish a close-up picture or some text explanation for this? Thank you!

    | Like
    • Muo TechGuy December 28, 2012
      0 likes

      Hi Andras – you’re right, they don’t perfectly align as such, but the difference is so small – at least on the 3mm LEDs I was using. Most will line up anyway, but if one isn’t lining up nicely then just use crocodile clips to hold it in place while you solder it.

      | Like
      • Andras December 29, 2012
        0 likes

        Hi again!

        I have just realized that I need some wire-like stuff to strengthen the layers, to connect all cathodes in a layer together, some wire which is similar to the LED pins. You call it craft wire. Is there another name for this stuff? I tried to find some on eBay, but I’m not sure what I’m looking for exactly. Any idea where I could find such wire-like stuff? Do they sell it in long stings or rolled up? Thank you!

        | Like