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.
Page last edited March 08, 2024
Text editor powered by tinymce.