Hi people, I'm brand new to electronics so please bare with me and my ignorance.
I'm working on a 4x4 LED cube and have started out building it and now trying to control it using an Arduino. I know the Ardunio doesn't have enough pins to accommodate the cube nor does it have sufficient power to drive it which is leading to my question.
I'm using a secondary supply source to drive the cube through a series of 3904 transistors. Yes, the ground for the secondary power and the Arduino are connected together. The column control doesn't appear to be an issue, but controlling the layers is. Can I control the layers using a transistor? The intent was to drive the layer on (connecting it to ground) by driving the base of the 3904 HIGH. Is my head in the right place or won't this even work? It seems my columns all light when I only have 1 layer active. What am I doing wrong?
Hard to say without a schematic. There are many ways to do it.
I would picture a shift register per row, 4 pins driving anodes high and 4 pins driving cathodes low to turn on indivual LED.
Repeat 4 times. Then 4 pins to enable the shift register per layer. Transistors to provide higher current capability.
How are you hooked up?
With 4x4x4 you could get by with just 12 pins, so arduino could control that directly.
Thanks for the reply CrossRoads. I have been flying by the seat of my pants on this one. I built a 3x3 cube and controlled it directly with the Arduino. That had 9 column pins and 3 layer pins and was fairly easy to control. How can I control a 4x4 with 12 pins? As it stands I'm just trying to use the transistors as a means of delivering high current in anticipation of completing the 4x4. I still have to learn how to hook up and program a shift register to make this thing work, but that is step whatever down the road. Is there another way to control the layer aspect or can Ii control the layers directly from the board. My fear is drawing too much current through the board and doing damage to it if I go direct on controlling the layers without a transistor in play to handle the current.
Hard to describe without a picture, but picture this per level:
1 Anode on off on
2 Anode off on off
3 Anode on off off
1 Cathode 2 Cathode 3 Cathode
Anodes in a row are connected.
Cathode in a column are connected.
To achieve an On, you need a Anode High a Cathode Low.
Anode Low and/or cathode high will result in off.
So typically one would start with anodes low, cathodes hi (all off).
Then start a simple loop of:
Cathode hi/low for row 1, pulse anode 1 high for # of milliseconds
cathode hi/low for row 2, pulse anode 2 high for # of mS
cathode hi/low for row 3, pulse anode 3 high for 3 of mS.
repeat for layer 2
repeat for layer 3
Could also control on LED by LED basis, making the anode or the cathode signal PWM for fading effect.
Then it would be cathode1/anode1, cathode2/anode1, cathode3/anode1
repeat for row 2,3 and layers 2,3
So I suppose you could do it with 18 pins (arduino has 20!)
level 1: anode 1-2-3, cathode 1-2-3
leve2: anode 4-5-6, cathoed 4-5-6
level3: anoder 7-8-9, cathode 7-8-9
Arduino can source 20mA for anode, can sink 20mA for cathode.
Be sure to only turn on individual LED in each level.
If you want to drive whole rows at a time, then need higher current source for each row, cathode will still just be sinking current for 1 LED.
Or go the other direction: can across the columns, easier hardware-wise. Turn on the anodes from arduino pin, use a part like ULN2003 for current sink for all 3 anodes. Only turn one column at a time.
I've managed to rig up the whole mess without blowing up anything, ha. To solve the issue of excessive current draw I've used a bunch of 2N304 transistors and a separate power supply as opposed to drawing from the Arduino. I'm using the outputs of the Arduino it to drive the bases of the transistors to control the anodes and cathodes of the cube. So far so good and nothing went puff which surprised me. The ultimate goal is convert this cube into a full blown 4x4 cube using 595 shift registers although I'm totally out to lunch on the code right now. All I can get them to do is count so I have no idea how to tell the shift registers how to talk to any given LED in the cube. Regardless of where I look, the information on shift register programming are all basically the same showing the same code for binary counting, nothing on how to control the shift register's output pins the way I want them displayed or I just haven't gotten into enough so far.
Any suggestions?
It is like taking your mind and converting the thought process to think differently. I've played with electric all my life but that has always been high voltage, i.e. 120 - 4160, 3 phase and single phase AC, but electronics doesn't follow the same rules so a lot of what I thought I knew isn't all that much of a help and it's like starting over.
Hey, thank you for your assistance here, it is very much appreciated. I'd like to say that if I could assist you someday, but as it stands, there probably is very little I can offer in the way of assistance.
Ha, I wish I had your confidence. I'm very shaky when it comes to programming the arduino since I'm so new at it. I'm gone through the arduino shift register tutorial several times but I can't seem to wrap my head around it.
Question, where you from? I'm in Pennsylvania.
Your assistance is greatly appreciated. For the moment I solved my problem with I/O pins, I ordered a new Arduino Mega, 54 I/O pins, haha, fixes the problem, teaches me nothing
Ok, Take a look at this and see if this makes sense.
4x4x4 LED cube is made of 16 groups of 4 LEDs per group, anode1 of all groups are wired together to an arduino output pin, same for anode2, 3, 4.
The cathode of each group is pulled low by an arduino output pin driving an open collector transistor (discrete, part of ULN2803, etc, capable of sinking 80mA).
Thus, 4 anode pins, 16 cathode pins, uses all 20 pins.
Only 1 transistor is turned on at a time to avoid overdriving Anode output, assuming 20mA current limit resistors.
4 Anode pins can be replaced with 16 bits of high current shift register (74AC299PC for example, 24mA source current), then all anode can be seperately driven and all LEDs can be turned on at once if desired.
Simple approach to coding follows
set up 4x 16 array of high, lows
void loop
for (count = 1 to 16)
digitalWrite anode for row (count)
digitalWrite cathore(count), Hi
delay 10mS
digitalWrite cathode(count), Lo
next count
cycle thru a few time to see the LEDs
set up next set of 4x16 data
end loop
I may actually be able to get this thing to work. Thanks for the guidance, if nothing else it's more than I had yesterday and that can't hurt.
I'll have to post on here the end product. So far I've been pretty lucky, I've only fried a few transistors, I'll caulk that up to the price of education, ha.