digital write to a label using a concatenated variable

I have spent hours trying to find the answer here and by Google, thanks in advance for any help you may offer me.

I am trying to use a string to refer to my predefined output pins. I call them JET1 through JET10 and I want to loop through them using a for loop. I then concatenate the string "JET" with the variable jet to give me the same labels as defined up top.

It won't compile no matter what I try. The error message is "cannot convert 'String' to 'uint8_t {aka unsigned char}' for argument '1' to 'void digitalWrite(uint8_t, uint8_t)' "

I have chopped this up to make it easier to understand.

A|What do I have to do to refer to a label this way? TIA

#define JET10 11
#define JET9 10
#define JET8 9
#define JET7 8
#define JET6 7
#define JET5 6
#define JET4 5
#define JET3 4
#define JET2 3
#define JET1 2

.....

Void loop();


 for (int jet = 0 ; jet <= 9; jet++) {


String MUZ = String ("JET") + jet ;


digitalWrite (MUZ , HIGH); 

};

I then concatenate the string "JET" with the variable jet to give me the same labels as defined up top.

At run time, variables have addresses, not names. What you want to do can not be done that way.

What you can do is put the pin numbers in an array, and use the value of jet as an index into the array, to get the pin number to manipulate.

What do I have to do to refer to a label this way?

Develop your own board that can be programmed using your language, after you've developed the appropriate compilers and linkers.

That's not going to work. Al your defines are ONLY used when compiling. Before it compiles it kind of does a big search and replace for every define in the code. So it will not find anything. After that it forgets about them so when running the code it does nothing.

There are more logical ways of doing something like that. And for that matter you just want to stay away from the awfull String class.

An example:

const byte JetPins[] = {11, 10, 9, 8, 7, 6, 5, 4, 3, 2};

void setup(){
  for(byte i = 0; i < sizeof(JetPins); i++){
    pinMode(JetPins[i], OUTPUT);
  }
}

void loop(){
  for(byte i = 0; i < sizeof(JetPins); i++){
    digitalWrite(JetPins[i], HIGH);
  }
  delay(1000);
  
  
  for(byte i = 0; i < sizeof(JetPins); i++){
    digitalWrite(JetPins[i], LOW);
  }
  delay(1000);
}

Awesome, thank you both for your help. That saves me beating my head against the wall :smiley: