We already have most of the code in place due to the testing we did earlier using the buttons. All that's left is to automate operation of the wings. We can use the accelerometer on the Circuit Playground Express to trigger their extension and retraction.

When freefall is detected, the wings should open. When it lands (which we can sense by the impact), they should close. The MakeCode accelerometer support blocks provide precisely what's needed. The code is shown below. Since extending and retracting the wings is done in multiple places, the servo operations have been moved into functions that are then used as required. You can select function blocks under ADVANCED then the FUNCTIONS block group.

This guide was first published on Aug 01, 2018. It was last updated on Aug 01, 2018.

This page (Code) was last updated on Mar 12, 2021.

Text editor powered by tinymce.