1. Case 01: Get into Danger

1.1. Purpose


  • To create a magic wand that can beat over the spider.

1.2. Materials

1.3. Background


With the sound of footfalls approaching in a quiet and dark gorge, Xiao En and his partners have left their magic school and got here for the first time. Suddenly a pair of red eyes shining in the grass in the front of them, oh, it is a guard of the insects! Let’s make a magic wand to expel the insects!

1.4. SoftWare


SoftwareMakeCode

1.5. Programming


Step 1

Click “Advanced” in the MakeCode drawer to see more choices.

../../_images/magicwand_case_01_02.png

We need to add a package for programming, . Click “Extensions” in the bottom of the drawer and search with “magicwand” in the dialogue box to download it. (Kindly note this package is still in the verifying process and pls search with “https://github.com/elecfreaks/pxt-magicwand “ before it’s ready)

../../_images/magicwand_case_01_03.png

Note: If you met a tip indicating that the codebase will be deleted due to incompatibility, you may continue as the tips say or build a new project in the menu.

Step 2

Drag and set the magic level block as primary; and set the infrared sending connection to P1.

../../_images/magicwand_case_01_04.png

Step 3

Drag the release magic once block into the while button P2 being pressed block as the picture shows.

../../_images/magicwand_case_01_05.png

Result

Press the button to activate the magic and if the moving spider was hit by the magic, it turns over and stops moving.

1.6. Exploration


How to play a sound while we use the magic.

1.7. FAQ


1.8. Relevant File