Hi Guys,
So I want to ahve a large matrix of leds, but in my code I don't want to have to write digitalWrite(pin, HIGH) for every single LED I want on, because I want different combinations f the leds onat any one time, so I was wondering whether there is a better way to do this. I.e cI make like a library or a header file or something that contains all the combinations of pin numbers, each one as a #define or something, and then when I call upon that define, my code sets those pins high? Im not sure exactly how to expalin it because Im not sure whats possible, but lets say I had a 3x3 matrix of leds, and one combo was having 1, 4, 6 and 8 on then could I have a define like:
#define combo1 {1,4,7,8}
and then when I want those led's on, I just pass combo1 to a function that loops through setting those pins of the array high?
void func_to_turn_on_leds(int[] pins){
for (int i = 0; i< pins.length; i++){
digitalWrite(pins[i], high);
}
}
Is that how its done?
I get that you could do it with arrays of the combinations but Im not sure how exactly its done with defines/led arrays.
Thanks