Pages: [1]   Go Down
Author Topic: Basic Referencing Quesiton  (Read 452 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 2
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi all,

First time on the forums, sorry to ask such a basic question however when things aren't working I need to ensure I'm referencing the right thing before I start trouble shooting other options. Next to no Arduino experience but I'm trying to read a sensor value from some analogue pins. I'm using a ATMega2560 and the signal pin is currently plugged into PF6 which according to the pin mapping is Analogue Pin 6. I'm just trying to double check what reference I should be putting in to gain a value from it via analogueRead(). Should it be PF6 the ATMega name? A6? AN6 which is printed on the board I'm looking at? I've just tried a few different things with seemingly no result, just wanted to double check.

Thanks all.
« Last Edit: October 03, 2012, 06:12:25 pm by Peleus » Logged

Offline Offline
Edison Member
*
Karma: 32
Posts: 1382
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Just a 6, AnalogRead() knows you are using an analog channel:
float value = analogRead(6);

The reference is helpful:
http://arduino.cc/en/Reference/AnalogRead
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 2
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks for posting that reference. Still finding my way around the site so it's handy to know things like that are around for functions.

I looked at the example here http://arduino.cc/en/Tutorial/ReadAnalogVoltage which had A0 which lead to some confusion (along with ANx being printed on the board).

Much appreciated.
Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 601
Posts: 48543
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

The A0, A1, A2, etc. names are aliases for the analog pins being used as digital pins.

While the functions that deal with analog pins have been modified to accept A0, etc., the value of A0 is 14 on a 328 based Arduino, and 54 (or thereabouts) on a Mega. In my opinion, they look silly in analogRead() calls. The analogRead() functions should be called with (in my mind) a value between 0 and one less than the number of analog pins on the board.
Logged

Pages: [1]   Go Up
Jump to: