To move properly, our robot shouldn't be hindered by obstacles. A common solution to detect obstacles is to use an ultrasonic sensor. A sample sensor implementation is HC-SR04. You can get it from SparkFun: https://www.sparkfun.com/products/13959. You can see it here:
The HC-SR04 sensor has four pins: VCC (Power), Trig (Trigger), Echo (Receive), and GND (Ground), which are easy to connect to Arduino and Raspberry Pi.
Another sensor is the IR distance sensor. A sample sensor implementation is the Sharp GP2Y0A21 IR Distance Sensor, https://www.dfrobot.com/product-328.html, from DFRobot. Since I'm using the MiniQ Discovery Arduino robot, this sensor can be attached directly to the robot shield. You can see this here:
The GP2Y0A21 sensor has three pins: VCC, GND, and Signal. The Signal pin of GP2Y0A21 can be connected to analog pins from the Arduino...