AnalogRead causes an other pin to stop sending voltages

Hi guys,

I am facing the following problem in my Arduino project: I am driving a LED on pin A5 and I am reading a ldr on pin A0. Whenever I upload the code attached below, the LED is on, as it is supposed to. But as soon as I enter the function where it starts to read the values from the ldr sensor, the LED switches off, while it should still be on. The only way to switch the LED back on again, is by resetting the Arduino Uno.

Could this be a hardware limitation of the Arduino? I have tested it on two different Arduino Unos, it would be very weird if both are broken.

I have attached the code I am using below. For clarification: the LED stops working as soon as the analogRead function begins.

Thanks, Bas

#define statusLed A5
#define ldrBtn A4
#define ldrSensor A0

void setup() {
  Serial.begin(9600);
  pinMode(statusLed, OUTPUT);
  pinMode(ldrBtn, INPUT);
  pinMode(ldrSensor, INPUT);
}

void loop() {
  digitalWrite(statusLed, HIGH);

  if (digitalRead(ldrBtn) == HIGH) {
    int value = analogRead(ldrSensor);
  }

}

Please provide a schematic; a scan or photo of a hand-drawn one will do. Double check your wiring.

I did not connect a LDR, but the sketch does not show the behaviour on my RedBoard (Uno).

Stupid me! I connected the LED's negative lead to the AREF pin on my protoptype board. Problem solved!