Getting Started With JavaScript Blocks: Magic Button Worksheet

Challenge 11

Watch the video - https://www.youtube.com/watch?v=-9KvmPopov8. It uses magnets to work.

Step 1

Head to the micro:bit website and go to the Let’s Code tab. JavaScript Block Editor.

Open the JavaScript Block Editor, you should see something like this.

Remove all the blocks by either dragging each block back to the library or selecting the block and pressing the delete key.

Self-Assessment

¨  I can load up the software on the micro:bit website.

¨  I can clear the workspace ready for building a new program.

Step 2

Program the following blocks.

You need to use a ruler and a magnet to test the micro:bits ability of measuring the magnetic force (µT).

Place the micro:bit 60mm away from the magnetic. Measure distance from the centre of the magnet to the middle LED. When you first run the program you have to move the micro:bit in a circle to set the micro:bit up. Complete the table below and plot the data.

Plan the different LED patterns needed for the different options of Rock, Paper and Scissors.

Distance between micro:bit & Magnet / Force measurement (µT)
60mm
55mm
50mm
45mm
40mm
35mm
30mm
25mm
20mm
15mm
10mm
5mm

Step 3

Using the information from your graph, give an evaluation of your results

Experiment evaluation

Step 4

Modify the program to the following,

In your own words explain what is happening, or use the website https://makecode.microbit.org/projects/magic-button-trick

Magnetic force loop

Step 5

Two inputs are needed for the program to work. If the A button is pressed and if isSwitched is true, then the string should display B, else display A. If the B button is pressed and if isSwitched is true, then the string should display A, else display B.

Screen print of working program

Self-Assessment

¨  I can Test and collect data

¨  I can Plot the results

¨  I can Evaluate the results.

¨  Use the compass feature to detect a magnetic field

Challenges

Well done for completing the Magic Button project. Think about some of the possible changes you can make.

·  Add an animation when above a certain magnetic force strength

·  A live read out option when “A+B” buttons pressed.

1

Ó micro:bit Educational Foundation 2016