18
Make your own 4x4x4 LED cube with an Arduino Uno Part List I’ll break this section down into two parts, the components that you’ll need to make the cube, and the tools that you’ll use to do it. The component list is pretty much fixed, with a few exceptions, but don’t feel restricted by the tools list, if you can think of a better way of doing something then by all means do it that way. Components: My cubes are made with parts ordered almost exclusively from eBay (because it’s cheaper to buy stuff from the Far East than it is from my local electronics store). Of course, you can order from your local store if you’re in a hurry, but to be honest you’re not going to get “better” components than if you order from Hong Kong. LEDs (Light Emitting Diodes) These are the core of your cube, you’ll need 64 of them to make it, but you’ll probably find it cheaper to order a batch of 100. This will also give you some spares in case you have any duff ones, or damage any during construction. Standard LED sizes are 5mm and 3mm. I’d tend to stick with 3mm as it allows you to see more of the inner workings of your cube (5’s can obstruct your view of what’s behind them). You can get them in a variety of colours, but one thing you might want to consider is buying “diffused” LEDs. Diffused LEDs shine light evenly in all directions, whereas traditional ones shove most of their light out the top. You’ll get very different effects depending on which type you use. There’s no right answer, it’s completely your choice. Jewellers wire Or something similar. What you’re looking for is some solid core, uninsulated wire that can be used to join our LEDs together into grids of 4×4. Typing “jewellery wire” into eBay should yield some suitable wire. I use silver plated copper wire, but any conductive metal that matches the colour of your LED legs will do just fine.

Make your own 4x4x4 LED cube with an Arduino Unoblog.portalpositivo.com.br/fisica_faat/files/2015/06/led-cube-4x4x4... · Make your own 4x4x4 LED cube with an Arduino Uno Part List

  • Upload
    others

  • View
    24

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Make your own 4x4x4 LED cube with an Arduino Unoblog.portalpositivo.com.br/fisica_faat/files/2015/06/led-cube-4x4x4... · Make your own 4x4x4 LED cube with an Arduino Uno Part List

Make your own 4x4x4 LED cube with an Arduino Uno

Part List

I’ll break this section down into two parts, the components that you’ll need to make the cube,

and the tools that you’ll use to do it.

The component list is pretty much fixed, with a few exceptions, but don’t feel restricted by the

tools list, if you can think of a better way of doing something then by all means do it that way.

Components:

My cubes are made with parts ordered almost exclusively from eBay (because it’s cheaper to buy

stuff from the Far East than it is from my local electronics store). Of course, you can order from

your local store if you’re in a hurry, but to be honest you’re not going to get “better” components

than if you order from Hong Kong.

LEDs (Light Emitting Diodes)

These are the core of your cube, you’ll need 64 of them to make it, but you’ll probably find it

cheaper to order a batch of 100. This will also give you some spares in case you have any duff

ones, or damage any during construction.

Standard LED sizes are 5mm and 3mm. I’d tend to stick with 3mm as it allows you to see more of

the inner workings of your cube (5’s can obstruct your view of what’s behind them). You can get

them in a variety of colours, but one thing you might want to consider is buying “diffused” LEDs.

Diffused LEDs shine light evenly in all directions, whereas traditional ones shove most of their

light out the top. You’ll get very different effects depending on which type you use. There’s no

right answer, it’s completely your choice.

Jewellers wire

Or something similar. What you’re looking for is some solid core, uninsulated wire that can be

used to join our LEDs together into grids of 4×4. Typing “jewellery wire” into eBay should yield

some suitable wire. I use silver plated copper wire, but any conductive metal that matches the

colour of your LED legs will do just fine.

Page 2: Make your own 4x4x4 LED cube with an Arduino Unoblog.portalpositivo.com.br/fisica_faat/files/2015/06/led-cube-4x4x4... · Make your own 4x4x4 LED cube with an Arduino Uno Part List

Resistors

You’ll need 16 resistors to protect your LEDs from blowing when connected to your Arduino

board. The actual value of your resistor will depend on the specifications of your LEDs, which

should be provided by the retailer.

Use an online checker to confirm the value of resistor that you should use.

