Pull up/down resistor for IR sensor input

Greets folks!

I have an Arduino project for an RC tank, this uses an IR sensor (for the time being a VS1838B) In use the tank may be operated with or without a sensor plugged in. With a sensor in everything works fine, but when it's removed the Arduino miss behaves giving random jittery output to my servos and eventually crashing the Arduino leading to the tank running away. I am assuming I should add a pull down resistor to keep this in check with no sensor plugged in but I'm not sure what to use such that the sensor will still work.

Thanks very much.

Drew.

Just enable the internal pull up resistor on that pin.

The datasheet for that sensor shows it should have a pullup anyway.

(Me picturing a tank running away…)

Thanks guys, I have set the input pull-up and it seems to have sorted the problem.

Fortunately these tanks only go at a slow jog pace so it's quite east to intercept, unlike one of my RC cars that went off at full throttle for about a kilometer, then across a busy road missing all the cars. Sadly it fitted under the crash barrier that separates the road from a 50M high cliff and the sea :fearful: There wasn't much left of it...

Thanks again Drew.

Sadly it fitted under the crash barrier that separates the road from a 50M high cliff and the sea

But it does paint a funny picture, although you probably don't see it like that.

This reminds me of a friend I knew in the 80s, he had written a very successful disk operating system for the BBC computer. He then went on to real time programming. One of his first jobs was writing software that controlled the chocolate enrobing process for a very well known ice cream bar here in the UK. He told me that if you made a mistake in an operating system you got a run time error, where as with the enrobing process you got half a ton of chocolate on the floor. :astonished: