Introduction: Wizard Staff With Magical Light Effects
In this Instructable, I'm going to show how I built a Wizard Staff which lights up and interacts using an accelerometer a magnetometer and some magnetic reed switches.
I was inspired to build this staff after reading the Magical Dragon Head Wizard Staff Instructable and Chicago Dave's NeoPixel Compass.
For this Instructable you will need:
- Triple-axis Accelerometer+Magnetometer (Compass) Board - LSM303
- NeoPixel Ring - 16 x WS2812 5050 RGB LED with Integrated Driver
- Aduino I used an Adafruit Metro Mini due to it's small size
- 3 Magnetic Reed switches I picked these on Amazon
- Magnets to trigger the reed switches. I picked up these from Amazon.
- 6' or so of 2 inch PVC Pipe
- 2 inch PVC Union
- 3/4 inch PVC pipe (maybe 2')
- Three 3/4 inch PVC pipe unions
- Brown Spray Paint (I used Krylon Fusion for plastic)
- Silver Spray Paint (Krylon Fusion again)
- 9V Battery Holder
- 3 AA Battery Holder
- Heat gun
- Dremel
- Epoxy
- Silicon Calk
General Supplies such as:
- Wire, Solder, Soldering Iron, Computer to program the Arduino
Step 1: Making and Painting the Staff
Take the PVC and cut to the desired length. I opted for just about eye level. Keep mind that that you will add the PVC union and 'Globe' to the top of the staff.
The next few steps require power tools and heat, please use common sense and protective gear.
Once cut sand down the outside of the PVC and union to remove the printing on the PVC and roughen the surface for painting.
Using a heat gun, soften the PVC to put the desired bend in the staff. I did this mainly so my staff would look a bit less like a piece of PVC pipe and more like a staff. I recommend checking out this youtube video for tips on bending the PVC pipe. Once you have bent the PVC to your liking let it cool
After the PVC is cooled use dremel to score the outside of the pipe with vertical lines to give it a more natural appearance.
Next I painted the PVC pipe brown using the Krylon Fusion Paint and the PVC union Silver.
Step 2: Wiring the Arduino and Components
In this step we will wire up all the components except for the magnetic reed switches.
Wire according to the diagram shown, the magnetic reed switches are shown in the diagram but we won't make them until the next step.
Once this portion of the wiring is completed the Neopixel ring can be fitted into the 2 inch PVC union. I used hot glue to line behind the ring to hold it in place.
I used wooden BBQ skewers to suspend the Magnetometer/Accelerometer inside the ring. This was also secured with hot glue, although epoxy would work for a more permanent attachment.
Notes: I use 3 AAA batteries to power the NeoPixel Ring and a separate 9V battery to power the Arduino. The LSM303DLHC is driven off of the 5V output from the Arduino. The Metro Mini Arduino has the option to run at 3V as does the LSM303DLHC. I didn't want to mess around with that at this time, however it might be possible to do this to extend the battery life.
Step 3: Magnetic Reed Switches and Holder
The Magnetic Reed switches I use are somewhat delicate and I broke a few from rough handling while I wired them up. I recommend testing them after wiring them (voltmeter continuity testing should work).
The switches are set up like a momentary button and use a 10K Ohm pull down resistor. See the Picture and check the button tutorial from arduino if you're not familiar with this.
I wired up three switches as shown in the picture. I ended up tying the grounds from all three and the positives from all three together to reduce the number of wires which will eventually be running through the Staff. Make sure to leave a lot of length of wire for the wire which will run to the arduino. We can always cut it down later.
Once my switches were built, I put together a housing for them made out of three pieces of 3/4 inch PVC and three Unions. I assembled the PVC and unions one at a time, starting with the First Magnetic Switch. Once First piece of pipe and union were together and the switch inside, I filled that section of the pipe with Silicon Calk. I then repeat the procedure with the second piece of pipe, second union and second switch, joining them to the first piece and sealing them in place. Finally the procedure is repeated for the third and final pieces. Let the calk set up for several hours, preferably overnight.
Notes: Originally I tried epoxy to secure the switch but I couldn't get the switch to sit properly in the pipe. Additionally since I found the switches to be more fragile than expected, I thought that the silicon calk would holds them in place and supports them better than simply epoxying them in place. The silicon also seems to hold the PVC pieces together well enough, in final assemble of the staff the housing will be epoxied to the inside of the 2 inch pipe.
I didn't worry about debouncing the buttons in my sketch, but you can always modify the code if you find you need it. Check out the Arduino Debounce Tutorial for details
Step 4: Final Wiring
In this step we connect the wires from the magnetic reed switches to the arduino as show in the diagram.
At this step you can trim the length of the wires from the switches to an appropriate length. It is important to leave enough slack so that the battery packs and arduino can be removed for reprogramming.
It is also important to remember which color wire was used for each switch so that you know the position of the switch and which function it will trigger. If you mess it up you can always modify the sketch to assign any switch to any function.
Step 5: Upload Sketch
Upload the following Sketch to the Arduino:
You will also need the following Libraries:
- Adafruit_NeoPixel.h
- Wire.h
- Adafruit_sensor.,h
- Adafruit_LSM303.h
The Wire.h should come with the standard distribution and the rest can be picked up on GitHub
Notes: The Sketch is built to run one of three different modes depending upon which switch is closed by a magnet.
Button/switch 1 - Compass mode - Color of Neopixel changes depending on magnetic heading. If accelerometers detect a bump then it flashes a white light and fades back to the compass mode. Also called ''Gandalf" or "You Shall Not Pass" mode.
Button/switch 2 - Fade Up/Fade Down - Neopixels Brighten and then Dim. Cycle repeats until switch opens. Also called 'Tardis' Mode
Button/switch 3 -Flashlight - Neopixels turns on at full power and stay on until switch opens again.
There is no 'default' behavior, if the switches aren't closed then it does nothing. This could be easily changed if you prefer something more active.
Attachments
Step 6: Assembling Staff
The Staff assemble involves gluing the magnetic reed switch housing to the inside of the staff. It is important to layout all the components and determine how far into the staff the housing should go. Once you determine this it is important to 'dry fit' everything before applying epoxy. I found I needed more room than I initially thought and ended up moving the housing further into the staff.
Once you are confident in the 'dry fitting' mix up epoxy and coat the top of the housing on the unions. Then carefully slide the housing into the staff with the epoxy side up. It is useful to use a spare piece of 3/4 inch PVC to side the housing in. Once far enough in, rotate the staff until the glue covered side of the housing is in contact with the inside of the staff. Next let sit for several hours until the epoxy cures.
Notes: The idea is that only the housing will be glued into the staff. All the other parts will be able to be removed from the inside so we can reprogram the arduino if needed and change batteries.The housing will also support the weight of the batteries so they aren't pulling on any components.
Step 7: Gem Top for Staff
I used a transparent plastic christmas ornament as a 'Gem' to top the staff. They are available in several sizes from craft stores. I opted to fill mine with clear plastic beads to scatter light. I sealed the bottom of the ornament with silicon caulk, but hot glue or something similar would also work.
I tried several variations of this including painting the ornament with white paint, but I ended up liking the bead filled option best.
I attached the ornament to the top of the PVC union with silicon calk, Epoxy or other adhesives should work as well.
This is the final step, once the silicon calk is cured, it can be powered on an assembled.
I hope you enjoyed this instructable and leave comments if you have problems and I'll try to help out.