For most 3mm LEDs, 100Ω or 330Ω (Ohms) should be sufficient. 330Ω is a very common resistor

value, so you should be able to pick up a ream of them cheaply.

We’re dealing with quite low power circuits here, so you should be ok with resistors rated at

0.25W (watts).

Arduino Uno board (or compatible)

The core of this project will be an Arduino Uno micro-controller board. The Uno is one of the

more popular Arduino boards, and suits this project down to the ground. The “official” version

can be bought from major retailers like RS Components, but you can also buy compatible boards

on eBay for a fraction of the cost.

In my experience, the “compatible” boards work fine for this project.

There’s nothing sinister about these boards, Arduino is an open-source platform. In other words,

any company can produce boards that are compatible with the Arduino software.

In this project I use a “Arduino Uno Ver 3″ compatible board, which I recommend you do too.

Jumper wires

Get these either as a ribbon cable or as individual strands, it doesn’t matter. You’ll need 20 cores

and I recommend getting them around 20cm long so that you have room to make all the

connections before you close the lid on your enclosure.

Don’t worry if it’s all in one ribbon, you’re going to be breaking it into parts to make things easier

for yourself.

It’s also a good idea to get multicoloured ones, so that you can colour code your design, which

will make it easier to plug the right wires into the right place. For my first cube, I used all red

wires, and it was a nightmare to connect everything up correctly.

Prototyping board

Sometimes called Veroboard or Stripboard. This is a great way to quickly make electronic circuits

without going to the effort of having a proper PCB (Printed Circuit Board) made up.

Page 3: Make your own 4x4x4 LED cube with an Arduino Unoblog.portalpositivo.com.br/fisica_faat/files/2015/06/led-cube-4x4x4... · Make your own 4x4x4 LED cube with an Arduino Uno Part List

The type that you want has common strips, which is great for connecting components together

without the need for wires.

In this project we’re going to use it to hold the LED array in place, and also to put our resistors in

line before soldering on the jumper wires which connect to the Arduino.

Some form of case

In this instance I use a black ABS plastic case from Maplin, but any case will do. Just so long as it’s

around 40mm deep (room for the Arduino + jumper wires) and big enough for the Cube to site

on top of.

Of course, you may have something else in mind. You might be fabricating your cube onto an

existing surface, or putting the cube inside a more complex project. But, if you want a standalone

unit then you’ll need a case.

For reference, the one I use is around 120mm x 100mm x 40mm.

Tools and equipment

You’re going to need to get a few bits and pieces together in order to complete this project. Some

of them are optional and you can do without, but I strongly recommend that you make use of all

of the tools mentioned here:

Soldering iron / gun (+ solder)

Thin nose pliers (two pairs)

Wire cutters / strippers

Small saw

Hand drill / electric drill

3mm / 5mm drill bit (depending on your LED size)

1.5mm drill bit

Set square

Ruler / measuring tape

Masking tape

De-soldering tool

An electric detailing tool

Page 4: Make your own 4x4x4 LED cube with an Arduino Unoblog.portalpositivo.com.br/fisica_faat/files/2015/06/led-cube-4x4x4... · Make your own 4x4x4 LED cube with an Arduino Uno Part List

Once you’ve gotten all of this together you’re ready to build your cube from start to finish, so

take a deep breath and click on the next page to see how the cube is put together.

Constructing a former

The cube is made up of 4 layers which are each made up of 16 LEDs in a square configuration, so

the first step is to put together four identical layers which will be soldered together later.

The layers are made by bending the cathodes (short legs) of the LEDs by 90 degrees and then

soldering them all together to form a common cathode. You’re then left with one common

cathode and 16 individual anodes (long legs) per layer.

If you try and construct the layers by hand you’re going to have a really bad time, so the first thing

to do is make a former which will then be used to space out the LEDs evenly.

Before you can make your former, you need to know how far apart to space the holes, and the

easiest way to do that is to work out how long the cathodes are when bent.

Most LEDs have a little nub on the legs about 3mm from the LED body. It’s designed to provide

a good base for soldering, but it’s also an excellent way to make sure you bend each LED at the

