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.

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

answered Jul 7, 2016 at 18:04

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.