Figure 8.
Figure 9.
Figure 10.
Your left wheel will probably rotate. Change that
150 value until the wheel stops. Higher values make
it spin more forward; lower values make it spin more
reverse. Save that value as variable B2 — convenient
for the CR servo on pin 2. Next add SERVO C. 4, 150
between those two commands to null your right
servo. Since the right servo faces the opposite way as
the left servo (think about it), it responds oppositely.
We’ll need to use a servo extension cable to connect
our USB programming adapter since the right servo blocks
access (Figure 8). Cut the cover off of the male end to plug
into the breadboard per Figure 9. Don’t connect the cable
so that the three pins get reversed. Use the cable colors for
reference to keep the same orientation between the USB
adapter and the breadboard. You might want to fashion
some type of polarizer to make sure you get it right. I just
always make sure the white wire goes on top. Servo cables
are so cheap, I cut and hack them to connect sensors to
the breadboard as seen in Figures 7, 8, and 14.
Lower values make it spin more forward; higher
values make it spin more reverse. That concept takes a
while to grasp, but it’s another rite of passage, my fellow
roboticist. Know it, embrace it. Resist the temptation to
reverse motor leads in one servo. While that cheat will work
and arguably simplify your programming, your non-standard
code won’t be much help to others. Save that value as
variable B4 for the servo on pin 4.
We’ll use the SERVO and SERVOPOS commands to
control our drive servos. We must experimentally calibrate
the SERVO values to stop (a.k.a., null) each servo. It will be
around 150, but different for each servo. Mine were 139
Hard code your determined null values for B2 (left null)
and B4 (right null) early in your program with a pair of
SERVO commands to initialize your servos. Subsequent
changes will use SERVOPOS commands to update servo
speeds. Experimentally determine the right pairs of
SERVOPOS values for various maneuvers. For low speed
forward, start with values B2+ 5 and B4-5. Medium forward,
try B2+ 12 and B4-12. Full forward, try B2+40 and B4-40.
(left) and 138 (right). It probably seems funny that it takes
a precise pulse width to simply stop a servo, huh? Note that
the null point may drift as battery voltage drops, so always
calibrate using fresh batteries. Run this short program:
Test each speed and adjust values to drive straight. Then,
do the reverse. Low: B2-5, B4+ 5. Medium: B2-12, B4+ 12.
Full: B2-40, B4+40.
SERVO C.2,150 ‘ send 1.5 ms pulses to left
‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘ servo on pin C.2
do:pause 100:loop ‘ loop eternally, program must
‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘ always run to keep servo
‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘ pulses going
Turns in place? Slower is usually best for control. Try
these numbers: Left: B2-5, B4+ 5. Right: B2+ 5, B4+ 5. Arcing
turns can be done at higher speeds by tweaking those
numbers to slow one wheel down. I have a figure 8 and
multispeed demo video at www.youtube.com/watch?v=
aBgAEAjk0po that might help.
40 SERVO 01.2016