Hello, i recently bought an arduino Due. And while testing the analog input i found it isnt working properly.
However, before saying the analog ports are broken maybe there is something im not aware about the due.
The circuit is very simple. A resistor in series with a photoresistor and then ground. In front of the photoresistor there is a blinking led. So in serial plotter a kind of square wave should be observed. However the valued measured was always constant despite the switching on\off led.
This experiment worked perfcectly in an arduino UNO, so it isnt a circuit problem. Also triying differnt analog ports didnt help. And with analogReadResolution the number shown was bigger but always constant.
I hope there is somthing im missing and not a board issue. If you have any idea or recomendation let me know
int analogPin = 0; // potentiometer wiper (middle terminal) connected to analog pin 0
// outside leads to ground and +5V
int val = 0; // variable to store the value read
void setup()
{
Serial.begin(9600); // setup serial
}
void loop()
{
val = analogRead(analogPin); // read the input pin
Serial.println(val); // debug value
}
"The Due’s analog inputs pins measure from ground to a maximum value of 3.3V. Applying more than 3.3V on the Due’s pins will damage the SAM3X chip."
Leo..
Yes my mistake while writting, i only used 3,3. In fact in the images i attached from the UNO it can be seen that the read value never goes close to 1023(5V), it's alway much lower
ard_newbie:
A0 is definitly not 0, therefore to read A0 pin, you need a:
analogRead(A0);
And if you Serial print A0, you will discover what is its number !
analogRead treats small pin numbers as analog pins implicitly. Unless the Due
is different (hmm, don't remember this being the case, but its a while since I used my
Due).
ard_newbie:
A0 is definitly not 0, therefore to read A0 pin, you need a:
analogRead(A0);
And if you Serial print A0, you will discover what is its number !
Indeed it showed as 54, but the problem remains ....
When i move the potentiomer the only values that are returned are 512 or 768, and if i read from a pin without anything connected it shows as 512 constantly. I dont knowm, maybe there is a shortcircuit somewhere in the board???