help in the part of pins and setting values

i want to know how do i differe between a const for pin and a value for const
example:
int led=13;//i need this const to be variable for pin 13
int val=13;//i need this const to be value of pin 13
and if i remove the variable led and made it
pinMode(13,OUTPUT);
will variable (val) be a pin)?
if yes how do i keep it a value not pin7
thanks :smiley:

int led=13;
int val=13;

Both of these declare a globally-scoped integer variable, initializing its value to
the number 13. The name of a variable is arbitrary and up to you.

You can define that a variable is not to be changed:

const int led = 13 ;

And you can save space by using an 8-bit int type:

const byte led = 13 ;

But IMO better than these is to use substitution, via #define, which
doesn't create any variables(*) at all:

#define led 13

(*) BTW the compiler can optimize away the space for a const variable, so
you may not pay anything for using const int, but #define is so much more
visible in the code for when you want to go through and change some
constants. Its more flexible too as you can substitute an expression, not
just a constant.

It won't matter, it's how you use it.

example:
int led=13;//name for pin 13
int val=13;//value for pin 13

pinMode(led,OUTPUT);
digitalWrite(led, val);

poliguaco34:
i want to know how do i differe between a const for pin and a value for const
example:
int led=13;//i need this const to be variable for pin 13
int val=13;//i need this const to be value of pin 13

I don't understand what difference you are thinking about when you write these lines.
As they are written, both led and val are variables. You must put the word const before them to make them constants.

When they are variables you can change the value they contain whenever you like. So at one time led could contain the value 13 and at another time it could contain the value 7.

On the Arduino pin 13 happens to have an LED connected to it, but otherwise it is the same as any other Arduino pin.
The name of the variable (led in this case) does not matter. It could just as well be called littleYellowLight

and if i remove the variable led and made it
pinMode(13,OUTPUT);
will variable (val) be a pin)?

Again, I am not sure what is in your mind when you ask this.

if you have

int led = 13;
int val = 13;

then

pinMode(13, OUTPUT);
pinMode(led, OUTPUT);
pinMode(val, OUTPUT);

all do exactly the same thing. However if you change the content of val it will obviously relate to a different pin

val = 7;
pinMode(val, OUTPUT);

if yes how do i keep it a value not pin7
thanks :smiley:

I don't understand why you think there might be a possibility of it becoming 7 unless you write some program code to make it change.

You will probably learn more by trying these things out for yourself and observing what happens.

I have a few LEDs with a resistor soldered to one leg and an extra piece of wire soldered to the other leg so I can quickly plug them into the Arduino to see how pins are changing from HIGH to LOW etc.

...R