Peculiar ldr problem

Hi, well got my robot to follow light, to see if everything was working fine, but the weird thing is, instead of changing direction in real time, it only changes direction when i reset my arduino board, same thing happens if i watch the serial monitor.


for example


it prints out 500 to the serial monitor

keeps printing 500, even if i change the light source.

i change the light source, and reset my arduino, then it changes to something like 200, and keeps printing 200 untill i reset my arduino again... this is really odd, i'm using the 0018 IDE.

anyone know how to solve this?

i have done another light following robot, this never happened...

thanks :D

Your code fails
I guessing here: your code reads and prints the DLR at boot up. Then it just continues to print your reading until a new boot occurs. Only then will it take a new reading.

I think it is not reading at

I think it is not reading at all.

Hook up something else that you know varies, and see if it reads that. Like short-circuting with your fingers or something. It should change in value if it is reading.

it’s reading, just not in

it’s reading, just not in real time, for some odd reason, i shorted it with my fingers and the serial print number changed a lot, same happened when i pointed my laser at the ldr.


here’s the loop:

void loop() {


if(analogRead(ldr1) > ldr2){





if(analogRead(ldr2) > ldr1){






it may be bad, i havent programmed my arduino since like november…

EDIT: after a few resets, it suddenly works, but as soon as i turn it off, wait a bit, and on again i have to reset it a few times… very weird