same point.

My advice would be to make the bend just before the nub, which came out at about 23mm on

the LEDs I’m using.

If you want, you can bend the cathodes flat against the base of the LED, which will give you greater

distance between them, but will also increase the possibility of damaging the LEDs while soldering

them together.

Page 5: Make your own 4x4x4 LED cube with an Arduino Unoblog.portalpositivo.com.br/fisica_faat/files/2015/06/led-cube-4x4x4... · Make your own 4x4x4 LED cube with an Arduino Uno Part List

The distance between your LEDs needs to be just a tiny bit smaller than the length of the bent

cathode, so that you’ve got some overlap to solder the cathodes together. But it doesn’t need to

be any more than a 1mm overlap.

Now that you have this measurement, you can space out the holes in your former. I tend to

scribble down the sums on a piece of masking tape, that way the measurements are available if

you forget.

The easiest thing to do is use the lid of your box, and I’m going to assume that’s what you’re

doing, but if you can’t do that then just use a piece of scrap wood.

Use some masking tape to cover the surface of the box, this will protect from pen marks and

flux/solder.

Next, use a set square and ruler to mark out grid lines on your box.

Then, take a 3mm or 5mm drill bit (depending on your LED size) and drill out the 16 holes for your

LEDs.

Page 6: Make your own 4x4x4 LED cube with an Arduino Unoblog.portalpositivo.com.br/fisica_faat/files/2015/06/led-cube-4x4x4... · Make your own 4x4x4 LED cube with an Arduino Uno Part List

Finally, at one end of the grid, drill four 1.5mm holes inside the gridlines as shown in the photo

below. These extra holes will be used to connect the four common cathodes to the Arduino using

strands of jewellers wire. You can drill these holes wherever you want, but it’s a lot easier to

solder the strands of wire if they’re near the edge of your cube.

Your former is now complete, next stage, soldering together LEDs!

Creating the LED layers

As mentioned previously, your cube will be made of four identical layers, each with 16 LEDs, so

you’ll need to follow the steps on this page four times in order to create enough layers for your

cube.

The first thing that you need to do is a bit tediuos and boring, but it’s definitely worth doing. You

need to test all 64 of your LEDs.

As with all things in life, you’ll occasionally get a lemon, and it’s better to find out you have one

now rather than waiting until it’s in the middle of your cube.

Not to fear though, there are two really easy ways to test LEDs.

Firstly you can get a CR2032 coin cell (like in a car remote keyfob) and press the legs of the LED

against either side of it. Do it the right way round and your LED should light up, do this 64 times

and you’re done.

Or, you can use the “Blink” program on your Arduino board and then connect your LEDs one by

one across pin 13 and the ground pin. I recommend doing it this way as it’s easier to test your

LEDs once they’re soldered into a cube.

Page 7: Make your own 4x4x4 LED cube with an Arduino Unoblog.portalpositivo.com.br/fisica_faat/files/2015/06/led-cube-4x4x4... · Make your own 4x4x4 LED cube with an Arduino Uno Part List

Once your LEDs are all known working, you’ll need to bend the cathode legs of all 64. You’ve

worked out where you’re going to bend the leg on the previous page. You need to bend to a 90

degree angle, it doesn’t matter which way as long as they are all the same, but don’t bend so that

the bent cathode is in line with the anode, otherwise you won’t be able to solder the cathodes

together.

Once you’ve bent all the legs, lay four of the LEDs into your former as shown below.

If you’ve done it correctly, you should find that the cathodes line up nicely with a small overlap

for soldering them together.

Page 8: Make your own 4x4x4 LED cube with an Arduino Unoblog.portalpositivo.com.br/fisica_faat/files/2015/06/led-cube-4x4x4... · Make your own 4x4x4 LED cube with an Arduino Uno Part List

Solder the cathodes together using as little contact and as little solder as you can. Remember,

more solder doesn’t equal a stronger join, it can actually cause a less conductive join which will

cause you problems later on.

Repeat for another three rows of LEDs, filling the former.

Now you’ll need to use the jewellers wire to connect the four rows together into a layer.

