Arduino Mega + MaxSonar Ultasonic

Ultrasonic Range Sensor

I2C protocol5 volts

Sensors are an important component of building a robot. Knowing the distance to an obstacle in front of the robot is extremely useful. For example to avoid a collision. An electronic compass and GPS is not sufficient to avoid a collision. I have thus experimented with several distance proximity sensors.

The Arduino Mega used Analog pin 1.

Fritzing

Sketch