■ FIGURE 8. Breadboard setup for Experiment 4.
■ FIGURE 9. Bottom view of modified touchpad.
Download TouchMoment.bas to
your breadboard setup. Whenever
you touch the on key, the red LED
should light; as soon as you withdraw
your finger, it should go out. When
the circuit is functioning correctly, try
sliding your finger back and forth
between the on key and the off key,
and watch the LED as you do so. You
will most likely find that you need to
slide your finger entirely off the on
key before the LED goes out. In fact,
you may even be able to light the
LED before your finger is actually
touching the on key at all.
Next, change the value in the
if…then statement to 150 and slide
your finger back and forth on the
keypad again to see the difference it
makes. This little experiment should
highlight the importance of properly
calibrating any touchpad sensors you
implement in a project. (Also, don’t
forget that each pin may require a
slightly different calibration.)
EXPERIMENT 4:
IMPLEMENTING TWO
LATCHED TOUCH-SENSITIVE KEYS
For our last experiment, we’re
going to modify the previous
experiment so that it implements two
latching keys. In order to do so, just
add a green LED (and a current-limiting resistor if necessary) to pin
C.0 on your breadboard setup (see
Figure 8) and modify the
TouchMoment.bas program by
adding two additional constant
definitions (LED_G = C.0 and
offKey = B. 2), one additional variable
definition (offVal = b0), and editing
the main do…loop so that it reads as
follows:
do
touch onKey, onVal
touch offKey, offVal
if onVal > 100 then
high LED_R
low LED_G
endif
if offVal > 100 then
low LED_R
high LED_G
endif
loop
Save the modified program as
TouchOnOff.bas, download it to your
breadboard setup, and test it out.
You may also want to experiment
with adjusting the calibration values
in the two if…then statements to see
what happens. For example, suppose
the two switches were controlling a
device for which an accidental on
condition would be much more
serious than an accidental off
condition. How would you want to
calibrate the two switches in that
situation? Also, what changes would
you make if the reverse were true,
i.e., an accidental off condition had
serious consequences?
EXPERIMENT 5:
MODIFYING THE
TOUCH KEYPAD
Even after I did a fair amount of
20
December 2010