Figure 3 is the schematic diagram for Eye-Ear. Main
power is derived from a nine volt, 500 mA wall transformer.
Nine volts from the transformer goes directly to the carrier
board’s nine volt battery connector. Voltage is regulated
down with a LM7805; five volts for U1, all LEDs, and a
LM7806; six volts for the servos. C1 and C2 are electrolytic
capacitors to supply surge power during servo operation.
I used the analog output from the MaxSonar units that
goes to five volts when objects are at close range. The
sonar signal goes through an LM339 comparator for noise
rejection. The reference voltage
on pins 5 and 7 are set to about
0.4 volts — just high enough to
prevent false triggering on
background noise. Normally (no
signal), the comparator outputs
(ports 1 and 2) are low (LEDs on).
When the sonar signal
exceeds the threshold, the output
goes high which then goes to port
1 or 2 on the microcontroller. A
Pulse Width Modulation (PMW)
signal then goes to drive the eye
servos to control their position.
The power supply wires that go to
the servos and sonar are not
The Stamp 1 is used for the program written in PBasic.
The basic idea of the program is to rotate the eyes (servos)
back and forth about 180 degrees, while checking for sonar
signal inputs. A flow diagram of the program can be seen
in Figure 4. The PULSOUT (port#) pulse time is used to
control the servo position.
The Stamp controls the position of the servos from 100
(max CW) to 150 (center), then 200 (max CCW).
(For BASIC Stamp 2s, the pulse time may be 500, 750,
and 1,000 for similar positions).
My program starts with the counter set to 150 (center),
then the counter counts down (minus two count) to 100 at
the position of max CW. The IF statement
checks the count each time through the loop.
When the count is equal to or less than
100, the program jumps to the up count (plus
two) branch, and the servo goes to the 200
count, CCW. Finally, there is a “Check Input”
subroutine where the input from the sonar is
tested each time through the loop. The program
jumps to the right or the left, depending on
which input is detected (high).
This project (as are many of mine) is of an
artistic nature and does not conform to any
strict pre-arranged plans. As it goes, I have
boxes full of parts; I have an idea of what I want
to do; and I just have fun fitting things together
to achieve my goals.
If you look at the photos, you will see that
Eye-Ears is made of some common household
70 SERVO 11.2013
No C=> 200
Eyes index CW (back)
Pulseout = Counts- 2
Eyes index CCW (fwd)
Pulseout = Counts+ 2
Subroutine- Check In
If P1=1 then Max CW (back)
If P2=1 then Max CCW (fwd)