Did You Know
Instead of having to hold down the A or B button, a script can make the Gripper complete a close-lift or lower-open maneuver open and close on its own after a button press-and-release. Simply put the statements updating the degrees variable and servo degree angle in a while loop that continues while the angle is greater than 30. A similar loop could also be written for button A that continues while degrees is less than 150.
Your Turn
- Use the image above to update the script, to make it gradually close and open the Gripper by just pressing and releasing the micro:bit module’s B and A buttons.
- Name your updated script test_gripper_angles_buttons_your_turn.