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.
Asked
Active
Viewed 957 times
2
-
1It's called an array. – Majenko Jul 06 '16 at 13:09
-
Does it need to be byte form? – Erik Jul 06 '16 at 13:11
-
An array can be made from any data type you like. Google "Arduino Arrays". – Majenko Jul 06 '16 at 13:12
-
Can you be more specific as to what you wish to accomplish? – 001 Jul 06 '16 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 Jul 06 '16 at 15:06
2 Answers
4
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;
Ignacio Vazquez-Abrams
- 17,663
- 1
- 27
- 32
0
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.
linhartr22
- 596
- 4
- 10