Using underscores in code

Hi there,

I am new in coding and electronics, so I have a question.

Can I use underscores " _ " in the Arduino code?
Because I am planning to use 6 inputs and 12 outputs, it is a bit easier to keep the overview in the names...

Is this example possible:

// INPUTS
      int switch01_Pin = 14;
      int switch02_Pin = 15;
    
// OUTPUTS
      int wire01_Pin = 0;
      int wire02_Pin = 1;

// VARIABLES
      boolean lastButton = LOW;
      boolean currentButton = LOW;
      boolean wire01_On = false;
      boolean wire02_On = false;

Thanks for your help!

Underscores in names are fine.

Because I am planning to use 6 inputs and 12 outputs, it is a bit easier to keep the overview in the names...

Even better would be arrays.

PaulS:
Underscores in names are fine.

Because I am planning to use 6 inputs and 12 outputs, it is a bit easier to keep the overview in the names...

Even better would be arrays.

Thanks Paul!
You mean like this?

// INPUTS
      int [switch01]Pin = 14;
      int [switch02]Pin = 15;
    
// OUTPUTS
      int [wire01]Pin = 0;
      int [wire02]Pin = 1;

// VARIABLES
      boolean lastButton = LOW;
      boolean currentButton = LOW;
      boolean [wire01]On = false;
      boolean [wire02]On = false;

That would be better indeed!

You mean like this?

Not exactly. Like this:

int switchPins[] = {14, 15};
int wirePins[] = {0, 1};
boolean wireStates[] = {false, false};

Oh good! It keeps it nice and short!
Didn't know that. (there's a lot I don't know yet)

Thanks! I will try to implement it in my code.