uneven reading

I have a cny70 sensor connected as voltage divider and output goes to MCU and also to comparator. I'm building linefollowing robot. Even when the robot is not moving the reading show values from 50 - 100. It's weird because my last robot showed values from 243 - 248, when it wasnt moving.is there anything else that i can do? I appriciate your help, thanks.

You need to supply more information on your circuit, like a schematic or other detailed description. Also, it wouldn't have hurt to say what kind of sensor it was (optical reflective) and provided a link to a datasheet:

Do you have everything exactly the same as before? Did you arrive at the working versions circuit values by trial and error? Are you using the exact same type/model of sensor?

Here is the connection. I have 9 of these sensors on bottom of my robot. They for line recognition.all of them are digital but only two are analog. digital reading is fine, only analog is uneven.

cny70.jpg

So if you get a large reflection, then you want the LED off, right? That looks ok to me, you must have some AC hum on it or something. Can you look at it with a scope? Try averaging the values of say 64 samples and see if you get anything consistent out of it.

do you mean the same ac hum as in audio use to be?

It's just a guess, but yes like what you hear on audio equipment. It could be plenty of other things too. Perhaps you have fluorescent lights in the area now that weren't around before? You'd have to look at it on a scope to be sure of anything though. Do you have a wall-wart plugged into the bot that wasn't in there before? They can be a source of noise on the power.

It was the ac hum. It works fine after averaging 64 values. Is there a way to fix hardware. i think the ac hum is made by 3.7V to 5V booster.Might that be problem? I'll try to power it different way. if it was a problem, would there be a way to fix it without removing the booster?

It's probably switching noise from the booster. You could try adding some bypass caps to the output of the booster to help route the noise to ground. Add .1uF caps to the output of the booster and near the power (Vcc) pin of the CPU. What frequency does the booster use for switching?

i don't know abouth frequency. I bought this: Radio Control Planes, Drones, Cars, FPV, Quadcopters and more - Hobbyking . the is no datasheet. but i'll try those caps.