‘*** Program Constants
symbol servo_delay = 5
‘ Delay to slow down servo motion (30ms default)
symbol servo_min = 120
‘ \Set these values based on your servos
symbol Servo_MAX = 180 ‘ /
symbol reset_PIR = 5000
‘ 5k milliseconds is 5 seconds
symbol True = 1 ‘ \
symbol False = 0
‘ /Used for comparisons
The first of the inner loops
counts from ServoMIN to
This is where I set the minimum and maximum
positions for the servos. I also set a PIR delay to keep the
ghost from immediately retriggering if the person who set
it off is still standing in front of it when the motions are
complete. For program initialization, I set the position of
the two servos, LED eyes, and
sound board to TTL low so
everything will be off before the
Peek-a-Boo detects the presence of
a warm body. The program has one
main function and one subroutine.
The main function contains a loop
that waits for the PIR signal to go
high. When the PIR goes high, it
calls the WAVE_ARMS subroutine
that starts the sound board trigger
and causes the LED eyes to turn on.
The WAVE_ARMS function has three
for/next loops that cause the servos
to go into motion. The one outer
loop is used to set the number of
arm cycles (one cycle being from
eyes covered to eyes uncovered).
The two inner loops are used to
seek the arm servos.
September 2014 23
For those interested, a kit of parts for the Peek-A-Boo Ghost
will be available in the Nuts & Volts Webstore.