Take a look at the above
tutorials before continuing
to read this tutorial.

A key feature for any robot is being able to sense the world that surrounds it. As humans, we all have 5 basic senses: sight, touch, smell, hearing and taste. These 5 senses allow us to intrepret the world
in a way to ensure our survival. But what senses can we give a robot? Let's explore one of the most important senses for a robot, proximity sensing.
In this article we will continue our Building A Robot series with Part 3: The Proximity Sensor. The standard IR proximity sensor will be introduced and integrated into the robot we built in Part 1: The Chassis and combined with the motor control we developed in Part 2: Motor Control. The final product will be a robot that
can sense its surroundings.

Building A Robot: The Proximity Sensor - Demonstration

Building A Robot: The Proximity Sensor - Setup

Purpose & Overview of this tutorial
The purpose of this part of the Building A Robot is to integrated a standard Infrared Proximity Sensor with our robot so that it can sense objects that are infront of it. If an object is detected as coming closer to the robot, some LEDs should flash as the object comes closer to the robot until finally, the robot will turn around and 'flee' a short distance away.
To accomplish this goal, we will use our already existing PIC 18F252 combined with the SN754410 motor controller we put together in Part 2: Motor Control, and add a single GP2Y0A21YK IR Proximity Sensor. This is an analog sensor, so the PIC's internal 10-bit analog to digital converter will need to be used in order to incorporate the sensor data with LEd flashing and motor movement.