I'm trying to make a 3x3 grid of LED's that have various different sequences to light up. With the LED's in a grid like:
1|2|3
4|5|6
7|8|9
One sequence (for example) will be led's 1,2,3,6,9,8,7,4 repeating. However, these LED's are not connected to pins 1,2,3... of the Ardunio. I'm trying to use a 2D array to reference the LED positions and the LED pins like so:
int ref[][] = {1,2,3,4,5,6,7,8,9},
{4,5,6,7,8,9,10,11,12}
Will doing this work, and how do I go about turning the LED's on using this method?
I currently have each sequence defined separately like so:
int cwcircle_step = 8; //number of steps
int cwcircle[] = {4,5,6,9,12,11,10,7}; //led's that light in this sequence.
and then calling them like this:
for (cwcircle_step = 0; cwcircle_step <= 7; cwcircle_step++)
{
digitalWrite(cwcircle[cwcircle_step], HIGH);
delay(100);
digitalWrite(cwcircle[cwcircle_step], LOW);
delay(100);
}
however if i ever want to change what pins the LED's are on, I will have to change each sequence separately. I am trying to create a "master reference table" so I only have to change it once