micro:bit magic wand (intermediate)

 

“Any sufficiently advanced technology is indistinguishable from magic.” (Arthur C. Clarke). Heck yes it is! What are we waiting for, let’s use technology to create our own kind of magic!!

This project uses two micro:bit microcontrollers, a household cooling fan, and a few small electronic parts to create our very own magical wand. I chose to use the Wingardium Leviosa gesture, but you can most certainly adapt this project to cast other spells!

Please note that this is an intermediate project because it involves high voltage and current. Use proper safety protocols and always have another adult nearby.

Difficulty: Intermediate

Read Time: 15 min

Build Time: ~ 1 hr

Cost: ~ $40

Materials

  • Wand!
    • You can purchase custom wands or get creative and make your own!
  • Feather (for floating!)
  • Glove (for hiding the micro:bit wand controller)
  • One (1) household cooling fan (4A or less)
    • We do not modify the cooling fan so grab one you have around the house or borrow one from a favorite human.
  • One (1) extension cord
    • We WILL modify the extension cord, so use an extra one you don’t need or buy a cheap one.
  • Two (2) micro:bits
  • Two (2) micro:bit battery packs and two (2) AAA batteries
    • If you get the micro:bit Go bundle, it comes with a battery pack and batteries 🙂
  • Two (2) microUSB cables
  • One (1) PCB
    • Mine is 2cm x 8cm, any similar or larger PCB will work (but definitely do NOT use a breadboard as it cannot handle the high current)
  • One (1) solid state relay (JZC-11F)
    • Rated for 5Vdc input and 220/250 Vac and 5A output. You can use a different relay as long as it can switch

Magic? What! How??

One of my favorite scenes from the first Harry Potter book was when Hermoine makes a feather float with the spell Wingardium Leviosa. This simple spell captures the essence of why we love magic: that literally at the flick of our wrist and a few choice words, we can instantly make surprising (and impressive) things happen.

Although we don’t have exactly that kind of magic, we do have technology that sometimes seems miraculous. So that sort of counts! To mimic my fav scene, I wanted to levitate a feather. How can we move feathers from afar in real life? With wind!!

After building a beginner version of this project, I wasn’t 100% satisfied. I wanted to reach Hermione-level wizard status! So I designed a second version that can switch power for a large household fan.

This version uses a solid state relay to switch AC power with a DC trigger. You can imitate my design or, better yet, create your own! There are TONS of variations for this project that you can make with this basic framework, find a spell that inspires you and bring it to life!

This tutorial will show you how to do the following:

1. Write a simple block-based code for a micro:bit wand controller

2. Build a circuit to switch power for a 12V, 4A hosuehold fan.

3. Write a simple block-based code for a magical receiver that is triggered with a radio signal (aka bluetooth)

Code it: Wand Controller!

Let’s start with our magic wand!
We are using block-based coding via the Make Code website, but if you have experience w/ coding you can also program the micro:bit using micropython or C++ in your fav coding environment (e.g. Idle, Visual Studio Code, etc.).

Step 1: In the On Start block, set the Radio Group number. We’ll use the same number for the magical receiver micro:bit.

Step 2: Decide how you want your wand to trigger action.

The micro:bit has a 3-axis accelerometer, we will use this to set a gesture trigger.

Quick solution: Use the “on shake” block!

 

More complex, gesture-based solution:

Explore how the accelerometer works by printing to the Serial port with the “Serial write value” blocks (under the Advanced section). Open the Arduino IDE Serial Monitor to observe the micro:bit output as you make gestures. Use your observations to set triggers. (Code No. 2)

The example in Code No. 2 is my attempt at a Wingardium Leviosa gesture: swish-and-flick! (down in the z-direction and left in the x-direction). Use as-is or as a starting point for your own fav magical gesture!

Helpful Tips:

(1) Since microcontrollers process information super quickly, the pause block gives us time to finish the first part of the gesture before the micro:bit checks for the second part. 

(2) I added axes labels on the micro:bit so I could more easily figure out how to get the right motion for Wingardium Leviosa spell — definitely recommend this!

Step 3: Use the gesture to send a radio number (or string, just be consistent).

The “radio send string” and “radio send number” blocks are found in the “radio” block set.

Step 4: Download and save the code onto the micro:bit!

Build it: Magical Receiver!

Grab your second micro:bit, your PCB, your soldering iron, and all of the electronic parts!

Quick overview: We are using the micro:bit 3.3V power out to trigger the DC side of the relay. The circuit is completed when the micro:bit P0 pin switches on the NPN transistor.

