Let's Make Robots!

infrared sensors

I've got two sets of phototransistors and infrared emitters put together to make two IR distance sensors. They are both connected in the same way, both powered by my Arduino Uno, both with the same resistor, etc. But when I check the values I'm getting from them, one of them ranges from about 980 - 1010, with the higher value closest to the sensor. The other, however, goes from about 350 - 570, with the higher value the furthest from the sensor.

In addition, I have a servo that is supposed to turn based on the the difference between the readings of the two sensors, so as to have motion tracking, or a basic emulation of it. The code is eesentially this:

if (difference between sensors > 0)

turn right

else if difference < 0

turn left

But it just tutrns to one side and stays, despite the fact that the values are constantly changing.

Can someone pelase help/point me in the right direction?

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

I have a feeling that you don't have any pull-up resistors installed.... Just gotta feelin'.

If you could take a clear, in focus picture of your set-up, we can help you much better.

I used that tutorial, OddBot, to help with this. My phototransistors are wired up in exactly that way. The emitters are just straight connectyed to 5v and GND on the appropriate pins. 

So Chris, I do have pull-up resistors, as OddBot's circuit diagram had, and other than that, its just straight Vcc and GND connections.