untitled

(Elliott) #1
ahead, you put the toggle switch connected to the encoder Pin 10 in the
closed position and push the transmit button. To ask Sam to slow down,
you put the toggle switch connected to the encoder Pin 10 in the open
position and push the transmit button.

Use Q3and Relay 2to tell Sam to start or stop. Q3 is a transistor that
turns on when decoder Pin 13 is at 5 volts. Turning on Q3 by having the
start/stop transmitter toggle switch closed allows current to flow
through the coil in Relay 2 and connects Pin 4 (the output of Relay 2) to
Pin 8. This tells Sam to run his engines. When the start/stop transmitter
toggle switch is open and Q3 is off, no current flows through the coil in
Relay 2, and Pin 4 is connected to Pin 6; this makes the output of Relay 2
zero (0) volts.


IC3is an H-bridge motor controller. Although this controller is capable
of controlling more functions than just going straight ahead (as you can
read about in Chapter 11), all we need it to do here is supply the voltage
to drive each motor forward. The battery pack attached to Pin 8 of IC3
supplies power for the motors. You connect the output of Relay 2 to the
enable pins (1 and 9) of IC3. When 5 volts is provided by Relay 2 to the
enable pins, IC3 supplies power to the motors. When 0 volts is connected
to the enable pins, IC3 doesn’t supply power, so Sam just sits there.


The left and right sensorsallow Sensitive Sam to take control of himself.
When the track curves or Sam drifts so that one of the sensors is over
the black electrical tape, power is cut to the motor on that side. This
causes Sam to move away from the tape. When the sensor again hovers
over a reflective floor, power is restored to that motor, and Sam straight-
ens out.


On the schematic, the orange (O) and green (G) wires connect to an
LED, with R4and R6limiting the current to protect the LED from
damage. The blue (B) and white (W) wires connect to a phototransistor.
When the sensor moves over a reflective surface, such as hardwood
floor, the phototransistor is on, and the base of Q5or Q4is connected to
ground. This turns off Q5 or Q4, which leaves the output of Relay 3or
Relay 4connected to Pin 11, allowing the motor to run. When the sensor
is over a nonreflective surface, such as black electrical tape, the photo-
transistor is off, and the base of Q5 or Q4 is connected to a positive volt-
age through R7or R5,turning on Q5 or Q4. This disconnects the output
of the relay from Pin 11 and also shuts off the motor.

Chapter 13: Sensitive Sam Walks the Line 307

Free download pdf