Page 312 - Hacking Roomba
P. 312
Chapter 13 — Giving Roomba a New Brain and Senses 293
Finally, to give a slightly different effect (suffusive glow instead of a point light), you can stick
the Arduino + prototyping shield into one of those tap lights that everyone seems to have and
use its diffuser to better mix the colors, as shown in Figure 13-27. You’ll have to snip out a
small section of the edge of the tap light to make room for the ROI cable. Of course, the
inner workings of the tap light have been removed so the tap function no longer works, but it
wouldn’t be hard to add back in and trigger some sort of action when the light is tapped by
hooking up the original tap light switch to a digital input on the Arduino board and using
digitalRead() on the input.
FIGURE 13-27: Arduino Roomba interface inserted into a tap-light for diffuse color
Listing 13-4: Additions to BumpTurn into MoodLight
int redPin = 9; // red LED
int greenPin = 10; // green LED
int bluePin = 11; // blue LED
int ledi = 0; // led loop counter
int redVal = 255; // brightness values to send to LEDs
int greenVal = 255; // start with all at full bright(==white)
int blueVal = 255;
void setup() {
pinMode(redPin, OUTPUT);
Continued