In the previous two chapters, we covered wheeled, tracked, and legged movement. Now your robot can move around. But what if you want the robot to sense the outside world, so it doesn't run into things? In this chapter, you'll discover how to add some sensors to help avoid barriers.
Your robot will take quite a beating if it continually runs into walls, or off the edge of a surface. Let's help your robot avoid these so that it looks intelligent.
In this chapter, you will cover the following:
Gathering the hardware
Connecting Raspberry Pi to an infrared (IR) sensor to detect the world
Connecting Raspberry Pi to a USB sonar sensor to detect the world
Using a servo to change the position of your sensor so that a single sensor can view a large field, eliminating the need for additional sensors
To find obstacles, you'll need some sensors. There are two choices and in this chapter I am going to show you how to interface with an infrared sensor and a sonar sensor...