Case 06: Trebuchet
Contents
9. Case 06: Trebuchet#
9.1. Purpose#
To build a trebuchet.
9.2. Products Link#
9.3. Materials#
9.4. Background Knowledge#
9.5. Bricks build-up#
A detailed assembly instruction can be downloaded via the below links: Githubdownload
9.6. Software#
9.7. Code#
Step 1#
Click “Advanced” in the MakeCode drawer to see more choices.
In order to programme for the Ring:bit Bricks Pack, we need to add an extension. Click “Extensions” at the bottom of the drawer. Search “servo” in the dialogue box to download it.
Note: If you met a tip indicating codebase will be deleted due to incompatibility, you may continue as the tips tell or build a new project.
Step 2#
While button A being pressed, set the servo connected to P1 port turning 180 degrees and pause 300ms; then set the same port turning 90 degrees and pause 1000ms; set the servo connected to P2 turning 0 degree and pause 1000ms; then the same port turning 90 degrees and pause 1000ms; P1 turning 0 degree and pause 300ms; then the same port turning 90 degrees and pause 500ms; P2 turning 180 degrees and pause 1000ms and the same port turning 90 degrees and pause 1600ms.
Note: As the servo we used is in 360 degrees, the “servo” extension in MakeCode is suitable for servos in 180 degrees, therefore, setting the turning angle to 0 degree or 180 degrees will lead to the servo turning clockwisely or anti-clockwisely, and 90 degrees means to stop turning.
Code#
Link: https://makecode.microbit.org/_AM7FejLdJD2m
You can also download it directly below:
Result#
While button A being pressed, the trebuchet executes the launch order and will return to its original launch status automatically.