Quick tip on the wire; it was probably delivered on a spool so will have some bends and curves to

it. To get rid of these quickly, cut a length of wire and then hold it at either end with the pliers. pull

hard on either end and you’ll feel the wire stretch slightly. This will get the wire 99% straight. If

you manage to snap the wire, try again but don’t pull so hard, you beast ;-)

Page 9: Make your own 4x4x4 LED cube with an Arduino Unoblog.portalpositivo.com.br/fisica_faat/files/2015/06/led-cube-4x4x4... · Make your own 4x4x4 LED cube with an Arduino Uno Part List

You could use four strips of wire per layer, but you really only need two – one after the first strip

of LEDs and a second just before the last strip of LEDs. You could put them elsewhere, but doing

it like this will give the greatest illusion of a joined up cube.

Solder the jewellers wire to the cathodes (horizontal), this will give you one common cathode and

16 individual anodes.

Make sure that you snip off any excess wire hanging over the edge of your cube, you can also snip

off the four protruding cathode legs that stick out of the edge of the layer.

Page 10: Make your own 4x4x4 LED cube with an Arduino Unoblog.portalpositivo.com.br/fisica_faat/files/2015/06/led-cube-4x4x4... · Make your own 4x4x4 LED cube with an Arduino Uno Part List

Now carefully remove the LEDs from the former and repeat three more times to give four

individual layers.

Soldering the layers together

Now that you have your four individual layers, it’s just a case of soldering them together to form

a cube.

we’re going to do this by joining the 16 anodes of each layer together so that we’re left with 16

common anodes and 4 common cathodes.

The first thing to do is bend the last 1mm of each anode toward the center of the LED, this will

help us join the layers together as it means the anode can run down the side of the LED below

and tuck back in to join up with the anode below. You only have to do this with three of your

layers, as the fourth layer will be on the bottom and won’t be connecting to another LED.

Page 11: Make your own 4x4x4 LED cube with an Arduino Unoblog.portalpositivo.com.br/fisica_faat/files/2015/06/led-cube-4x4x4... · Make your own 4x4x4 LED cube with an Arduino Uno Part List

The next thing to do is make sure that all of the anodes legs are pointing straight up. This will

make it easier to solder the layers together, and the end result will look more “square” as well. If

any legs aren’t quite there, just give them a gentle prod near the base to get them pointing in the

right direction. If you push from the tip of the leg then you might bend the leg, which will make

the problem worse.

Once you’ve bent the legs, put one layer back in the former.

From here there are two ways to complete the task:

1) You can create some cardboard formers that will ensure the correct distance between layers,

then lower another layer on top of the first and solder the anodes. This works just fine but is time

consuming and can be a bit tricky.

2) You can do it by eye.

I’ve never bothered with formers on my cubes, I just take my time and hope for the best, but by

all means use some strips of card if you’re not sure.

Which ever way you choose, my advise is to solder the corner anodes together first. After you’ve

done the corners, take a step back and look at the layers; are they parallel? If not, de-solder

whichever corner is out of alignment and move it into the correct position. Once you’re happy

with the alignment, solder together the rest of the legs.

I would always advise that you re-check the connections using the “Blink” program and some

jumper wires between layers. Not only will this test your solder joints, but it’ll also check that

none of the LEDs have been damaged by the heat.

Repeat this for the remaining two layers and your cube will be complete.

Page 12: Make your own 4x4x4 LED cube with an Arduino Unoblog.portalpositivo.com.br/fisica_faat/files/2015/06/led-cube-4x4x4... · Make your own 4x4x4 LED cube with an Arduino Uno Part List

Fabricating and Circuitry

If you’ve used your case as your former then you should be able to flip the cube over and drop

the protruding anodes into the holes. If you’ve used a different surface as your former, you’ll

need to get the drill back out and drill holes in your case using the same measurements.

Either way, you should be left with 16 pins poking through a surface.

The next thing you’ll need to do is put in some uprights to connect the four cathode layers to the

Arduino, and that’s where the four tiny holes you drilled in the former come into play.

Run four pieces of (straightened) wire through from the inside of your case to the cube. Bend

