Page 128 - The Definitive Guide to Building Java Robots
P. 128
Preston_5564C04.fm Page 109 Wednesday, October 5, 2005 7:22 AM
CHAPTER 4
■ ■ ■
Sensors
“The senses collect the surface facts of matter...”
— Ralph Waldo Emerson
4.0 Introduction
You’ll find that most of the programming logic for sensors is located inside the microcontroller
programs. The reason for this is simple: microcontrollers are much better at communicating
with these sensors than PCs. However, using Java programs to initiate and control the “sensing”
from these sensors has many advantages that will become more apparent in Chapter 7, which
discusses navigation, and Chapter 8, which tackles various advanced topics.
The types of sensors I’ll talk about in this chapter are
• Orientation Sensors (Compass): These devices allow your robot to know what orienta-
tion it has.
• Switch Sensors: These devices take logical readings of on or off.
• Distance Sensors: These devices allow your robot to measure the distance from itself to
the range of the sensor.
In this chapter, I’ll talk about three basic Stamp programs and four Java classes. But before
we get sensor readings, let’s talk about ways to connect your sensors to your microcontroller.
Connecting Your Sensors
Connecting sensors was probably the most difficult part of robotics for me. I started connecting
sensors with the typical copper-plated breadboard from Radio Shack ages ago. You can see a
few of my first circuits in Figure 4-1.
109