Hi all,
Can someone please either point me to the list that gives the Sequential numbers for the pins or tell me!
A0 = ? (on the Uno it's 14)
...
A15 = ?
Is it: 55 thru 69 for the Mega 2560 ??
Found it for the Uno, but cannot find it for the Mega 2560.
Example for Uno. (0-19)
Digital 0 = 0
Digital 1 = 1
Digital 2 = 2
etc ...
Digital 13 = 13
Analog A0 = 14
Analog A1 = 15
Analog A2 = 16
Analog A3 = 17
Analog A4 = 18
Analog A5 = 19
Thanks
-Enjoy
fh : )_~
68tjs
June 2, 2012, 1:50pm
2
Have a look on IDE files : hardware/arduino/variants/mega
All is in the "pins_arduino.h" file
Many Thanks ... And thanks for not just answering but pointing to the information.
So my guess was correct, If I had one in my hands I could of figured it out, I don't.
-Enjoy
fh : )_~
cmiyc
June 2, 2012, 8:53pm
4
Why are you using the pin numbers anyway? Just refer to A0 in your code.
Umm ... It's a bit difficult iterating alphanumeric.
-Enjoy
fh : )_~
cmiyc
June 2, 2012, 9:47pm
6
for(int pin=A0; pin<= A5; pin++)
int whatever = digitalRead(pin);
You could even start with digitial pin 2.
This code is more portable.
When reading the code it is very clear you are using the analog pin.
I agree with both your points ...
I'm sure that works to iterate analog pins, however I do not see how it works across the digital to analog boundary.
Example please that crosses the boundary.
As I see it:
int(13)=13 (Uno Digital 13)
int(A0)=54 (Uno Analog 0)
So the boundary is 13 to 54 ...
Am I missing something here ??
Thanks
-Enjoy
fh : )_~
cmiyc
June 3, 2012, 1:01am
8
Uno doesn't have 54 pins. A0 is 14, one more than 13.
That is EXACTLY my point ... So how does it work your way!
-Enjoy
fh : )_~
Use an array of pin numbers, that way you can iterate through pins in any order you like.
Rob
Yup, if one needs to iterate them in a predefined order that is not in align with pin numbering.
Otherwise it's a waste of space.
I'm still hoping James provides the example I asked for on his method of iterating pins 0 to A5 (or A15 for the Mega) ...
Thanks
-Enjoy
fh : )_~
Uno:
for (byte pin = 0; pin <= A5; pin++)
{ /* whatever */ }
Mega:
for (byte pin = 0; pin <= A15; pin++)
{ /* whatever */ }
Simple.
Looks broke, works broke ...
The code:
void setup() {
Serial.begin(115200);
}
void loop() {
for (byte pin = 0; pin <= A5; pin++) {
Serial.println(pin);
delay(50);
}
}
The results:
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
Didn't know the Uno had 60 pins!
-Enjoy
fh : )_~
FestusHagen:
Looks broke, works broke ...
Why does it look broke? I just tried on my Uno and got this, as expected:
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
You may want to review your experimental techniques.
And on my Mega:
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
Works perfectly.
FestusHagen:
Looks broke, works broke ...
...
Didn't know the Uno had 60 pins!
-Enjoy
You may also want to review your attitude.
Nick,
Before I forget AGAIN! Sorry for posting this in the wrong forum, Originally to me it was a Hardware question, it got turned into a software one.
Back at it ...
Ok, I have to say this ... I AM A FREAKING BONEHEAD!
I do not own a Mega, Yet I have one on my desk and I'm missing a Uno ...
The kids I'm helping (that I originally asked the Q for) were here earlier and must of grabbed the wrong one when they left.
So, after plugging in a Uno, I get 0-19 ...
As I walk away in shame!
-Enjoy
fh : )_~
system
June 3, 2012, 7:51am
18
Arduino mega 1280
Probably could be useful:
regards
Yes sir that would of been very helpful before I started this thread.
The very first answer was what I really needed to be told (and what I wanted).
The rest has been a waste of others time for the most part ... for that I apologize.
Then of course my test bed was flawed by stupidity.
But I did learn something so it has not been a total waste. Arduino C can iterate alphanumeric pin numbering!
Because they are defined somewhere.
I guess I need to take the time and read the Arduino source in complete to learn these little things.
Thanks
-Enjoy
fh : )_~