Analog Pins on Arduino Due

Hello,

I have a project that requires 16 analog inputs. I recently bought an Arduino Due, and at the page for the Due in the Arduino website it says that it has 16 analog inputs. However, I can't see A12-A15 on the board.

After a lot of help from the Programming Questions part of the forum, someone told me that the rest of the analog pins are on DIGITAL pins 20, 21 and 52 and that the last one is connected to an internal temperature sensor.

How do I analogRead() from pins 20, 21 and 52 if these are digital pins? I tried doing that and I got a relatively steady number around 760 from the ADC. Turns out, this pin is SHARED with A9! Can someone help me in this total sh*tshow?

OmerFlame:
I have a project that requires 16 analog inputs. I recently bought an Arduino Due, and at the page for the Due in the Arduino website it says that it has 16 analog inputs. However, I can't see A12-A15 on the board.

That page says you get 12.

The datasheet for the SAM3 says it has 16 and "One channel is reserved for internal temperature sensor" on page 3.

OmerFlame:
Turns out, this pin is SHARED with A9!

It’s not A9. Pin D21 of the Due board is connected to pin 87 of the 144 pin LQFP package which is connected to channel AD9 of the ADC. Arduino pin A9 is NOT channel AD9.

The ADC channel numbers are not connected to the analog pins of the Arduino with the same number.

OmerFlame:
How do I analogRead() from pins 20, 21 and 52 if these are digital pins? I tried doing that and I got a relatively steady number around 760 from the ADC.

First there is a hardware issue, pin D20 and D21 are SDA and SCL and have 1.5k pull-up resistors connected to them.

The Arduino files for the Due have been written to support 12 analog pins only. You will need to modify at least the following files.
..\AppData\Local\Arduino15\packages\arduino\hardware\sam\1.6.12\variants\arduino_due_x\variant.h
..\AppData\Local\Arduino15\packages\arduino\hardware\sam\1.6.12\variants\arduino_due_x\variant.cpp
..\AppData\Local\Arduino15\packages\arduino\hardware\sam\1.6.12\cores\arduino\wiring_analog.c