The code for this project is shown above and may be downloaded from the link below.
If you are new to Microsoft MakeCode on the Circuit Playground Express, we have a guide on getting you familiar with this great combination of hardware and software:
The code loops
forever, first moving the
servo motor from
0 degrees to
50 degrees (with a
pause between angle changes). Then the code waits
150 milliseconds and reverses the angle of the servo from
50 degrees back to
0 degrees. The movement is timed to be fairly fluid without being too fast or too slow.
If you find the movement too fast or slow, adjust the times of the
pause statements directly below the
servo write block. A small addition or subtraction will do, you do not want the wave to be super fast or so slow.
The switch on the battery pack is used to turn the project on and off.