Lego + Arduino : Proximity Sensors

These small cheap devices (pic below) are extremely useful in many situations where you want to know is something is close by, whether that be an object or a black/white line etc.

IR Proximity Sensor

They work by sending out an IR beam and looking for it coming back. Therefore it has to reflect off a surface for it to work. In reality most surfaces will reflect back some of the IR. They have a small turn screw to adjust the sensitivity so that you could just detect objects very close by or look for ones further afield. The effective range is from around 3mm to 10cm – depending on the type of surface being reflected. The better at reflecting IR then the longer the detectable distance would be. The video below goes into hooking this up and using with our Lego projects, source code for the model built is listed below the video.

The Code

That’s it for now, in the next article we’ll look at how to hook up Lego Classic 9V motors to our Arduino’s so that we can give some “Brains” to our builds.