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:

What is the Code Doing?

The code loops forever, first moving the servo motor from 0 degrees to 50 degrees (with a .9 millisecond 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.

This guide was first published on Feb 05, 2019. It was last updated on Mar 18, 2024.

This page (Code with MakeCode) was last updated on Mar 08, 2024.

Text editor powered by tinymce.