SparkFun (#PRT-10007) and Adafruit (item #85). See
the Sources box website addresses for these and other
Here’s how the circuit works: Two cadmium sulfide
(CdS) photocells detect the amount of light falling on
them. This type of photocell exhibits a change of
resistance depending on the amount of light: The less
light, the higher the resistance; the more light, the
lower the resistance. For each CdS “eye,” a 22 kΩ
resistor turns the resistive output to a varying voltage
— the CdS cell resistor and the fixed resistor form a
voltage divider circuit.
The voltage produced at the junction between
these components stretches from between zero and
five volts. The outputs of the sensors are connected to
two of the AXE401’s analog inputs — the pins marked
B. 3 and B. 4.
The value of 22 kΩ for the resistors connected to
each CdS cell is determined experimentally. There are
no standards in CdS photocells, and their dark and
light resistance can differ greatly — even among
components of the same type. You’ll want to try different
values to determine the best sensitivity for the photocells
you use. You want the highest sensitivity while maintaining
the widest possible swing between zero and five volts.
(Note: The pin IDs reflect the nomenclature used on
the 28X2 chip itself, and are printed on the AXE401 board.
For your reference, the B is a port on the chip containing
many pins, and the 3 or 4 is a specific pin on that port. The
28X2 has three ports, labeled A, B, and C. There are
different numbers of pins available on each of the ports.)
Recall from last month that the L298 H-bridge module
requires two inputs per motor. The direction of the motor is
determined by the instantaneous value of these two inputs,
according to Table 1.
By setting the pins LOW (zero volts) or HIGH (five volts)
in programming, you can control the operation and
direction of either motor. You’ll see exactly how this is done
in the next section.
You may have noticed that the AXE401 contains its
own power plug and five volt voltage regulator — it even
has a second regulator for 3. 3 volts. For this project, we
won’t be using these features, as the Beginner Bot instead
draws its five volt power from the regulator on the L298
H-bridge that we’ve selected for the project. This power
drives the logic portion of the L298 module, and also
operates the AXE401.
This power connection arrangement simplifies the
wiring, but know that when it comes time to reuse
your AXE401 for some other project that it’s capable of
being separately powered using its own onboard
Phase 3 of the
added on top.
Figure 6 shows the completed Phase 3 of the Beginner
Bot, with AXE401 board, prototype expansion shield, and
populated mini solderless breadboard.
As with the Phase 2 version of the Beginner Bot that
demonstrated control using a hex inverter IC, the two CdS
photocells are mechanically attached to the front of the
mini solderless breadboard and poke out like snail’s eyes.
Precut and predrilled
Beginner Bot base, with all
software, sales (UK and EU):
AXE401 development board,
serial and USB download
cables for PICAXE:
Motor turns one direction
Motor turns the other direction
Mini solderless breadboards,
jumper wires, header pins,
*At the time of this writing, these
resources were not yet carrying
the AXE401, but they do stock
other PICAXE parts. Check for
SERVO 10.2011 73