Using the light strip for debugging the avoid behavior
LEDs in rainbows are fun, and switching colors looks nice. However, LEDs can be used for practical purposes too. In Chapter 8, Programming Distance Sensors with Python, we added sensors to our robot to avoid obstacles. You can follow along in a PuTTY window, and see what the sensors are detecting by reading the numbers. But we can do better; with the light strip, we can put information on the robot to tell us what it is detecting.
In this section, we will tie the LED output together to values from a behavior, first by basic lighting, and then by making some rainbow colors, too.
Adding basic LEDs to the avoid behavior
Before we get fancy and reintroduce the rainbow, let's start with the basic version. The intent here will be to make two indicator bars to the left and right side of the LED bar. For each bar, more LEDs will light when the corresponding distance sensor detects a closer obstacle. We'll make it so...