For a final version we'll use a BBC micro:bit and the CRICKIT for micro:bit. We'll also write the code using MakeCode.
If you are new to Microsoft MakeCode, you can learn the basics of MakeCode here.
To add CRICKIT support, MakeCode needs to load an extension - to bring in some blocks that are not usually loaded in the main program. A detailed walk-through of how to do this for the micro:bit as well as a discussion of the CRICKIT blocks that the extension provides is here in the CRICKIT guide - scroll down to the "For micro:bit Crickit" section. You will need to use the beta version of MakeCode for micro:bit and add the extension web address manually. But it works well.
If you've read through the Python and/or C++ pages, the MakeCode program should look similar, but much simplified. For example, here is the
The stop function is a bit different. Instead of setting each servo to 0%, it sets the pwm pulse width. Remember that servos are all a bit different and can respond differently to an exact pulse width. In the Python and C++ libraries we can set the pulse ranges and stop will be in the middle. So changing the range will move the stop point. We don't have that capability in the CRICKIT MakeCode extension, so to stop we can set the pulsewidth directly. With a little trail and error we can find the setting for each servo that causes it to stop.
on button - pressed blocks are used to trigger one of two predefined movement scripts. Here's an example:
Here's the entire program, as well as a link to open it in MakeCode.