2

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.

5
  • 1
    It's called an array.
    – Majenko
    Jul 6, 2016 at 13:09
  • Does it need to be byte form?
    – Erik
    Jul 6, 2016 at 13:11
  • An array can be made from any data type you like. Google "Arduino Arrays".
    – Majenko
    Jul 6, 2016 at 13:12
  • Can you be more specific as to what you wish to accomplish?
    – 001
    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
    Jul 6, 2016 at 15:06

2 Answers 2

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;
0
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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.