I have these two motion sensors that were given to me awhile ago. They take 10-30V (i'm giving them 12 regulated) and ouput 200mA which I have in the analog pins. I have them on voltage dividers so they don't output too much to the arduino pin...so they're outputting around 2V, giving me a steady serial reading of around 240.

I'm using the sensors for a kinetic sculpture...an object is raised by a pulley, when the top sensor sees the object, it gets lowered, when the bottom sensor sees the object it gets raised.

my problem is, is that sometimes the bottom sensor doesn't see the object and it continues to get lowered. this happens very sporadically...the motion could on for 2 hours and then all of a sudden miss a reading. if i wave my hand in front of it, it starts up again and everything continues. I need this thing to be able to run perfectly, though...for 8 hours a day for around a month.

any ideas why this sensor might not get a reading every once and awhile? any ideas for how I could tweak it so that it works better?

here is the codei put the sensor readings throughout the loop and it's been working straight for 2 and a half hours now. Is that a fix or are there other things i could do better?thanks so much for any feedback