Go Down

Topic: Analog pins give ok digitalRead but peg to 5V on analogRead (Read 192 times) previous topic - next topic

areeves

I recently began working with an Arduino Mega 2560. It worked briefly, but when developed issues with the analog pins. As far as I am aware, I didn't short anything or otherwise improperly wire the arduino.

If I call an analogRead on any of the analog pins, the value 1023 is returned. This is true whether the pin is floating, tied to ground through a resistor tied to ground with no resistor, or tied to the 3V3 rail. Connecting with a potentiometer doesn't result in a change either.

A digitalRead still gives appropriate values - 0 if the applied voltage is low, and 1 if it's high. Confirmed both by tying the pins to 5V and then to GND, and by connecting a potentiometer and varying it.

My sketch is as follows:

Code: [Select]
int value;

void setup() {
  Serial.begin(9600);
}

void loop() {
  value = analogRead(A0);
  Serial.println(value);
  delay(100);
}


I have verified that the sketch and wiring are correct by testing them on an Arduino UNO that I have lying around.

I have attempted to label the A0 pin on the Mega as INPUT with no effect.

This is true for all analog pins on the Mega.

Please help me understand what's going on. I suspect the board may be bricked because I haven't been able to find any resources on this, but I would much prefer that not be the case. Any help would be much appreciated.


DrAzzy

Anything connected to AREF? Was anything in the past? (If you have external voltage on AREF, but call analogRead() without setting analogReference to external, it can damage the ADC)
ATTinyCore for x4/x5/x61/x7/x8/x41/1634/828/x313 megaTinyCore for the megaavr ATtinies - Board Manager:
http://drazzy.com/package_drazzy.com_index.json
ATtiny breakouts, mosfets, awesome prototyping board in my store http://tindie.com/stores/DrAzzy

Go Up