I'm new to all of this, but it's there a way to group a cluster of pins to one variable? I don't necessarily want the grouped pounds to be sequential.
-
1It's called an array.Majenko– Majenko2016年07月06日 13:09:11 +00:00Commented Jul 6, 2016 at 13:09
-
Does it need to be byte form?Erik– Erik2016年07月06日 13:11:40 +00:00Commented Jul 6, 2016 at 13:11
-
An array can be made from any data type you like. Google "Arduino Arrays".Majenko– Majenko2016年07月06日 13:12:17 +00:00Commented Jul 6, 2016 at 13:12
-
Can you be more specific as to what you wish to accomplish?001– 0012016年07月06日 13:19:49 +00:00Commented Jul 6, 2016 at 13:19
-
One example of a application I am considering is a grid of LEDs. I may wait to group some LEDs to look like constellations. I would like to have variables naming the constellations, that I can't turn on and off like a light switch.Erik– Erik2016年07月06日 15:06:31 +00:00Commented Jul 6, 2016 at 15:06
2 Answers 2
Only if you drop to low-level access, and only if the pins are on the same port.
#define pinset 0x55
...
PORTC |= pinset;
delay(1000);
PORTC &= ~pinset;
In the example of the constellations, consider using an array for each constellation where each element in the array corresponds to an LED output pin. You could simply put a 1 or a 0 in each array element to indicate if you want the corresponding LED output pin on or off. It would be easy then to create a function that you would pass a constellation array and would turn the LED output pins on or off based on the contents of the array.