LED Cube and Arduino Lib

 by gzip
Featured
There are other Instructables about building LED cubes, this one is different for several reasons:

1. It's built with a low number of off-the-shelf components and hooks up directly to the Arduino.
2. A clear, easy to reproduce circuit diagram is provided with plenty of photos.
3. A unique approach is used for the software which makes programming the cube easier and more expressive.

Parts needed:

-   1 Perfboard
-   3 NPN Transistors (2N2222, 2N3904, BC547, etc.)
- 12 Resistors (~220 ohms and ~10k ohms)
- 13 Headers (male or female)
- 27 LEDs
- Wire





 
Remove these adsRemove these ads by Signing Up

Step 1: Prepare the LEDs

This step largely follows the LED Cube 4x4x4 but we'll be building a 3x3x3 cube instead. A cube of this size is about as big as it gets without introducing additional circuitry and complexity. We'll need a total of 27 LEDs that will be grouped into three sets of nine.

Each set of nine LEDs will share a common connection amongst their cathodes (negative leads). I'll refer to each of these sets as a "level". Each of the nine LEDs on a level is connected to the corresponding LED on the other two levels through their anodes (positive leads). These will be referred to as "columns". If that didn't make sense it will become self explanatory as we build the cube.

To start we'll use a drill to create a jig out of a small piece of scrap wood. The jig will hold the LEDs in place while we solder them. I decided to space the holes around 5/8 of an inch apart (~15 mm) but the exact distance isn't critical. The hole should have a tight fit around the LED since we don't want them to move around while soldering.

Once the jig is done we're going to bend the cathode of each LED in a 90 degree angle. The cathode is identifiable in three ways: 1) It's the shorter leg, 2) It's on the flat side of a round LED, 3) it's connected to the larger piece inside the LED. Make sure you bend the cathode in the same direction for all of the LEDs.

Now we're ready to begin soldering.
1-40 of 188Next »
ironheartbj18 says: May 19, 2013. 2:59 PM
download gzip frist then unzip file attached to any verison arduino/libraries click extract all file after that then you will have to same thing file as EEPROM, ENTERNET, etc. for example go to eeprom there have four file which are eeprom.h, eeprom cpp, keyboard.txt, and example that are in your in your sketch already it will showing orange letter. the ledcube does not name a type because it does not exist in your libraries. so you will have to make new folder move four files into ledcube folder.
espongy says: May 18, 2013. 9:20 AM
Hi. I just want to clarify something. I've been searching everything about building an LED Cube here in Instructables. Aren't the collectors connected to the GND while the each emitter is connected to each row/layer?
profT says: Apr 30, 2013. 1:43 AM
hello,
is it possible to transform your 3x3x3 led cube to 7x7x7 one. I try this and the result is not like I would! My output are not in order, how can I write them : first line (left to right) second line (left to right or right to left) etc...
and when a led sould be on it's be of and inversely, is it normal?

thanks
Gregted says: Apr 10, 2013. 4:45 AM
Great instructable. Worked first time. Had to find the Pin codes. They were in the arduino script but great anyway. Levels 1 pin11, 2 pin 12, 3 pin 13, and leds are pins 2 through to 10.
gzip (author) in reply to GregtedApr 20, 2013. 10:10 AM
Thanks. I've added a paragraph about pins to the end of step 3.
lynxhockey says: Apr 19, 2013. 3:33 PM
Hey, this is my first Arduino project, but I'm having some issues getting the code pushed from the sketch to the Arduino. (I'm running 1.0.4 if that matters.) However, I keep getting an error when I try to upload it that says "avrdude: stk500_getsync(): not in sync: resp=0x00" . Also, in the event that it matters, I'm using the Arduino Diecimila.
gzip (author) in reply to lynxhockeyApr 20, 2013. 9:59 AM
You might have the wrong programmer selected or maybe it's not getting enough power.
herroc says: Apr 6, 2013. 6:44 PM
awesome project, took about 2hrs start to finish. No issues at all, though i would bend the legs the opposite way (as suggested). thanks
chromedome45 says: Apr 3, 2013. 5:14 PM
Never mind I fugured it out and it works great. However form ledcube I had to modify the ledcube.cpp file and remove the refernce to newfix.h. Until then I had problems compiling.
gzip (author) in reply to chromedome45Apr 3, 2013. 7:01 PM
What were the compile errors and what version of the Arduino software?
chromedome45 says: Apr 3, 2013. 1:51 PM
One more question where do you apply power? to what pins?
chromedome45 says: Apr 3, 2013. 1:47 PM
Question about the Transistors. Is the Emitter being grounded. Looks that way.
rdela cruz2 says: Mar 25, 2013. 3:23 PM
thank you so much, that worked for me!!! hehe :)
shawnchristophrevaz says: Mar 7, 2013. 5:37 AM
hi,
can you please help me in connecting the wires from the led to the the ports on an adruino?

