Page 126 · Robotics with the Boe-Bot
This
loop sends 122 sets of pulses to the servos, one each to P13 and P12,
FOR...NEXT
pausing for 20 ms after each set and then returning to the top of the loop.
FOR counter = 1 TO 122
PULSOUT 13, 850
PULSOUT 12, 650
PAUSE 20
NEXT
causes the left servo to rotate counterclockwise while
PULSOUT 13, 850
causes the right servo to rotate clockwise. Therefore, both wheels will be turning
650
toward the front end of the Boe-Bot, causing it to drive forward. It takes about 3 seconds
for the
loop to execute 122 times, so the Boe-Bot drives forward for about 3
FOR...NEXT
seconds.
Your Turn – Adjusting Distance and Speed
√
By changing the
make the Boe-Bot move forward for half the time. This in turn will make the
Boe-Bot move forward half the distance.
√
Save BoeBotForwardThreeSeconds.bs2 under a new name.
√
Change the
FOR
√
Run the program and verify that it ran at half the time and covered half the
distance.
√
Try these steps over again, but this time, change the
to 244.
The
PULSOUT Duration
maximum speed. By bringing each of the
stay-still value of 750, you can slow down your Boe-Bot.
√
Modify your program with these
PULSOUT 13, 780
PULSOUT 12, 720
√
Run the program, and verify that your Boe-Bot moves slower.
loop's
FOR...NEXT
EndValue
...
loop's
NEXT
EndValue
arguments of 650 and 850 caused the servos to rotate near their
PULSOUT Duration
PULSOUT
argument from 122 to 61, you can
from 122 to 61.
loop's
FOR...NEXT
arguments closer to the
commands:
PULSOUT 12,
EndValue
Need help?
Do you have a question about the Boe-Bot and is the answer not in the manual?
Questions and answers