Naming Pins

Hello everyone!!! I am new to this and wanted to ask a question. I have looked for some information on naming pins and not sure I am understanding this correctly. I will just ask rather than go over everything that I have looked at.

I would like to name all of my pins before my program to make it easier to use. I work on PLC's like Allen Bradley and Siemens. I would like to name them the same way. Makes programming faster for me.

All inputs would be I01 I02 I03.....etc
All outputs would be O01 O02 O03.......etc
All analog would be either A01 A02 A03......etc or PIW1 PIW2 PIW3........etc

Would this be possible?

Also, would I name them by

int I13 =13; //LED pin 13 is input 13
int PIW01 =A0 //Analog input A0

I would like to create a library for the different boards that I will use with this for easy use. It will help me also understand the naming better to understand the coding. Any input or help will be appreciated.

Thank you

const byte I01 = 2; // input pin
But why not:
const byte upperLimitSwitch = 2;

const byte O01 = 3; // output pin
But why not:
const byte mortorDirection = 3;

const byte A01 = A0; // analog pin
But why not:
const manifoldTemperature = A0;

You can place generic definitions into a header file, then include this file in your sketches.

slouich:
Hello everyone!!! I am new to this and wanted to ask a question. I have looked for some information on naming pins and not sure I am understanding this correctly. I will just ask rather than go over everything that I have looked at.

I would like to name all of my pins before my program to make it easier to use. I work on PLC's like Allen Bradley and Siemens. I would like to name them the same way. Makes programming faster for me.

All inputs would be I01 I02 I03.....etc
All outputs would be O01 O02 O03.......etc
All analog would be either A01 A02 A03......etc or PIW1 PIW2 PIW3........etc

Would this be possible?

Also, would I name them by

int I13 =13; //LED pin 13 is input 13
int PIW01 =A0 //Analog input A0

I would like to create a library for the different boards that I will use with this for easy use. It will help me also understand the naming better to understand the coding. Any input or help will be appreciated.

Thank you

Your method may be easier for you, but if you expect to ask for help on the Arduino forum, you really need to name the pins showing what they are actually connected to. Makes for MUCH easier debugging by remote control!

Paul

Thank you!!!!!

Would this be possible?

Yes. It even makes sense.

Naming the input pins Fred, George, and Martha is possible, too, but does that make sense? Not to me.

Also, would I name them by

int I13 =13; //LED pin 13 is input 13

I would not do that. There is a reason that a pin is being used for input. Using that reason in the name makes more sense than using the pin number in the name. If you discover that using pin 13 as input becomes a problem, because you add an ethernet shield and can not longer use pin 13, changing the value of I13 to 7 will be possible, but misleading. Changing the name to I7 will be easy, but you need to change it everywhere. Changing the value of IOnPin from 13 to 7 does not require any other changes to the rest of the program when you discover that the on switch can not be connected to pin 13.

Paul_KD7HB:
Your method may be easier for you, but if you expect to ask for help on the Arduino forum, you really need to name the pins showing what they are actually connected to. Makes for MUCH easier debugging by remote control!

Paul

I have nothing connected to the pins. This is just trying to understand the programming and make it easier for me to adapt to Arduino.

Today pin 2 might be an input but tomorrow it might be an output. :wink:

slouich:
I have nothing connected to the pins. This is just trying to understand the programming and make it easier for me to adapt to Arduino.

Then that is just confusing to someone you have asked for help.

Paul

PaulS:
Yes. It even makes sense.

Naming the input pins Fred, George, and Martha is possible, too, but does that make sense? Not to me.
I would not do that. There is a reason that a pin is being used for input. Using that reason in the name makes more sense than using the pin number in the name. If you discover that using pin 13 as input becomes a problem, because you add an ethernet shield and can not longer use pin 13, changing the value of I13 to 7 will be possible, but misleading. Changing the name to I7 will be easy, but you need to change it everywhere. Changing the value of IOnPin from 13 to 7 does not require any other changes to the rest of the program when you discover that the on switch can not be connected to pin 13.

This was an example and not an actual name. Thank you

Paul_KD7HB:
Then that is just confusing to someone you have asked for help.

That is why it says NEWBIE under my name. LOL

Paul

That is why it says NEWBIE under my name. LOL

No. It says NEWBIE under your name because you have posted less than 100 times.