Write six procedures "p1" through "p6" that solve each of the 6 tasks
below. Do not define any other procedures, but use the primitive commands ("a," "on", "off",
"rd", "toggle", "switch 7", ...). Download your procedures as
menu options 1-6 and test them. We will provide the instructors'
Handy Board with correct versions of these procedures as example so
you can test to make sure you understand what they're supposed to be doing.
- a is on when switch 7 is pressed and off otherwise; b is on when switch 8 is pressed and off otherwise.
- switch 7 turns a on and b off, switch 8 turns a off and b on (in any order).
- Only one of a and b is on. Which one is on changes every time switch 7 is pressed.
Note: The following cannot be accomplished without mutable variables and/or concurrency:
- switch 7 toggles motor a, switch 8 toggles motor b (in any order).
- switch 7 turns on a for a second, switch 8 turns on b for a second. Switches active even when motors on.
- motors a and b go forward for 1 second, then backwards for 1 second. They repeat this behavior until switch 7 is pressed.