Page 88 ·
Robotics with the Boe-Bot
Solutions
Q1.
Instead of holding a certain position like a standard servo, the Parallax
Continuous Rotation servos turn a certain direction at a certain speed.
Q2.
A millisecond lasts one thousandth of a second. Millisecond is abbreviated
"ms".
Q3.
The
DO…LOOP
command is used to make other PBASIC commands execute over
and over.
Q4.
HIGH
connects I/O pin to Vdd,
LOW
connects I/O pin to Vss.
Q5.
The variable sizes are bit, nib, byte, and word.
Bit – Stores 0 to 1
Nib – Stores 0 to 15
Byte – Stores 0 to 255
Word – Stores 0 to 65535 or -32768 to +32767
Q6.
Pulse width controls servo speed and direction. As seen on a timing diagram, the
pulse width is the high time. In PBASIC, the pulse can be generated with the
PULSOUT
command. The
PULSOUT
command's
Duration
argument adjusts the
speed and direction.
E1.
PAUSE
10000
E2.
The key to writing the variable declaration is to choose a variable size large
enough to hold the value 24. A Nib (nibble) will not work, since the maximum
value a Nib can store is 15. Therefore, choose a Byte variable.
counter VAR Byte
FOR counter = 6 TO 24 STEP 3
DEBUG ? counter
PAUSE 500
NEXT
P1.
The key to solving this problem is to send a pulse train to the LED as well as the
servo.
' Robotics with the Boe-Bot - Ch02Prj01_DimlyLitLED.bs2
' Run servo and send same signal to the LED on P14,
' to make it light dimly.
'{$STAMP BS2}
'{$PBASIC 2.5}
DEBUG "Program Running!"
DO