A couple of years ago I saw a 4X4X4 Led Cube at Fry's. Ever sense that day I have been wanting to make one for my self. So I finally got to doing it. I wanted to use an arduino to control it so I started digging in my parts bins and found some blue LEDs, a perfboad, and some shift registers.
I did not know were to start, so I searched the internet to see if anybody had done any using these parts. Luckily I found a few posted at instructables.com, but the only ones using shift registers where the 8x8x8 cubes. People making the 4X4X4 were not using shift registers. They were just using all the pins on their arduinos. I did not want to use up all of the pins on just the cube because eventually I also want to add a 16x2 lcd display and maybe an RTC.
So not finding any examples to work with I went ahead and started building it anyway. I used this great example to help me with the soldering part. I also took a look at the Arduino ShiftOut tutorial to help me with the wiring and to get some code started. Since I could not find any examples of anybody using this set up I had to come up with my own code.
So if you check out the link above of the great example on instructables.com. You will see that all the cathodes are connected together in each layer. I soldered every thing exactly the same way. In the picture above I labeled the layers and the transistors.
The transistors control the layers(floors)
- When you apply current to the base of transistor Q-1, current will flow thru the transistor. allowing layer-0 to connect to ground.
- When you apply current to the base of transistor Q-2, current will flow thru the transistor. allowing layer-1 to connect to ground.
- When you apply current to the base of transistor Q-3,.... Ok I think you get the point.
The shift registers control the columns
- COL-7B = 128
- COL-6B = 64
- COL-5B = 32
- COL-4B = 16
- COL-3B = 8
- COL-2B = 4
- COL-1B = 2
- COL-0 = 1
- Turn on all the LED on layer-0.
- Send current to the base of Q-1 to allow current to flow thru layer-0. (My code looks something like this. digitalWrite(layer0, HIGH)).
- Set the latch pin LOW so the LEDs don't change while you send the bits. (My code looks like this. digitalWrite(latch, LOW)).
- Turn all LEDs on like this. First line of code will be to send the first set of bits to IC-B and the second line of code will be for the second set of bits to IC-A. (first line) shiftOut(data, clock, MSBFIRST, 255); (second line) shiftOut(data, clock, MSBFIRST, 255);. The first line is for IC-B and the second line is for IC-A.
- Set the latch pin HIGH when your done sending bits. (digitalWrite(latch, HIGH)).
- Turn on COL-4B and COL-3A on layer-3.
- Send current to the base of Q-4 to allow current to flow thru layer-3. (My code looks something like this. digitalWrite(layer3, HIGH)).
- Again set the latch pin LOW the same way.
- Turn on COL-4B and COL-3A like this. (first line) shiftOut(data, clock, MSBFIRST, 16); (second line) shiftOut(data, clock, MSBFIRST, 8);
- Set the latch pin High when your done sending bits.
- Turn on COL-7B + COL-6B and COL-1A + COL-6A on layer-1.
- Send current to the base of Q-2 to allow current to flow thru layer-1. (My code looks something like this. digitalWrite(layer1, HIGH)).
- Set the latch pin LOW.
- COL-7B + COL-6B = 192 and COL-1A + COL-6A = 66. So in code you would do it like this. (first line) shiftOut(data, clock, MSBFIRST, 192); (secon line) shiftOut(data, clock, MSBFIRST, 66);
- Set the latch pin HIGH.
Here is the schematic.
Here is the code.
The code is well commented and maybe a bit overkill, but I wanted it to be clear enough for even a beginner to understand and modify.
I tried to download your code, but I got an error message. Could you possibly email me the Arduino code to goldeagle98201@yahoo.com? I, too, am an amateur and just learning Arduino code.
ReplyDeleteIt's the best manual on revival a led cube. Your code will be very helpfull for everyone, and for me too. (dfedor54@gmail.com)
ReplyDeleteCould you send the code to me, too. I am a novice. But, I think I can handle this if I get the code. TIA
ReplyDeleteArnold
Oops. My EMail is arnoldbaker@lincolnxing.org. Thanks again.
ReplyDelete