Datasheet

Chapter 5 Tactile Navigation with Whiskers
152Robotics with the BOE Shield-Bot
When neither whisker is pressed up against its 3-pin header, you can expect your Serial
Monitor to display two columns of 1’s, one for each whisker. If you press just the right
whisker, the right column should report 0, and the display should read 10. If you press just
the left whisker, the left column should report 1 and the display should read 01. Of course, if
you press both whiskers, it should display 00.
No whiskers pressed Right whisker pressed Left whisker pressed
Active-low Output : The whisker circuits are wired for active-low output, which means that they
each send a low signal when they are pressed (active) and a high signal when they are not
pressed. Since digitalRead returns 0 for a low signal and 1 for a high signal, 0 is what tells your
sketch that a whisker is pressed, and 1 tells it that a whisker is not pressed.
Create, save, and run TestWhiskers on your Arduino.
Reconnect the USB cable and set the 3-position switch to position 1.
As soon as the sketch is finished loading, open the Serial Monitor.
Leave the USB cable connected so that the Arduino can send serial messages to
the Serial Monitor.
Example Sketch: DisplayWhiskerStates
/*
* Robotics with the BOE Shield - DisplayWhiskerStates
* Display left and right whisker states in Serial Monitor.
* 1 indicates no contact; 0 indicates contact.
*/
void setup() // Built-in initialization block
{
tone(4, 3000, 1000); // Play tone for 1 second
delay(1000); // Delay to finish tone
pinMode(7, INPUT); // Set right whisker pin to input
pinMode(5, INPUT); // Set left whisker pin to input