i have very little knowledge on which port to connect thee pins from the led to the adruino
antisubae says: Feb 10, 2013. 3:48 PM
I fiddled with the design a little and crammed it on to a Seeed ProtoShield today. Not my best work, aesthetically, but it worked like a champ on the first try! I'm no stranger to a soldering iron, but I'm *really* new to the Arduino. It's projects like this that are really motivating me to learn the software side of things. Thanks for the awesome Instructable, gzip!
maikmuc says: Dec 30, 2012. 7:53 AM
Hey nice cube :-)
First I wanted to write my own library, but am not so fit yet... So I try to understand Yours and am playing around with Your code.
In the function LedCube::lightDrop I found an error since the column on Pin 10 never lights up. The parameter where You call lightPulse has to be (r-1, col, wait)
and not lightPulse(r-1, col-1, wait);
and I also wrote a function called lightRise so You can do a random column rise:

void LedCube::lightRise(byte col, unsigned int wait)
{
     for(byte r=0; r<=levels; r++)
    {
        lightPulse(r-1, col, wait);
     }
}
gzip (author) in reply to maikmucDec 30, 2012. 8:11 PM
Hi,

Please try the latest on Github:
https://github.com/gzip/arduino-ledcube

And feel free to submit a pull request for the new method (or the bug if it's still present).
Eduort says: Nov 9, 2012. 9:40 PM
Hi, it looks very good, but i have a question, is posible to add more routines and start each whit a button?
fueler335 says: Oct 16, 2012. 7:42 PM
AWESOME work on the library! Thanks so much for the transition from a 4 by 4 by 4 cube to a 3 by 3 by 3.I did this for a school project and got an A from it.Great website,as well... :)
bubzyg says: Sep 14, 2012. 3:50 AM
I have written an alphabet for this project, if anyone is interested in the code please let me know :)
bubzyg in reply to bubzygSep 26, 2012. 6:14 AM
http://codepad.org/TfR2vbLX

code is inefficient as the arrays are defined each time the loop runs, this is just to move them through the "planes" with a bit of work, this can be rectified.
some coding knowledge may be required.
oslik_ia in reply to bubzygSep 25, 2012. 9:56 AM
Hi, can i get code for an alphabet ?
ohtextex in reply to bubzygSep 17, 2012. 2:22 PM
i was going to do that after i finished a few additions/tweaks to this library. great learning experience this project turned out to be.
jtmanders says: Jul 17, 2012. 6:43 PM
ok so i have built my cube very similar to yours and the code works on it. however my cube is 4x4....how would i go about changing the code so it would run the entire cube? is this even possible? thanks
gzip (author) in reply to jtmandersJul 27, 2012. 12:20 AM
This is a work in progress so let me know if you have any luck with it.
Arduino LED Cube code
ride on toy dude says: Jul 20, 2012. 1:27 PM
What is the color code on the 220 ohm resistors? I'm short on cash and am trying to harvest a couple from any electronics I can find.
ride on toy dude says: Jul 20, 2012. 1:25 PM
Thanks for the code!!
hampp890 says: Jul 18, 2012. 9:53 PM
Can anyone help me i have tried everything to upload the code to my Arduino Uno, and nothing seems to be working. I have unzipped the files into libraries and examples but I still get the same error code. (ledcude does not name a type) If anyone could help me that would be great.
mnralhajj says: Jul 14, 2012. 9:50 PM

