Page 44 · Robotics with the Boe-Bot
√ Try changing the
PAUSE Duration arguments from 1000 and 2000 to 5000 and
10000, for example:
DEBUG "Start timer..."
PAUSE 5000
DEBUG CR, "Five seconds elapsed..."
PAUSE 10000
DEBUG CR, "Fifteen seconds elapsed..."
√ Run the modified program.
√ Also try it again with numbers like 40 and 100 for the
Duration arguments;
they’ll go pretty fast.
√ The longest possible
Duration argument is 65535. If you've got a minute to
spare, try
PAUSE 60000.
Over and Over Again
One of the best things about both computers and microcontrollers is that they never
complain about doing the same boring things over and over again. You can place your
commands between the words
DO and LOOP if you want them executed over and over
again. For example, let’s say you want to print a message repeating once every second.
Simply place your
DEBUG and PAUSE commands between the words DO and LOOP like
this:
DO
DEBUG "Hello!", CR
PAUSE 1000
LOOP
Example Program: HelloOnceEverySecond.bs2
√ Enter, save, and run HelloOnceEverySecond.bs2.
√ Verify that the “Hello!” message is printed once every second.