
218 Chapter 12 • Doing the Math
Averaging Data
There are situations when you may prefer that your robot base its decisions not
on a single sensor reading but on a group of them, to achieve more stable
behavior. For example, if your robot has to navigate a pad made up of colored
areas rather than just black and white, you would want it to change its route only
when it finds a different color, ignoring transition areas between two adjacent
colors (or even dirt particles that could be “read” by accident).
Another case is when you want to measure ambient light, ignoring strong
lights and shadows. Averaging provides a simple way to solve these problems.
Simple ...