hi,, thank u for your efforts,, i did every thing right but when i download the library an error occurred :

1-
at LedCube cube(SIZE, levelPins, colPins); i get this error :

'LedCube' doesn't name a type
cooltronics3200 in reply to mnralhajjJul 17, 2012. 4:44 PM
the same thing is happening to me!
timboo says: Jun 7, 2012. 2:29 PM
This is the first time iv ever done anything like this, i understand how to put the leds together. just when it comes to the circuit board it gets abit confusing. iv started buying the parts for this from the list, well i think the stuff iv bought is right, only thing is i cant find any headers, cant see any on ebay and dont know what they even look like!!! and can someone give me a link for the jump wires on ebay? any help would be great please. is there a step by step way of explaining how to put together the circuit?

Thank you in advance :)
gzip (author) in reply to timbooJun 8, 2012. 9:41 PM
Don't worry about the "jumper" part, any wire will do. Here's a link to headers on ebay. There's no more step by step than than the steps on step 3.
timboo in reply to gzipJun 9, 2012. 6:02 AM
Thank you for your help. I wanted to get the parts from the u.k as thats where i live. Would these headers be fine http://www.ebay.co.uk/itm/10x-Single-Row-Male-Female-40-Pin-Header-Strip-2-54mm-/180688882757?pt=UK_BOI_Electrical_Components_Supplies_ET&hash=item2a11e58c45

and then get these jump wires
http://unmannedtechshop.co.uk/Cables-Connectors/Jumpers?product_id=115

Cant wait to get going on this!!

Cheers
gzip (author) in reply to timbooJun 9, 2012. 10:55 AM
The headers are fine since you get both male and female so you can choose which one to use. The jumpers will work with a little help (by sticking a male pin in one end) but are not ideal since they're female to female. The instructable uses female headers and male to male jumpers made from a hard drive connector cable and male headers (which is labor intensive but nice looking). Simple pieces of wire will work just as well. Something like this male to female ribbon cable will also work nicely if you use male headers on the cube board.
stringstretcher says: Mar 8, 2012. 2:08 PM
I'm experimenting with the routines and find that one column doesn't light up properly in the routine //columns in and out. I have been looking at the cpp file but can't find out what the problem is. Has anyone else seen this? Any ideas? The cube works perfectly otherwise and I love it! Also, the routine you supplied here is not the one featured in your vid is it? Mine doesn't follow these steps!
gzip (author) in reply to stringstretcherMar 8, 2012. 7:37 PM
It's the same routine, the video just starts somewhere in the middle.
stringstretcher in reply to gzipMar 9, 2012. 2:05 AM
I'm sorry, but I beg to differ! My cube doesn't look like this... maybe it's the nut holding the wheel? (me)I'm wondering it there is a bracket missing, which would exclude some of the routines in my sketch. I see some of the sequences, and they should. I will post a vid link so you can have a look. We might learn something! I don't know enough yet to figure this out, hence the questions. Can you point me anywhere to learn more? Thanks for taking time to answer, this is a great little cube and I have had o much fun showing it to my friends. If anyone is interested I will post my revised code, gives a little variation to the cube's appearance.
gzip (author) in reply to stringstretcherJun 3, 2012. 10:17 AM
I finally got around to pulling out my cube and testing this out. As a matter of fact I did manage to botch the software somewhere along the line. The problems are now fixed and as a consolation I've added a few new effects while I was at it. Please download the software again on step 4. Thanks for the report.
ryanprocter says: May 12, 2012. 4:32 PM
also the only jumper wires i can find are breadboard jumpers. are these ok or are these completely wrong?
gzip (author) in reply to ryanprocterMay 14, 2012. 9:13 AM
Breadboard jumpers are fine but a spool of wire (or even salvaged wire) is just as good.
1-40 of 188Next »
Pro

Get More Out of Instructables

Already have an Account?

close

PDF Downloads
As a Pro member, you will gain access to download any Instructable in the PDF format. You also have the ability to customize your PDF download.

Upgrade to Pro today!