8. case 05 Shock Box#

8.1. Goal#

Make a shock box.

8.2. Material#

1 x basic kit 1 x Cardboard 1 x Hot melt glue gun 1 x Scissors 1 x Handmade knife

8.3. Background#

What is a shock box ?#

Want to be special? Let’s make a shock box and you will find more when you turn off the light.

How does it work?#

When micro:bit is received signal detected by crash sensor by basic:kit board, the servo turns and the shock box turns and shows different faces.

8.4. Practical operation#

Prepare a handmade knife, a hot melt glue gun, a scissors and a piece of cardboard.

../../_images/5fTCOyS.jpg

../../_images/OsrstYv.jpg

../../_images/t6A0IwP.jpg

Set up as below:

Make a little square box which has four special faces(You also could draw it by yourself). Make a little paper cover on the box and set the box on servo.

../../_images/XUKaZuB.jpg

Clip four pieces of the cardboard and cut the centre part of the four pieces, then place the four cardboard around the box. You could place them closely to the box and you could clearly see the faces.

../../_images/ZzkorKa.jpg

../../_images/bhjsZG9.jpg

Make a roof by cutting your cardborad and drill a small hole of the roof. Then thread light wire through the hole.

../../_images/EHVofkw.jpg

../../_images/xp7iEj5.jpg

../../_images/FwJVqmw.jpg

Set and stick components as below.

../../_images/OJpRAKH.jpg

8.5. Hardware connect#

Connect small LED to P0, servo ro P1, crash sensor to P2 and battaries pack to micro:bit. (as below)

../../_images/qIxyiCc.jpg

Please note the swith of basic:bit should at P0.

8.6. Software#

makecode

8.7. Programming#

Step 1#

Under “on start”,set pull pin P2 to up to keep signal stable. Set servo write pin P1 to 180, then the sticker board is at rest.

Set door as a variable, and its initial value is false for controlling turn of faces box.

../../_images/XGUcluA.png

Step 2#

Under forever, snap if statement to judge if the P2 port is equal to 0, it means if the sensor switch is pressed.

When the value P2 port is equal to 2, the sensor switch is pressed, set variable door to not door.

Then, snap another if statement to control the value of varible door, which means to judge the status of the door. If variable door is equal to true, then the show will turn and the light will up(P1=0).

../../_images/kcnU9rf.png

Step 3#

When the value of P2 is not equal to 0, the sensor switch is not be pressed.

Then, the box at rest(set P1 to 180) and light will off.

../../_images/Q8LsMmq.png

Program#

Please refer to detail programming:https://makecode.microbit.org/_M9M33fRYo9KY

You also could directly download program visit website as below:

8.8. Result#

Press the crash module, the box turns and shows different faces

../../_images/g0CMLx6.gif

8.9. Think#

How to make the faces box turns face by face ?

8.10. Questions#

8.11. More Information#