Author Options:

Coding to controll a 4x4x4 led cube with arduino duemilanove... Help please? Answered

Okay, i know how to build the cube and to multiplex it to use only 12 pins. what i am going to do is connect each anode of each level and connect each cathode of each row, and each one will go to its own transistor. so i will have a total of 8 transistors for the anodes and 8 transistors for the cathodes, which i can further multiplex into two groups of 4x2 transistors. that makes a total of 12 pins on the arduino(i hope that makes sense ill add pics of what i mean to help) but what im asking is that i need help on writing the code for this project. i have a basic idea to run loops inside of loops to make more than one led look like theyre on at the same time(i believe its called persistance of vision)  but maybe someone more experienced would be able to help me out with this. thank you to anyone helps and A Happy New Year To All Of You!!!



I have built that up too, but I did it from a youtube video, http://www.youtube.com/watch?v=lZyc6ulpkyM, turns out to be the same as your plan.

I know that you only light one at a time, very quickly, to give the impression of more than one on..- check that option out, Lemonie :)

Thing is, on my ardiuno, I have a problem with the code I think...
I get random LED`s light up..

If I run the code to turn on Anode1 & Cathode1, then A&C 2, then A&C 3, too A&C 8, all on then off in turn.... it works on a LED bargraph, but on the LED cube, each AC1...AC8 sequence lights up more than one LED when I expect it to light up one at a time.
It sounds like a short circuit, but I can assure you that its NOT, its my code...

Any help is appreicated!



This isn't going to work as you want.
Think about powering a few LEDs and what happens.
(look at existing instructables)




use https://www.instructables.com/id/The-4x4x4-LED-cube-Arduino/ -- they have it designed already. There is no way to light more than 1 'row' at a time using an array of matricies. It's all about flashing as lemonie says here.

8 pins is 8 bit, but there aren't that many options with this design.


Yeah, multiplexing is definitely required.

thanks for all the replies! theyre all very helpful and have taught me a lot. (this was just an idea i had, but it seems that i was wrong. after some expirence i hope to learn more) but for now i think i am going to go with forte1994's 'ible because it seems easy for a beginner.(thanks frollard!)

check that: https://www.instructables.com/id/LED-Cube-4x4x4/ has a much better diagram.

Here is my code to control my 5x5x5 led cube.
I use PortD to supply the power to 5 LEDs at a time and PortB (multiplexed) to select which of the 25 rows to light up (provides the ground to the row).

I use Sebastian Wallin's interrupt routines to scan the rows at a uniform rate - this ensures the LEDs are uniformly bright when on.

The main code sets bits in the led array (and I provide macros to do this easily) to light the LEDs.

This code just sets two patterns, all on and a moving wall. You can create your own patterns after these!

Best Wishes.