Using a photoresistor with arduino

I am using a photoresistor to measure light source, but when I put it in, nothing happens.
My code is

void setup() {

void loop() {
  Serial.println(analogRead(A0) * (5.0 / 1023));

Any help would be appreciated.

How are things wired?

Make sure you have a resistor (10k for example) from the 5v to A0 then the sensor to ground.

You need a source of volts to read it. This forms a voltage divider with a variable resistance being the sensor.



A forum rule of thumb is to post your code and a schematic of how you have things hooked up: it's well nigh impossible to help otherwise.

The use of a photoresistor in the voltage divider configuration is explained here at adafruit with code and schematic.

Actually, if you use Google you’ll find a multitude of examples.
It helps to put the word “arduino” at the beginning of your search to screen out PIC examples.

photo resistor examples with arduino