# led cube programming

Hi all, I am a beginner and I recently started writing some code and found it would be very useful to do some things which I am sure someone has already done. I need someone to point me to the right keywords here.

Essentially I have been addressing the individual LEDs by their two pins that turn one on and then putting a delay (of 1) and a for loop and addressing others when I want them to appear on at the same time. For this one program I wanted a wave to go from the bottom front right corner to the top left back corner and theres a stupid long code I wrote that does exactly that.

Someone must have figured out a way to address the LEDs in another way that allows them to be variable, and also making sections of the code change algorithmically to make this wave pattern (and any other variation of patterns). They must be some kind of objects they address them as in a spatial way, and I was wondering what kind of functions and tricks I might use to set up a way to begin programming this thing spatially rather than manually addressing each LED to form patterns.

Where do I start?

like is there some kind of way to do this with integers in matrices?

So, if you want a wave to go from the bottom left corner to the top back corner, than this means that at any moment, all leds where X+Y+Z = some value will be lit. To make the wave move, you bounce that value around.

I got it to move, but I want a more efficient way to code in general. Instead of writing

void setup()
{
pinMode(2,OUTPUT);
pinMode(3,OUTPUT);
pinMode(4,OUTPUT);
pinMode(5,OUTPUT);
pinMode(6,OUTPUT);
pinMode(7,OUTPUT);
pinMode(8,OUTPUT);
pinMode(9,OUTPUT);
pinMode(10,OUTPUT);
pinMode(11,OUTPUT);
pinMode(12,OUTPUT);
pinMode(13,OUTPUT);
}

