THanks for the response, I know what you mean. However, the pin mapping diagram doesn't say what is the chip and what is the arduino board. I haven't bought my arduino yet, so the schematics and diagrams are all I have to go by.
For instance, if on the pin mapping diagram, it was listed like this:
Pin Number: 35; Pin Name PL0; Mapped Pin Name: Digital Pin 49
(This is an actual pin on the 2560)
Which would you use to assign it to a variable, 35 or 49?
123Splat:
35 is the Amtel pin #.
D49 is the Arduino pin#.
Always use the Arduino pin #.
Ok. That seems fine except for you wouldn't set the int to D49, you would set it to 49.
The only place where that doesn't make sense is when I am trying to set some analog pins. For instance, one analog input I would like to use is labeled like this on the pin map diagram:
So according to that logic, I would enter this code:
//Initialize variables
int sensor = 0; // this is the analog pin for the sensor. using the 'mapped pin name' from the pin map diagram, which is "analog pin 0."
//..
//..
void setup() {
Serial.begin(9600);
pinMode(sensor, INPUT); // setting it to be an input
}
Now something about that seems wrong since I heard at one point that 0 and 1 was used for USB-serial connection.
retrolefty:
Perhaps the following pin mapping worksheet will help you out. Column 1 has the Arduino pin# you use in digitalRead, digitalWrite, and mode commands:
Where do you get those numbers in the first column? They don't match up with anything in the pin map diagram available from Arduino. Not saying you're wrong at all, just wondering where it came from.
The PD, PB, PC refer to the arduino port registers for direct addressing of i/o pins.
PORTD maps to Arduino digital pins 0 to 7
PORTB maps to Arduino digital pins 8 to 13
PORTC maps to Arduino analog pins 0 to 5
retrolefty:
Perhaps the following pin mapping worksheet will help you out. Column 1 has the Arduino pin# you use in digitalRead, digitalWrite, and mode commands:
Where do you get those numbers in the first column? They don't match up with anything in the pin map diagram available from Arduino. Not saying you're wrong at all, just wondering where it came from.
It came from the arbitrary abstraction that the Arduino platform defined in their 'core libraries'. There is no logical relationship between the AVR processor port and pin numbers Vs the Arduino abstracted pin numbers, it is what it is because they defined it as such.
They don't match up with anything in the pin map diagram available from Arduino.
Which map are you referring to? Can you post a link to what you are looking at.
Lefty
Scroll down the page and you'll see the big table with all the values I've been referring to. I just need to know which number to use when assigning variables to pins. Didn't think it would be so confusing.
123Splat:
35 is the Amtel pin #.
D49 is the Arduino pin#.
Always use the Arduino pin #.
Ok. That seems fine except for you wouldn't set the int to D49, you would set it to 49.
The only place where that doesn't make sense is when I am trying to set some analog pins. For instance, one analog input I would like to use is labeled like this on the pin map diagram:
So according to that logic, I would enter this code:
//Initialize variables
int sensor = 0; // this is the analog pin for the sensor. using the 'mapped pin name' from the pin map diagram, which is "analog pin 0."
//..
//..
void setup() {
Serial.begin(9600);
pinMode(sensor, INPUT); // setting it to be an input
}
Now something about that seems wrong since I heard at one point that 0 and 1 was used for USB-serial connection.
First you don't use pinMode commands to setup analog input commands, you just use the pin names A0 to A5 in the analogRead(x) , where x can be either 0,1,2,3,4,5 or A0, A1....A5. The 0 is not to be confused with digital pin number 0 which is a different physical pin. To make it even more confusing you can utilize analog input pins as digital input or output pins by using the normal digital input and output and mode commands but using arduino digital pin numbers 14 to 19. That is assuming we are talking about a 168/328 based chip as the mega1280/2560 uses different digital pin numbers to map to it's 16 analog input pins.
The numbers down the left are the physical pins on the chip. You need to use the "Mapped Pin Name" colunm.
The first line of that table, Digital Pin 4 on your Arduino Mega is pin 1 on the chip itself. PG5 is it's register address.
inboxjason:
The numbers down the left are the physical pins on the chip. You need to use the "Mapped Pin Name" colunm.
The first line of that table, Digital Pin 4 on your Arduino Mega is pin 1 on the chip itself. PG5 is it's register address.
ie
int pwmPin = 4; // Pwm from *Pin1* of MEga
See my coding example two or three posts up... the only problem with that is that the mapped pin name for the analog pin in my example is 0. So I'm not sure how using the mapped pin name can be the right number since I know for a fact that 0 and 1 are usb-serial ports..
EDIT: Here is the code:
//Initialize variables
int sensor = 0; // this is the analog pin for the sensor. using the 'mapped pin name' from the pin map diagram, which is "analog pin 0."
//..
//..
void setup() {
Serial.begin(9600);
pinMode(sensor, INPUT); // setting it to be an input
}
inboxjason:
The numbers down the left are the physical pins on the chip. You need to use the "Mapped Pin Name" colunm.
The first line of that table, Digital Pin 4 on your Arduino Mega is pin 1 on the chip itself. PG5 is it's register address.
ie
int pwmPin = 4; // Pwm from *Pin1* of MEga
See my coding example two or three posts up... the only problem with that is that the mapped pin name for the analog pin in my example is 0. So I'm not sure how using the mapped pin name can be the right number since I know for a fact that 0 and 1 are usb-serial ports..
EDIT: Here is the code:
//Initialize variables
int sensor = 0; // this is the analog pin for the sensor. using the 'mapped pin name' from the pin map diagram, which is "analog pin 0."
//..
//..
void setup() {
Serial.begin(9600);
pinMode(sensor, INPUT); // setting it to be an input
}
Also, Just thinking, that listed in the 'mapped pin name' section, there is a digital pin 0 and an analog pin 0, so if I say:
int newPin = 0;
Am I talking about the analog pin 0 or the digital pin 0?