the end of each wire to a 90 degree angle with pliers, then solder one of the wires to each of the

four layers. It doesn’t really matter where as the layers are electrically common, just try and make

it look nice.

Now you’ll have 16 anode wires and 4 cathode wires poking through the underside of your case.

The basic circuitry from here goes:

LED anode –> Resistor –> wire –> Arduino board.

LED Cathode –>Arduino Uno

How you achieve that will be up to you, and it will depend on what type of case you’re using. I

would recommend using prototyping board, but there’s actually nothing to stop you just

soldering the components together and wrapping them in insulating tape. But, using prototyping

board will always give a stronger connection, and you can also use it to hold the LED cube in place.

Page 13: Make your own 4x4x4 LED cube with an Arduino Unoblog.portalpositivo.com.br/fisica_faat/files/2015/06/led-cube-4x4x4... · Make your own 4x4x4 LED cube with an Arduino Uno Part List

In my cubes, I tend to cut up strips of prototyping board and soldering the LED anodes to

that. There’s no need to cut any of the tracks as the LED leg will connect to the same rail as one

side of the resistor, and the jumper wire to the Arduino will connect to the rail on the other side

of the resistor.

Doing it my way means four resistors and four jumper wires per piece of board.

You can do it all on one piece of prototyping board, but try and push 20 LED pins through a single

piece of board at the same time and you’ll see why my way is just as good.

I digress. Whichever way you choose, just make sure that each anode is connected to a

resistor. You don’t need resistors on the four cathode layers.

Page 14: Make your own 4x4x4 LED cube with an Arduino Unoblog.portalpositivo.com.br/fisica_faat/files/2015/06/led-cube-4x4x4... · Make your own 4x4x4 LED cube with an Arduino Uno Part List

Once your LED cube is fixed to the board (or at least connected up as above), you’ll need to

connect your jumper wires to it.

The process is the same whether you’re using individual strands or a ribbon. I recommend using

wires of around 20cm in length, as this will give you enough room to connect everything to the

Arduino without obstructing yourself.

Once you’ve soldered the wires to the 16 anodes and 4 cathodes, it’s time to connect them up to

the Arduino. You need to connect each wire to the correct port on the Arduino for the program

to work, so check the diagram below which shows the LED cube as viewed from the top.

Connect up the jumper wires to the Arduino and the circuit is complete.

Of course, you’re going to need to find a place to put the Arduino board inside your case (and

make a hole in the side for the power connector), but before you do that it’s a good idea to check

that everything is working.

Click on to the next page and I’ll take you through the programming aspect of the cube.

Programming the Arduino

The Arduino needs to be programmed so that it knows what to do with each of the various

connections on the board.

Page 15: Make your own 4x4x4 LED cube with an Arduino Unoblog.portalpositivo.com.br/fisica_faat/files/2015/06/led-cube-4x4x4... · Make your own 4x4x4 LED cube with an Arduino Uno Part List

To do that you’ll need to download the Arduino software and install it on your PC. Then follow

this user guide to connect up your Arduino and install the drivers on your PC.

If you just want to get your cube working, then the easiest thing to do is just download my code

from here. This gives you a program that lasts about 30 seconds and loops round over and over.

Once you’ve downloaded the code, open up the Arduino software and click File–>Open. Navigate

to the code you downloaded and open it. Then click the “upload” button at the top of the

window.

If the animations don’t appear correctly, you may have mixed up some of the pins on the Arduino,

so disconnect it and double check. Once you’re positive everything is in the right place, plug it

back in and the animations should display properly.

If you’re happy with that, and everything’s working, then congratulations; you’re done! click

through to the next page and finish up your project!

If you want to make your own animations, read on and I’ll explain how it works.

So, when you opened the code in the Arduino software, you may have noticed the large block of

code in the middle that looked a bit like this.

Don’t worry too much about anything else on the page, just focus on the large block of code in

the middle, as this is what’s causing the patterns on the cube.

Page 16: Make your own 4x4x4 LED cube with an Arduino Unoblog.portalpositivo.com.br/fisica_faat/files/2015/06/led-cube-4x4x4... · Make your own 4x4x4 LED cube with an Arduino Uno Part List