Step 1: Solder the relay and transistor to your PCB board.

Step 2: Solder the diode across the relay DC power pins to protect the micro:bit from stray voltage when the relay coils switch. The negative side of the diode (grey line) should connect to the relay DC positive power in pin.

Step 3: Solder one jumper wire to the relay DC positive power in pin. Connect an alligator clip between this wire and the micro:bit 3.3V output pad.

Step 4: Solder another jumper wire between relay DC power out (GND) pin and the transistor collector pin.

Step 5: Solder the third jumper wire to the transistor emitter pin. Connect an alligator clip between this wire and the micro:bit GND pad.

Step 6: Solder your resistor to the transistor base pin. Connect an alligator clip between the other end of the resistor and the micro:bit P0 pad.

Step 7: Remove 1/2″ (2 cm) of insulation from the 14 gauge wire on both sides. Solder one wire to the relay NO (normally open) pin and the other wire to the relay COM (or coil 2) pin.

Step 8: Cut the extension cord on one side only, and remove ~ 1/2″ (2cm) of insulation from side of the cut wire.

Step 9: Grab the 14 gauge wire and slide a piece of heat shrink tube onto each wire.

Step 10: Line up one end of the 14 gauge wire with one end of the extension cord wire, then twist the metal together. Secure the heat shrink tube with your fav. heat source (e.g. lighter, hair dryer, etc.). Repeat for the other wires and heat shrink tube.

Note: Orientation of the AC wires does not matter.

Code it: Magical Receiver!

Time to code our magical receiver!

Step 1: Set Radio Group to the same number as for the Wand Controller.

Step 2: Pull out a “on radio received” block and set it to “receivedNumber” (or “receivedString” if you used that for your Wand Controller).

Step 3: Drag a repeat block into the “on radio received” block and switch it to repeat 2 – 4 times.

Step 4: (Optional but recommended) Show an icon on the micro:bit to let you know if it received the string.

This is super duper helpful if/when you are debugging.

Step 5: Turn on Digital Pin 0! (aka “digital write pin P0” to 1)

This block is found under the “Pins” block under the Advanced tab.

Step 6: Pause for a few seconds.

I chose 2 seconds, you can keep this or adjust as desired.

Step 7: Turn off Digital Pin 0 (“digital write pin P0” to 0) and the micro:bit display.

Step 8: (Optional but recommended) Add a back-up trigger using micro:bit button A for testing and debugging purposes 🙂

Voila! Download the code onto your Magical Receiver micro:bit and we’re ready for the magical prop!

Test & Debug!

And now, for our favorite part: testing!!

Power up your micro:bits (via battery or microUSB), plug in the extension cord and plug the fan into the extension cord, then move your wand controller to check that the magical receiver turns on the fan.

When you are done testing, coat the magical receiver connections in hot glue to hold them in place. If you want an ultra-permanent solution, use epoxy (waterproof is a nice bonus feature). Recommended to avoid covering the micro:bit in glue so you can use it for future projects.

Not working as expected?

1. Power is the most common issue for makers of all experience levels. Double check that all the things are plugged in. Use the micro:bit controller quick trigger to test that the receiver shows the “got message” icon.

2. Fan not moving? When the relay switches, you will hear an audible click. Use the micro:bit controller quick trigger and listen for the sound.

I did notice that the micro:bit 2xAAA battery pack was insufficient power to trigger the relay. I ended up just using the microUSB cable but a 3xAAA battery pack should also do the trick.

3. Use a multimeter to check continuity of your solder joints and, if necessary, voltage across the relay DC coils.

Build your magical prop!

Now that you’ve tested and practiced your magical tech abilities, you’re ready to build your magical prop! Use gloves to hide the micro:bit wand controller + battery pack.

For the magical receiver: Where do you want to put the feather and how can you hide the fan?

For my demo, I just hid the fan off camera (shhhhh don’t tell!!), but if you are doing your magical performance in-person you can build an enclosure to hide the fan. I found that window screen mesh worked great to help hide the parts while still letting air flow through.

Want to do other kinds of magic? You can build different types of props! This same setup will work to turn on any low-power AC device like speakers or a screen! Just be sure that the maximum current draw is less than 5A.

Go forth and be magical!

Heck yes, wizard level: intermediate!! Practice your gesture so you can really impress all the people. And of course, teach others how to do this technological magic!

Leave a comment if you need some help, have any questions, or to show off your creations!

Happy making, friends!

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.