Working Harry Potter Wand With AI

by kunnalmardia in Circuits > Software

212 Views, 2 Favorites, 0 Comments

Working Harry Potter Wand With AI

Untitled drawing.jpg
718a184f-32dd-448a-b66d-a0413c3faccc.jpg
Lumos demonstration

At first, I was going to make a Harry Potter wand that would glow at the tip. After that, I decided, it would be cool if you could cast spells with this. So the result of that thought was this, a code that would harness the power of machine learning and find out which spell is being cast, and cast it. I hope you enjoy making your AI. I used Chat GPT to help with some of the code, so please be aware that I did not completely write it.

Supplies

download.jpg
download.jpg
images.jpg
download.png
download.jpg
download.jpg
download.jpg
61KhZCpqmYL._AC_UF894,1000_QL80_.jpg
download.jpg
download.jpg

Materials

1x Joystick

1x 2 color led

1x Push button

A few female-to-female jumper wires

1x 2 AAA battery pack with batteries

Aluminium Foil

wooden kebab skewer

Tools used


Soldering iron/ wood burner

3D pen(optional)

Hot glue


Software


I used pyCharm IDE with Python 3.12.2

Connecting the Electronics

ec0716fc-6c96-4396-a3c9-1b3571ff0ac6.jpg
24f3fec9-000e-46ba-9c69-d656e2ce6de4.jpg

You can skip ahead to step to step 5 if you bought a wand or have a pre-made one. Just attach a distinctive color like red or green to the front and start coding.

Here the connections are straightforward

First, you connect the battery's positive to the 5V of the joystick.

Next, you connect the VRX and the VRY of the joystick to the red and green legs of the LED.

Then you connect the ground leg of the LED to one side of the button.

Lastly, connect the remaining side of the button to the battery's ground.

You can refer to the pictures for any clarification, but the wiring is simple for this project and there is no soldering.

Connecting It to the Skewer

a04c1ee7-79e8-4165-82bf-09509c940c73.jpg
513b906b-72a8-4bf1-be36-cfe25391ff96.jpg
e181dbbf-157b-4f36-88f9-ca75f3f70d57.jpg
8d09ca55-6ef1-4e34-9c64-0a89c060f2e2.jpg
11cf9f7f-cb40-43fc-9e62-a0670a9520d0.jpg

This step is easy, but make sure the button and joystick are on opposite sides of the skewer around 1 inch apart. Also, if you want a shorter wand you can trim the edge of it. Also here I removed the joystick's cap because it was too large.

Wrapping It in Foil

92fc3284-73d2-4532-92e4-466359e332e7.jpg
d93fca9d-ea23-4b97-87e8-77d25b1715f2.jpg

Here you wrap the skewer in around 3-4 layers of aluminum foil. Be careful to keep an opening for the button, joystick, and LED so you can still control the colors of the light. Before wrapping it test that it displays the 2 different colors.

Adding the Surface

b4693823-7399-45e5-bd0a-3d5f365eb8c5.jpg
5c0dd34a-8885-4ab1-8eab-05e5296524af.jpg
57ad6606-def7-4119-a06d-aeef4e273022.jpg
4ddb506b-cb8f-493b-8d7b-9f784600ac1f.jpg
30897bc2-a333-43ba-9ae3-864dd2db42cf.jpg
73882176-1b8a-4a6a-9e02-7d0225d1321a.jpg
9fc6e32e-b63a-4996-a91b-aade28ee52b0.jpg
34c486fd-8a8a-4a3a-9bed-c3c661e04a34.jpg
02864aa3-72cb-42d8-84fe-ba3c36d1cc9d.jpg
eeb03659-56d0-4103-bf35-17d4479361bb.jpg
dfe88e04-d86e-47cc-a2a5-3f15510c9448.jpg

For this project, I used a 3d pen to make the surface. You can paint directly onto the foil, but I do not feel like it gives the project a finished look. My 3D pen was cheap(around $10), and there are better pens and more skilled people but I feel that the overall look is nice. After adding the filament, I melt and smooth it back down using a soldering iron and it makes a difference. After that, I just coated it with some paint and I was done. You can see that it can emit 3 different colors, red, orange, and green.

Collecting Data for the AI

43e2e3acee57a39738aa33ab2c458aa5.jpg
Nox training
Lumos Screen
Lumos Screen

So now we are going to start collecting data for our model. First, you can collect some data for the model for none. This is going to be so that the AI can recognize if a spell is not being cast. So each time run the program and hold the wand so that it learns if a spell is not being cast. For the Lumos spell, you can refer to the chart, and then change lines 77 and 80 from None to Lumos. Then you record yourself doing a lot of these spells using the code. Then you do the same thing for Nox. You should have around 70 pictures for each file. For this one, you have to install the libraries openCV2 and scikitlearn.

Downloads

Training the Model

As long as you saved the files as "Lumos", "Nox", and "None", all you have to do is run the code. If you want to you can run this multiple times and choose the one with the highest percentage. (Around 96 or 95 percent). For this one, you have to install the libraries keras, openCV2, and scikitlearn.

Downloads

Testing With the Model

Lumos Screen
Nox screen

Now you just have to run the code attached. This will turn the brightness to 100 if you cast Lumos, and turn the brightness to 20 if you cast Nox. For this step, you need to install the library screen_brightness_control. The video adjusted for the change in brightness, but you can see that it changed.

Downloads

Now Were Done!

WhatsApp Video 2024-04-03 at 8.19.51 PM

Now you can test around with these codes, and code some more spells, or modify the ones here. With this model, instead of making if change the brightness, I trained it to also turn on the light when running Lumos.