The easiest way to think of it is as an animation. Each change on the cube represents a frame of

animation, and each line of code represents one frame.

In each line there are 64 1’s and 0’s, split into 16 blocks. If there is a 1 then that signifies that an

LED is to be lit in that frame, if there’s a 0 then it won’t be.

The first block represents the four LEDs on the bottom row on the left hand side.

The second block represents the four LEDs on the bottom row, to the right of the ones in the first

block, and so on.

Within each block, the 1st number represents the furthest LED away from you, the 4th number

represents the LED closest to you.

The number at the end of the line indicates how long that frame will last for. Make the number

higher and the frame will last longer. Make it lower and the frame will last less time.

So, in this way, you can indicate which LEDs will be on and off during each frame of the animation.

If you’re not entirely sure what I’m getting at, here’s a tip: Delete all but the first line of the

animation, then change all the values to “0” except for the first one, then hit upload.

You should find that the LED on the bottom row, on the left hand side, at the back will light up. Of

course, it all depends on which side you’re sat on.

Try changing some other values to “1” and see where it gets you, you should be able to work out

quite quickly how the system works.

Now, it’s simply a case of writing multiple rows to give you more frames of animation. You can

literally turn each LED on and off independently of the others.

Try coming up with your own animations, my advice is to use comments to give yourself a

reminder of what each animation does. You can type a comment into the program by typing “//”

and then the comment.

The Arduino will ignore any text that is after the “//” so you can type anything you want in there.

You can literally spend hours of your life coming up with new patterns, so before you get too

engrossed, lets finish off the build and then you can get back to this part.

Power and finishing off

Providing the programs displayed correctly on the previous page, you just need to fabricate

everything inside your case and you’re done.

The Arduino board can be powered from either a traditional DC power supply (sold separately)

or a USB cable connected to a PC, TV, or even a USB phone charger.

I recommend using the USB connection as it means you can connect the cube to almost anything

that has a USB socket.

Page 17: Make your own 4x4x4 LED cube with an Arduino Unoblog.portalpositivo.com.br/fisica_faat/files/2015/06/led-cube-4x4x4... · Make your own 4x4x4 LED cube with an Arduino Uno Part List

You only need one or the other, not both.

Whichever you use, you’ll need to cut a hole in the side of your case for the socket to poke

through. If you’re using the DC jack then just drill a suitably sized hole, but if you’re using going

to use the USB connector you’ll need to use a detailing tool to cut an appropriately sized hole.

Once you’ve made the hole, check that the board sits nicely and that you can close the lid on your

case without any trouble.

Providing you can, bust out the silicone adhesive and go wild.

Seriously, this stuff is completely inert, you can apply it to almost anything without any risk of a

chemical reaction.

Page 18: Make your own 4x4x4 LED cube with an Arduino Unoblog.portalpositivo.com.br/fisica_faat/files/2015/06/led-cube-4x4x4... · Make your own 4x4x4 LED cube with an Arduino Uno Part List

You’ll need one big dollop under the Arduino board, which will hold it in place inside the case. You

should also apply some where the jumper cables connect to the Arduino, to hold them in place.

You could also apply some to the prototyping board if you want to, but it’s not really necessary.

The silicone will take about an hour to cure, so leave it be for a while. Once it’s dry to the touch,

you just need to put the lid on, screw the case together, and we’re done!

Hopefully this guide has given you some ideas about how you can make your own cube. To be

honest, providing the circuit stays the same as this one, you can move the LEDs around into

whatever pattern you want.

In this way, it’d be really easy to arrange the 64 LEDs into a single sheet pattern for other lighting

effects.

My advice would be to take your time. This guide is not the only one on the Internet that takes

you through this exact process, so if you’re not sure about anything in this particular walkthrough,

have a look on Google for other walkthroughs that present the information in a different manner,

chances are we’re all using the same circuitry and code.

Finally, if anyone’s got any questions, drop them to me in the comments below!

http://www.techmadeeasy.co.uk/2013/01/21/make-your-own-

4x4x4-led-cube-with-an-arduino/2/