LDR - Keep getting a reading of 0 in the serial monitor

I have a bunch of LDR and I have used this example, directly connect the resistor to Analog 0 and GND, but I keep getting the reading of 0 in the serial monitor.

// declare a variable to store
// light dependent resistor
// reading
int ldr;

void setup(){//void setup begin
Serial.begin(9600);
}//void setup end
void loop() {//void loop begin

// set the value of ldr
// as analogRead(A0)
ldr = analogRead(0);
// pring the reading on serial
// monitor
Serial.print("ldr reading = ");
Serial.println(ldr);
// set 1 seconds delay to prevent
// flow of massive data
delay(1000);

}//void loop end

Since the purpose of this forum is also to make you think for yourself and not be a substitute for basic electonics knowledge:

  1. look up light dependent RESISTOR on wiki.
  2. think about what sort of circuit is needed for a resistor.
  3. put 1 and 2 together to figure out why an input pin is giving you 0 volts

There also is a disconnect between your AnalogRead comment and the AnalogRead statement.

I think you need to connect it so when there is low resistance, the pin connects to 5v, and when it's high resistance, it connects to gnd (or vice versa I guess). Related to the idea of pull up and pull down resistors. Or you could try and connect it between 5v and A0, with another resistor in series so it doesn't short when the LDR is low resistance. I think...

An LDR needs to be setup in a voltage divider configuration. If its value is 10K at
ambient light levels, then you should use a 10K pullup.

Other than that, wolf is 100% correct. You could have figured this out yourself in
30-seconds by doing a google search on how LDRs work. They're very simple. You
need to learn something about electronics if you're going to be doing electronics
stuff.

The other thing is, you need to buy yourself a DMM [look it up], and if you had one,
you'd have seen that the voltage on the ADC pin was always 0V.

Also, use the "code" symbol = #, instead of the quote symbol for code.

I read 0 in the serial port,too.
I normally can read my value in the serialport but when a delay function runs, I see zero.

int led=8;
int sensor=A0;
int sensorValue=0;
// the setup function runs once when you press reset or power the board
void setup() {
Serial.begin(9600);
pinMode(led, OUTPUT);
pinMode(sensor,INPUT);
}

void loop() {
sensorValue=analogRead(sensor);
// Serial.println(sensorValue);

digitalWrite(led, HIGH);
Serial.println(sensorValue);
delay(1000);
digitalWrite(led, LOW);
Serial.println(sensorValue);
delay(1000);

}

Resurrection of a seven year old post and a duplicate here:

https://forum.arduino.cc/index.php?topic=696153.0