Harry Potter IR Remote With Raspberry Pi
by coleminer31 in Circuits > Raspberry Pi
4216 Views, 17 Favorites, 0 Comments
Harry Potter IR Remote With Raspberry Pi
This instructable outlines how to make a simple Python script that is controlled by the Harry Potter universal remote control wand made by The Noble Collection. It requires a Raspberry Pi as the controller and a Flirc USB IR receiver in combination with the universal remote wand to control functions in the script.
I arrived at this solution after attempting to modify various wand-controlled devices that other people posted instructions for on Instructables, Hackster, and elsewhere. The most famous of these is the Rasberry Potter project produced by Sean O'Brien (https://www.raspberrypotter.net/about). The majority of programmable wand-triggered projects work by reflecting an IR light source off the tip of a wand, detecting the reflected light using the Raspberry Pi NoIR camera, and tracking that light using different computer vision algorithms. These projects do work, and the flexibility that computer vision based approaches enables really is magical. But the computer vision techniques all allow for some level of false detects, and I needed something more predictable.
My ultimate goal was to build a magic, wand-controlled treasure box that my sister could use as a prop in her first-grade classroom (both my sister and my mom are teachers, and they're the real magic). I started by recreating the Raspberry Potter project, but, as I've already noted, I had trouble getting rid of false detects. Classrooms are unpredictable places, to say the least. There's lots of various moving pieces that can reflect light or that might be light sources themselves, and you can't easily dim a classroom enough to get rid of potential sources that the computer vision algorithms will try to track.
I knew that I needed something encoded that could not be falsely associated with random light sources in the classroom. At the same time, I knew that I didn't want to build something like that myself. Luckily, The Nobel Company already makes a Harry Potter universal wand remote, and the Flirc USB receiver gives you the ability to associate any IR remote command with a keypress. By writing a python script that waits for a specific keypress, I was able to detect a command sent by the Harry Potter universal wand remote each time it was processed by the Flirc USB receiver. This setup gave me the control I needed.
You can see the results in the gifs I posted. In these videos, I use my harrypottercontroller.py script to drive a servo motor, which opens and closes the treasure box that will be installed in my sister's classroom.
Supplies
- Rasberry Pi 3b+
https://www.amazon.com/CanaKit-Raspberry-Premium-C...
- Flirc USB reciever
- Harry Potter Universal Remote Wand
Prepare the Raspberry Pi
I used a Raspberry Pi 3 Model B+ for this project, but the python script should work with other models. (And it will likely work with other setups that can run Python have a usb port, too.) You will need a keyboard, mouse, and display for your Raspberry Pi if you do not already have them.
Once you have your Raspberry Pi setup running, follow these instructions from Sparkfun to get started with Python.
Prepare the Flirc USB Reciever
Now that you have Python running on your Raspberry Pi, plug the Flirc UCB receiver into a USB slot on your board.
Follow these instructions to install the Flirc software on your Rasberry Pi.
Prepare Your Harry Potter Wand
You will need two AA batteries and an IR TV remote. When you have them, follow these instructions from The Noble Collection to start up your wand, practice some gestures, then program a certain gesture to match a code sent by your TV remote.
Pair Your Flirc and Harry Potter Wand
Now that you have your Flirc and Harry Potter wand setup, you need to pair them. You can do this through the Flirc GUI using these instructions.
https://flirc.gitbooks.io/flirc-instructions/conte...
Follow the "Advanced Pairing" guide to record an IR command, sent by waving your wand while it is in Control Mode, and relate it to a keypress. Then end the Flirc recording mode, open a Raspberry Pi terminal, and wave your wand again, looking to see if the keypress you programmed appears in the terminal.
You can also do this in the terminal without using the GUI by following these instructions.
https://flirc.gitbooks.io/flirc-instructions/conte...
This was my preferred method when working on the project, and it's the method I recommend if you are comfortable working in a Linux terminal.
Set Up Your Python Code (LAST STEP!)
First, download the harrypottercontroller.py Python script in this Instructable, or get it from the git repo here.
https://github.com/coleminer31/HarryPotterRaspberr...
Place the python script in the directory of your choosing, and open it up with the editor of your choice.
All you have to do is replace 'PUT YOUR CHOSEN CHARACTER HERE' with the Flirc character you paired with your wand. Then replace #DO SOMETHING HERE in the magic while-loop with a function you want to run. (Tip: you might want to make a function that breaks the loop after a certain key is pressed, so that you can avoid an infinite loop and properly stop the script.)
And that's it! Yer a wizard, programmer. You can now control Python functions with your wand. Just run the script and give it a whirl.
You can use this setup to drive any number of applications, from robotics to IoT. I'm looking forward to seeing what you create!