L
L
L
e
e
e
s
s
s
s
s
s
C
C
C
i
i
i
r
r
r
c
c
c
u
u
Now, to an the w whisk turn partic tactil touch There tactil count produ be usi auton whisk schem pictur HHHaaannnddd
Using Bot k (Chap Boe-B assem Using
so
o
o
n
n
n
3
3
3
1
1
1
:
:
:
u
u
u
i
i
i
t
t
t
we are g other cir hiskers. kers are a circuit cular, th le switch h to turn e are ma
le witche ting obje uction li ing them nomous kers are matically re: d
ddsss OOOnnn((P(PP
g the boo kit, follow
pter 5 pg Bot, the c mbled. B
g Figur
W
W
W
h
h
h
i
i
i
s
s
s
k
k
going to rcuit com
Essent a switch
t on and he whisk hes; they n on and ny uses es from s
ects on a ne to wh m for:
navigat represen y as the
P
PPaaarrrttt 111)) )
ok Robo w the in g. 166-1
circuitry Below is a e 1, crea
k
k
k
e
e
e
r
r
r
o move o mponent
ially the h that ca d off. In kers are y use d off. s for simply a
hat we w tion. Th nted e followin otics wit nstructio 167). On y associ a diagra te the ci
N E n t; e an n will e ng
h the Bo ons on a
nce the w ated wit am of th rcuit on
Needed:
•
Boe-• Com
Stam
• USB
• 2 – W • 2 - 2
Resi • 2 – 7 • 2 – ½
• Nyl
• 2 – 3 • 1 – W
• Mul
Est. Time
oe-Bot th ssembli whiskers th the wh he whisk n your B
-Bot mputer w
mp Edit B Cable
Whisker 220Ω 2
istors 7/8” Sc ½” Spac
on wash 3 pin He Wire ltimeter
e: 45 mi
hat came ng the w s are con hiskers ker circu Boe-Bot b ith BAS tor progr r Wires 2 – 10kΩ
rews cers hers
eaders
in
Figure 1: Diagram of Whisker Circuit Figure 2: Single Whisker
T
TTeeessstttiininnggg ttthhehee WWWhhihiissskkkeeerrrss s
Once you finish the whisker circuit assembly, run the following program. This will check if your whisker circuit is functioning properly. The program specifies that pin 5 and 7 are input pins by IN5 and IN7. The BIN1 is a formatter within the BASIC Stamp that tells the Debug Terminal to display values as 1 or 0 (on or off).
Now, hook a multimeter to monitor the status of the whiskers. The students can hook up the multimeter as shown in the picture with the wire coming from ground, or they could connect directly to the whisker.
Q: Does the multimeter reading change when the whisker is pressed? Is this change reflected in the output of the program above?
A: Yes the multimeter reading does change when the whisker is pressed. When the whisker is not pressed the voltage reading is approximately 5V, and when the whisker is pressed the voltage reading drops to 0V. This is reflected in the program; in the Debug Terminal, when the whisker is pressed the corresponding pin output is a 0 and when it is not pressed the output is a 1.
D
DDiiissscccuuussssssiiiooonnn
Let’s examine the circuit. You may have some questions that come to mind when looking at the circuit:
1. How do the 220Ω resistors affect the whisker circuit?
a. They do not affect the circuit. They are only in the circuit for safety precautions to prevent damaging the BASIC Stamp for draining the batteries. (For example, if pin 7 goes to HIGH then we have a direct short to ground if the 220Ω resistor was absent.)
circuit is not there. The Basic Stamp uses that portion of the circuit and acts as a multimeter measuring the
Voltage, Vo (Figure 2).
3.So what is the Basic Stamp/multimeter measuring when the whiskers are pressed and not pressed?
a. When the whisker(s) are pressed, the switch is closed, Vo
will go to 0V (Vo is shortened to ground) and the Boe-Bot
pin goes LOW.
b. When the whisker(s) is not pressed, the switch is open, Vo
builds to 5V and the Boe-Bot pin goes to HIGH.
H
HHaaannndddsssOOOnnn(((PPPaaarrrttt222)))
Earlier we mentioned that for our class we will be using the
whiskers as a navigation tool. In order to do this, we need is to be able to use the tactile ability of the whiskers to process being
touched and then change the Boe-Bot motion. This might sound difficult, but we are already half way there! We have already created a program that shows that the BASIC Stamp can detect when a whisker is being pressed. Now we need to write the program that can take that information and process it to change the Boe-Bot motion, thus, navigating by touch autonomously.
How do we make the BASIC Stamp process the touch and then change motion? We will have to use what is called an IF…THEN statement. This command allows the BASIC Stamp to make decision “if a certain condition, then do an action, else if a
different condition, then perform a different action” and so on till you end the IF statement. Thus, the syntax for the command is:
Teachers:
You might give the students just the program without the comments and have them comment their own programs. This will help to enforce how the IF…THEN
statement works and ensures that the
students understand the program. Also, this program calls for
subroutines very similar to the
subroutines we made for the PULSOUT command lesson. They should be able to write these themselves. So you could just give them the top half of the program.
Understanding the IF…THEN statement is important. It is a very useful programming tool that can be used in many different
applications (i.e. automated telephone calls: for directions in English press 1, for directions in Spanish press 2. This is basically an IF…THEN command. IF 1(English) THEN go to
directions in English, ELSEIF 2 (Spanish) THEN go to directions in Spanish, and so on).
Let’s put this program into our BASIC Stamp to see how the IF…THEN