So I am just starting to mess around with these led cubes I see everywhere, the concept of multiplexing wasn't to bad but then charlie came along.....

but anywho two part question I seem to recall using a matrix of arrays back in the day ( about a decade ago while taking C++ courses) I was thinking this could be a useful way to define the "steps" of the cubes animation, just wondering if Its worth trying to bring back that memory or if I am totally of base.

Second, I started with a simple 3x3 grid and made nifty little dice numbers, I setup a void for each number and then called them one by one, I tried to store the name of each void in an array so that calling the voids could be done simply by calling the array position containing the proper name, the code complied error free but nothing happened, I think I am missing the proper syntax for calling a void based on these parameters. I am confusing my self I thing, let me try to explain , "numbers" is an array position zero contains the string "one()", position one contains "two()", etc. "i" is a random number between 0 and 5, I would hope them writing "numbers(i);" (i know these should be square braces but they keep processing as) html would call the proper void. This would save a lot of ifs and elses but it doesn't seem to work and I am hoping that someone can point out something I am missing.

They're not "voids", they're functions.

LOL

``````//3x3 LED Die, at current this program selects a random number and displays it as a die face via 3x3 led grid

int i;

//array containing the function names
char* numbers[] = {"one()","two()","three()","four()","five()","six()};

void setup()
{
//set pins as output
for(int pinNum = 2; pinNum <= 7; pinNum ++)
{
pinMode(pinNum, OUTPUT);
delay(10);
}
}

void loop()
{
//select a random number
i = random(6);
//call function, this line is where I need to find the proper syntax or command
numbers[]; ****"i" should be between the brackets****
delay(1000);
}

void one()
{
//cathodes
digitalWrite(2, HIGH);
digitalWrite(3, LOW);
digitalWrite(4, HIGH);
//anodes
digitalWrite(5, LOW);
digitalWrite(6, HIGH);
digitalWrite(7, LOW);
delay(5);
}

void two()
{
//cathodes
digitalWrite(2, HIGH);
digitalWrite(3, HIGH);
digitalWrite(4, LOW);
//anodes
digitalWrite(5, HIGH);
digitalWrite(6, LOW);
digitalWrite(7, LOW);
delay(5);
//cathodes
digitalWrite(2, LOW);
digitalWrite(3, HIGH);
digitalWrite(4, HIGH);
//anodes
digitalWrite(5, LOW);
digitalWrite(6, LOW);
digitalWrite(7, HIGH);
delay(5);
}

void three()
{
//cathodes
digitalWrite(2, HIGH);
digitalWrite(3, HIGH);
digitalWrite(4, LOW);
//anodes
digitalWrite(5, LOW);
digitalWrite(6, LOW);
digitalWrite(7, HIGH);
delay(5);
//cathodes
digitalWrite(2, HIGH);
digitalWrite(3, LOW);
digitalWrite(4, HIGH);
//anodes
digitalWrite(5, LOW);
digitalWrite(6, HIGH);
digitalWrite(7, LOW);
delay(5);
//cathodes
digitalWrite(2, LOW);
digitalWrite(3, HIGH);
digitalWrite(4, HIGH);
//anodes
digitalWrite(5, HIGH);
digitalWrite(6, LOW);
digitalWrite(7, LOW);
delay(5);
}

void four()
{
//cathodes
digitalWrite(2, HIGH);
digitalWrite(3, HIGH);
digitalWrite(4, LOW);
//anodes
digitalWrite(5, HIGH);
digitalWrite(6, LOW);
digitalWrite(7, LOW);
delay(5);
//cathodes
digitalWrite(2, LOW);
digitalWrite(3, HIGH);
digitalWrite(4, HIGH);
//anodes
digitalWrite(5, LOW);
digitalWrite(6, LOW);
digitalWrite(7, HIGH);
delay(5);
//cathodes
digitalWrite(2, HIGH);
digitalWrite(3, HIGH);
digitalWrite(4, LOW);
//anodes
digitalWrite(5, LOW);
digitalWrite(6, LOW);
digitalWrite(7, HIGH);
delay(5);
//cathodes
digitalWrite(2, LOW);
digitalWrite(3, HIGH);
digitalWrite(4, HIGH);
//anodes
digitalWrite(5, HIGH);
digitalWrite(6, LOW);
digitalWrite(7, LOW);
delay(5);
}

void five()
{
//cathodes
digitalWrite(2, HIGH);
digitalWrite(3, HIGH);
digitalWrite(4, LOW);
//anodes
digitalWrite(5, HIGH);
digitalWrite(6, LOW);
digitalWrite(7, LOW);
delay(3);
//cathodes
digitalWrite(2, LOW);
digitalWrite(3, HIGH);
digitalWrite(4, HIGH);
//anodes
digitalWrite(5, LOW);
digitalWrite(6, LOW);
digitalWrite(7, HIGH);
delay(3);
//cathodes
digitalWrite(2, HIGH);
digitalWrite(3, HIGH);
digitalWrite(4, LOW);
//anodes
digitalWrite(5, LOW);
digitalWrite(6, LOW);
digitalWrite(7, HIGH);
delay(3);
//cathodes
digitalWrite(2, LOW);
digitalWrite(3, HIGH);
digitalWrite(4, HIGH);
//anodes
digitalWrite(5, HIGH);
digitalWrite(6, LOW);
digitalWrite(7, LOW);
delay(3);
//cathodes
digitalWrite(2, HIGH);
digitalWrite(3, LOW);
digitalWrite(4, HIGH);
//anodes
digitalWrite(5, LOW);
digitalWrite(6, HIGH);
digitalWrite(7, LOW);
delay(3);
}

void six()
{
//cathodes
digitalWrite(2, LOW);
digitalWrite(3, LOW);
digitalWrite(4, LOW);
//anodes
digitalWrite(5, HIGH);
digitalWrite(6, LOW);
digitalWrite(7, HIGH);
delay(5);
}
``````

Each of these could be replaced for faster operation:

void one()
{
//cathodes
digitalWrite(2, HIGH);
digitalWrite(3, LOW);
digitalWrite(4, HIGH);
//anodes
digitalWrite(5, LOW);
digitalWrite(6, HIGH);
digitalWrite(7, LOW);
delay(5);
}

These are all PORTD pins, yes?
So using direct port manipulation:
void one()
{
PORTD = PORTD & 0b00000011; // clear all bits, leave 0/1 alone
PORTD = PORTD | numberArray[1]; // OR in upper 6 bits, leave 0/1 alone
delay(5);
}
where
numberArray[1] = 0b01010100; // 7-6-5-4-3-2-x-x

Then you could simplify further, just call
void numToDisplay(byte value){
PORTD = PORTD & 0b00000011; // clear all bits, leave 0/1 alone
PORTD = PORTD | numberArray[value]; // OR in upper 6 bits, leave 0/1 alone
delay(5);
}

or something similar to that - software gurus, help me out with syntax here please.

i have no idea what that says. I don't know what a portd pin is. I do know that there are several other ways to simplify the code that displays the number, I even could download code from somebody else that already does the same thing as my code. I am really trying to learn ( re-learn actually ) to write the code I need instead of a lot of cut and paste.

There was one technique I am particularly interested in figuring out that involved using a matrix for each number but thats down the road, the code I am trying to figure out right now is in the loop function, I want to call a function by accessing a variable that has the functions name stored in it. it seems simple in concept but I can't find any examples of it.

I want to call a function by accessing a variable that has the functions name stored in it.

That's what I was explaining. There is a function, the data to be stored is 6 bits at each array location that represents the anode & cathode states

numberArray[1] = 0b01010100; // Digital IO pins 7-6-5-4-3-2-x-x
// 7-6-5 are the anodes, 4-3-2 are the cathodes per your pin definition.
The 0b indicates binary format, easy to follow
0b 010 101 00 data from your void one()
010 are your Low-High-Low for anodes, 101 is the High-Low-High for cathodes, and 00 are D1/D0 that you will not change as Serial uses them.
PORTD allows 8 bits to be written at one time, vs 6 digitalWrites.

So numberArray[1] thru numberArray[9] are the combinations of Anodes/cathodes that will be turned on.

i think I am following , what your showing me (in dummy-speak) essentially would fit my entire set of function into an array.
It makes sense compared to other code i was reading, but I would still like to know If it is possible to do it the way I originally wanted. While it may be unnecessary in this case it may be something for another more complex project.

is possible to do it the way I originally wanted.

No it is not. C dosen't work like that. Once it is compiled all names are lost.

Runaway Pancake - What like this?

twelch:
but I would still like to know If it is possible to do it the way I originally wanted.

Pedro147:
Runaway Pancake - What like this?

LOL when i need a good laugh i just check out this pic… LOL some funny there.

Pedro147:
Runaway Pancake - What like this?

What? Just my initials?

the image

Yes, right, R.I.P, Runaway Ignatius Pancake

So, anyway, twelch, making any headway with switch.. case ?

twelch
You there? Any report?
(Is it a "bump" eliciting a response from an OP? How about "prod"?)
People posting questions and disappearing - Really.

Prod , Prod

Sorry taking so long I spent several days reading code from different people that drive the same led array. The phrase more then one way to skin a cat does not even begin to give the vast amount of techniques I've discovered. I think I have a good handle on switch case but ok was actually trying to simplify it further then that. The reality is that for a program so small it doesn't matter but I was preparing for bigger things that I haven't dreamt up yet. Alas the parts for the things I am paid to make have come in and I will be switching gears for a while but thatnks for all your help!