void loop()
{
digitalWrite (2,HIGH);
digitalWrite (11,HIGH);
delay (100);
digitalWrite (2,LOW);
digitalWrite (11,LOW);

for(int i=1; i<100;i++)

{
digitalWrite (3,HIGH);
digitalWrite (5,HIGH);
digitalWrite (11,HIGH);
delay (1);
digitalWrite (3,LOW);
digitalWrite (5,LOW);
digitalWrite (11,LOW);
digitalWrite (2,HIGH);
digitalWrite (12,HIGH);
delay (1);
digitalWrite (2,LOW);
digitalWrite (12,LOW);
i++;
}

for(int l=1; l<100;l++)

{
digitalWrite (11, HIGH);
digitalWrite (4, HIGH);
digitalWrite (6, HIGH);
digitalWrite (8,HIGH);
delay (1);
digitalWrite (11, LOW);
digitalWrite (4, LOW);
digitalWrite (6, LOW);
digitalWrite (8,LOW);

digitalWrite (12, HIGH);
digitalWrite (3, HIGH);
digitalWrite (5, HIGH);

delay (1);
digitalWrite (12, LOW);
digitalWrite (3, LOW);
digitalWrite (5, LOW);
digitalWrite (13, HIGH);
digitalWrite (2, HIGH);
delay (1);
digitalWrite (13, LOW);
digitalWrite (2,LOW);
l++;
}
for(int k=1; k<100;k++)

{
digitalWrite (11, HIGH);
digitalWrite (7, HIGH);
digitalWrite (9, HIGH);

delay (1);
digitalWrite (11, LOW);
digitalWrite (7, LOW);
digitalWrite (9, LOW);

digitalWrite (12, HIGH);
digitalWrite (4, HIGH);
digitalWrite (6, HIGH);
digitalWrite (8,HIGH);
delay (1);
digitalWrite (12, LOW);
digitalWrite (4, LOW);
digitalWrite (6, LOW);
digitalWrite (8, LOW);
digitalWrite (13, HIGH);
digitalWrite (3, HIGH);
digitalWrite (5, HIGH);
delay (1);
digitalWrite (13, LOW);
digitalWrite (3,LOW);
digitalWrite (5,LOW);
k++;
}
for(int m=1; m<100;m++)

{
digitalWrite (11, HIGH);
digitalWrite (10, HIGH);

delay (1);
digitalWrite (11, LOW);
digitalWrite (10, LOW);

digitalWrite (12, HIGH);
digitalWrite (9, HIGH);
digitalWrite (7, HIGH);
delay (1);
digitalWrite (12, LOW);
digitalWrite (7, LOW);
digitalWrite (9, LOW);
digitalWrite (13, HIGH);
digitalWrite (4, HIGH);
digitalWrite (6, HIGH);
digitalWrite (8, HIGH);
delay (1);
digitalWrite (13, LOW);
digitalWrite (4,LOW);
digitalWrite (6,LOW);
digitalWrite (8,LOW);
m++;
}
for(int n=1; n<200;n++)

{
digitalWrite (7,HIGH);
digitalWrite (9,HIGH);
digitalWrite (13,HIGH);
delay (1);
digitalWrite (9,LOW);
digitalWrite (7,LOW);
digitalWrite (13,LOW);
digitalWrite (10,HIGH);
digitalWrite (12,HIGH);
delay (1);
digitalWrite (10,LOW);
digitalWrite (12,LOW);
n++;
}
digitalWrite (10,HIGH);
digitalWrite (13,HIGH);
delay (100);
digitalWrite (10,LOW);
digitalWrite (13,LOW);

digitalWrite (10,HIGH);
digitalWrite (13,HIGH);
delay (100);
digitalWrite (10,LOW);
digitalWrite (13,LOW);
for(int n=1; n<200;n++)

{
digitalWrite (7,HIGH);
digitalWrite (9,HIGH);
digitalWrite (13,HIGH);
delay (1);
digitalWrite (9,LOW);
digitalWrite (7,LOW);
digitalWrite (13,LOW);
digitalWrite (10,HIGH);
digitalWrite (12,HIGH);
delay (1);
digitalWrite (10,LOW);
digitalWrite (12,LOW);
n++;
}

for(int m=1; m<100;m++)

{
digitalWrite (11, HIGH);
digitalWrite (10, HIGH);

delay (1);
digitalWrite (11, LOW);
digitalWrite (10, LOW);

digitalWrite (12, HIGH);
digitalWrite (9, HIGH);
digitalWrite (7, HIGH);
delay (1);
digitalWrite (12, LOW);
digitalWrite (7, LOW);
digitalWrite (9, LOW);
digitalWrite (13, HIGH);
digitalWrite (4, HIGH);
digitalWrite (6, HIGH);
digitalWrite (8, HIGH);
delay (1);
digitalWrite (13, LOW);
digitalWrite (4,LOW);
digitalWrite (6,LOW);
digitalWrite (8,LOW);
m++;
}

for(int k=1; k<100;k++)

{
digitalWrite (11, HIGH);
digitalWrite (7, HIGH);
digitalWrite (9, HIGH);

delay (1);
digitalWrite (11, LOW);
digitalWrite (7, LOW);
digitalWrite (9, LOW);

digitalWrite (12, HIGH);
digitalWrite (4, HIGH);
digitalWrite (6, HIGH);
digitalWrite (8,HIGH);
delay (1);
digitalWrite (12, LOW);
digitalWrite (4, LOW);
digitalWrite (6, LOW);
digitalWrite (8, LOW);
digitalWrite (13, HIGH);
digitalWrite (3, HIGH);
digitalWrite (5, HIGH);
delay (1);
digitalWrite (13, LOW);
digitalWrite (3,LOW);
digitalWrite (5,LOW);
k++;
}

for(int l=1; l<100;l++)

{
digitalWrite (11, HIGH);
digitalWrite (4, HIGH);
digitalWrite (6, HIGH);
digitalWrite (8,HIGH);
delay (1);
digitalWrite (11, LOW);
digitalWrite (4, LOW);
digitalWrite (6, LOW);
digitalWrite (8,LOW);

digitalWrite (12, HIGH);
digitalWrite (3, HIGH);
digitalWrite (5, HIGH);

delay (1);
digitalWrite (12, LOW);
digitalWrite (3, LOW);
digitalWrite (5, LOW);
digitalWrite (13, HIGH);
digitalWrite (2, HIGH);
delay (1);
digitalWrite (13, LOW);
digitalWrite (2,LOW);
l++;
}
for(int i=1; i<100;i++)

{
digitalWrite (3,HIGH);
digitalWrite (5,HIGH);
digitalWrite (11,HIGH);
delay (1);
digitalWrite (3,LOW);
digitalWrite (5,LOW);
digitalWrite (11,LOW);
digitalWrite (2,HIGH);
digitalWrite (12,HIGH);
delay (1);
digitalWrite (2,LOW);
digitalWrite (12,LOW);
i++;
}
digitalWrite (2,HIGH);
digitalWrite (11,HIGH);
delay (100);
digitalWrite (2,LOW);
digitalWrite (11,LOW);
}

this, I would like to write something that will add another level or plane, and determine which leds should be lit for that level. I want to be able to make shapes algorithmically and translate it into which LEDs should be lit. Like another level I can input equations into and generate forms. How would I begin to code something like that?

Hi,

See section 7 http://forum.arduino.cc/index.php/topic,148850.0.html

How many LEDs do you have and what arduino are you using? UNO?

Tom…

TomGeorge:
Hi,

See section 7 http://forum.arduino.cc/index.php/topic,148850.0.html

How many LEDs do you have and what arduino are you using? UNO?

Tom…

@TomGeorge, perhaps you should make the link clickable?
http://forum.arduino.cc/index.php/topic,148850.0.html

Hi,

aarg, do you want me to do everything! ! !

Tom....