Photoresistor values seem reversed

Hello

I am trying to read values off an LDR to control a simple photovore robot. My test code and connection diagram below :

int leftSensor=1; //LDR on analog pin 1
int leftSensorVal=0;

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

void loop()
{
  leftSensorVal= analogRead(leftSensor);
Serial.println(leftSensorVal);
delay(1000);
}

However, the values i get seem reversed. ie, as the intensity of light on the LDR increases, the values tend to come closer to 0, and vice versa. eg... under normal indoor light, values are 65, 67, 62...etc. Under bright light, values are 5, 3, 2 etc.

Is this the way its supposed to come out?

Thanks

Yes, as the light level increases, the resistance of the LDR decreases.

If you reverse +5V and Ground and leave the rest as is, the analogRead will return reversed values.

Always seemed confusing calling it a light dependent resistor, shouldn't it be 'dark dependent resistor' or maybe a 'light dependent conductor' ? :slight_smile:

I like light dependent conductor. Unfortunately, users don't get to name things very often. :wink:

reversed the connections and it came out fine. Thanks guys. apparently, i hadnt calculated a correct resistor for the circuit...