photocells. This is the perfect chance to use our
breadboard’s DVM (digital voltmeter) to see the
junction voltage, so move the white wire to the
photocell’s center connection.
Check out my video demo at www.youtube
.com/watch?v=8gotiXIKFV8. This uses the same ADC
code given previously. Interestingly, this differential
sensor can’t determine the overall brightness level in
the room. That requires a third photocell joined to a
fixed resistor (as previously described) and another
Distance is not reliably measured by a simple
resistance sensor. Sharp makes sophisticated PSD
(position sensitive device) distance sensors which use
reflected IR, are amazingly accurate, and output an
analog voltage from 0. 4-3.2V.
Our PICAXE ADCs can easily measure these
voltages. Sharp’s model GP2Y0A21 is a typical version,
measuring 10-80 cm and priced from $7-$10 (with
cable). Per Figure 7, its voltage output is non-linear
and inversely related to distance.
Polarity does matter with this sensor, and the
three-wire cable is color-coded. The yellow output wire
goes to the ADC pin as shown in the opening photo.
A My Sharp sensor demo controlling a servo is at
sensor’s analog output fluctuates a bit using 4.5V of
alkaline batteries, making the servo a bit glitchy.
Sharp recommends adding a 10+ µF filter cap at
the sensor, but instead I did a software filter and
averaged 20 sensor readings before moving the servo,
which helped considerably:
servo 4,150 ‘ initialize servo on pin 4
do ‘ start loop
w1=0 ‘ zero average total
for b1=1 to 20 ‘ loop 20 times
readadc 2,b0 ‘ take ADC reading
w1=w1+b0 ‘ add all readings together
next ‘ end loop
b0=w1/20 ‘ divide total by 20
servopos 4,b0 ‘ update servo position
loop ‘ end loop
Now, we have the tools to make a simple robot.
Using just one servo, we can make an ultra-simple
mechanism to make our breadboard walk. It uses short
passive legs which nudge the robot forward as the servo
alternates lifting the left and right sides of the robot. It’s
clunky but cute. See the video at www.youtube.com/
You can see that I’m a scratch builder who favors
commonly available parts and copious amounts of Super
Glue™(thick, gap filling Super Glue and Zip Kicker are my
idea of “rapid prototyping”).
SERVO 11.2015 71