In this, we're gonna make a Magic Ball that uses a motion sensor and an RFID scanner to control the animations of the LED lights inside.
Step 1: Materials You Need
For this project, you're going to need the following tools and materials:
- An Arduino Uno
- An MPU-6050 Sensor with Accelerometer, Gyroscope, and Temperature sensor.
- An RC522 RFID Reader
- some compatible Tags (i used NTAG215s)
- 36 white LED
- 36 red LED
- 36 blue LED
- 8 NPN Transistors, i used IRF520
- Clear plastic ball, 16cm diameter
- Small breadboard
- 9V battery pack (6xAA)
- Lotsa cables
- 3D Printer
- Soldering Iron
Step 2: The Shell
The first thing we'll do is prepare the outer shell of the ball.
To do that, simply sand the inside of the plastic ball.
You'll be able to see the strokes you make sanding it, so take your time and to in small circles to have an even pattern.
Step 3: The Support Skeleton
The next thing we'll build is the support skeleton.
This skeleton will hold all of the LED in place and contain the rest of the electronics. It has an outside diameter of 13cm, so that there is around 1,5cm space between led and shell, which we'll fill with diffusing material. The RFID reader will also have to fit outside of the skeleton in the end.
For this I made a 3D model consisting of 6 ribs, with each rib having small clips on the side where the LED fit into.
As you can see, each rib has 18 clips, 6 for each colour.
As all of the ribs are identical, you can print one rib 6 times. You can already continue with the next step once you have a rib printed, to save time while the rest is printing.
Step 4: Wiring Up the LED
Now, we'll wire up the individual rib.
Each rib holds 6 white LED in center row, 6 red LED in one of the outside rows, and 6 blue LED in the other outside row.
Stick your LED into their appropriate clamps, and make sure to align the polarity of the LED so that each rib has a positive and a negative end, with all of those lining up too.
First, Solder each top three and eatch bottom three LED of each row together so they're connected in series.
After that, connect both positive ends of a row with a wire, and both negative ends, so that both parts are connected in parallel.
repeat for all 6 ribs.
Step 5: Connecting the Ribs
When you're done wiring each individual rib, it's time to connect the ribs to the battery pack
You can wire the positive ends of all blue and white LED rows directly to the 9V cable of your battery pack.
My red LED had a slightly lower voltage than my other LED, meaning i had to first connect all positive ends of their rows, and then connect that to the 9V with a resistor. If all your LED have the same voltage, you can skip this step.
Step 6: Wiring LED to the Arduino
Now, the transistors come into play.
Take your small breadboard and wire all the ground pins to your Arduino's ground.
Then, connect the Digital pins of your arduino to the middle pins of the Transistors. I used pin 1 to 6 for the white LED, and pin 7 and 8 for red and blue.
Now you can connect each negative end of your white LED rows to a their respective transistor, make sure to not mess up the order. Then connect the blue and red negative leads to their respective transistor.
Step 7: Connecting the Sensors
Now we'll connect the sensors.
The motion sensor connects easily, simply connect it's VCC to the 5V pin, Gound to Ground, and SCL and SCA to the SCL and SCA pins on your board
The RFID reader needs more wires:
(left is RFID, right is Arduino)
- SDA ->10
- SCK ->13
- IRQ is unused
- GND ->GND
- RST ->9
- 3.3V ->3.3V
Make sure the RFID reader's wires are long enough so it can be outside of the Skeleton
Step 8: Coding Time!
Now that we've connected everything, its time for the code!
To use the RFID reader, you'll need this Library: https://github.com/miguelbalboa/rfid, and the built-in SPI library.
To use the motion sensor, you'll need to use the built in Wire library, since it's an IC2 device.
While I won't paste my whole code here, I'll talk about parts of it:
To assign a unique animation to a specific nfc tag, I have the IDs of each tag saved into a variable, so that when the RFID reader reads a tag, it compares it's ID to the saved ones, and through an if-statement calls for the assigned animation function.
The motion sensor simply reads the value of any chosen axis, if the read value is positive the red lights are turned on, and if it's negative the blue lights are turned on.
Step 9: Closing the Lid and Final Flourishes
We're almost done!
To finish off the project, simply fold a plastic bag into each half sphere as diffusion material, gently place the inner ball into one half, and close the other half over it. Then you're done!
You now have the choice to package your NFC tags however you want, you could stick them into pages of an old book and let the pages act as the spells the ball is reading, or like i did, print out a few fake parchment sheets, write or draw on them, and stick the NFC stickers on the backside. Tadaa, you have your spells all set!
And with that, we've finished our project!