hello,
in description of functions pinMode, digitalRead and digitalWrite the pin can be set through the numbers from 0 to 13 (or so; here it ist a Mega328 device), and near by the end of the function description there is a note in the reference:
The analog input pins can be used as digital pins, referred to as A0, A1, etc.
but what I don't understand: Pin numbers are integers and A0 ist a string. How can I specifiy the port number if I do't want to use the analog pins as analog pins but with their second purpose as additional digital one.
A0 is an identifier, not a string. "A0" would be a string.
The identifiers A0, A1 etc have been #defined in the system to the
actual pin numbers (which for the Uno are 14, 15, ...)
The only place you can use the numbers 0, 1, 2 as analog pin numbers
is as an argument to analogRead. analogRead will also accept A0, A1
etc too, so those names are more universal. Its probably least confusing
to stick to the names A0, A1, etc. (for instance you can iterate over
6 analog pins like this:
for (int i = A0 ; i <= A5 ; i++)
pinMode (i, OUTPUT) ;
which on the Uno happens to be equivalent to
for (int i = 14 ; i <= 19 ; i++)
pinMode (i, OUTPUT) ;
Also for completeness the following three lines are equivalent on the Uno too:
x = analogRead (A0) ;
x = analogRead (14) ;
x = analogRead (0) ; // special shorthand only analogRead recognises