Skip to content

EMP Charge

Key details

  • Shake the device vertically (gently) for 30 seconds to charge, it will beep when charging.
  • Once charged it will beep differently; pressing A+B will then start a 5 second countdown.

Bill of materials

  • BBC micro:bit; a V1 micro:bit is fine but a V2 will offer sound.
  • BBC micro:bit battery power box.
  • Craft materials if you want to make it look interesting.

Click here for the completed code.

Here is an example of the emp device using a 3D printed back plate (here) mounted to a plastic tube box.

example

example

Explanation

The code for the EMP charge is relatively straightforward. When charging, the BBC micro:bit checks once per second for the shake gesture. If a shake is detected, the charge level is increased and a sound made. If not shaking is detected then the charge level is reduced.

Once maximum charge limit is reached, the EMP switches into charged mode. At this point, the charge level will stay at maximum and not drop over time.

The user can press the A+B buttons and the EMP countdown will begin from 5 seconds. Once the time runs out, the charge is dispersed and a jingle is played.

Instructions

Setup the following variables:

screen shot

Add the following code:

screen shot