Introduction: Arduino Celebration Hat
As a way of celebrating my 1000 subscriber milestone on YouTube, I made myself this celebration hat with two flags that wave automatically.
The hat is a great party prop or an excellent addition to your sports cheering gear to show better appreciation to your favorite sports team.
Arduino Uno - https://s.click.aliexpress.com/e/_d81uCo2
9g Servo Motor - https://s.click.aliexpress.com/e/_d6sziDG
Soldering Iron - https://s.click.aliexpress.com/e/_d8wg1iS
Breadboard wires - https://s.click.aliexpress.com/e/_dZAdsdG
Sports hat - https://s.click.aliexpress.com/e/_BfjoalzY
Bamboo skewers - https://s.click.aliexpress.com/e/_dYYrKwq
Step 1: Prepare the Servos
The 9g servos that I use come with two different attachment arms for different uses. Mine had the cross arms attached so I removed them by removing the center screw and I replaced them with the one-sided arms.
They will be better for this application as they will not stick out of the bottom when placed on the hat.
Once the arms were in place, I tested the servos with the basic sketch in Arduino to verify that they both work.
Step 2: Attach the Flag Poles
With the servo arms ready, I added rubber bands to the servo arms and used two bamboo skewers as the flag poles.
The entire project is just a prototype so I didn't bother to secure them better. If I were to use the hat outside or maybe at a sports game, I would have probably glued them in place with hot glue.
The rubber bands also provide a sort of amortization to the servo motors while programming and testing the animations as they do not stress it too much when the pole hits something.
Step 3: Attach the Flags to the Poles
For the flags, I've used two of my channel stickers that are stuck back to back to each other, trapping the pole in the middle.
Fell free to use your country or your favorite team flags here as this step is completely dependent on the occasion that you want to celebrate.
For birthday parties you can make some numbered flags or just simply be creative use your imagination. Feel free to show me your creations in the comments.
Step 4: Prepare and Attach the Trigger Button
The servos movement triggering is controlled via a push button that I wired with a longer cable. This way, the button can be routed through clothes to have it in your arm or place it anywhere you want.
On the end that attaches to the Arduino, I've directly soldered a 1KOhm resistor that is attached to ground as a pull-down resistor to prevent any floating voltage.
The servos are controlled through pins 9 and 11 and are powered from the 5V output on the Arduino while the input button is attached between pin 7 and the 3.3V output on the Arduino. This is enough for it to recognize it as a HIGH and trigger the code.
Step 5: Program the Movements
You can find the code for the hat as I used it on the Github repo:
There are three animations: swing, reverse swing, and random. When the button is pressed, one is chosen at random and executed. Once the animation stops, the servos are reset to their middle position and get ready for their next move.
Feel free to use this code or modify it any way you want.
Step 6: Assemble the Hat
Once everything was prepared, I used a bit of hot glue to stick everything to an old hat that I had laying around.
The Arduino is stick to the back so it is generally out of sight while the servos are glued to the top of the shade in the front.
I didn't bother to hide any of the wires, but if you want to make this a more permanent project, you can sew the wires into the hat. Also, you can use some smaller board other than Uno and also sew it into the hat to make it nicer.
Step 7: Have Fun!
I hope that you liked this project and that if you choose to replicate it you will have a ton of fun using it.
I definitely had great fun and my kids loved it. Being in quarantine at the time of writing this because of COVID-19, it is of a great importance to keep up your mental health and stay positive.
To everyone that is a subscriber I want to again say THANK YOU and for the rest, I suggest that you check out my channel and maybe subscribe. I do weekly videos of electronics, code and making in general so I'm sure you'll find something of interest.
Stay safe and thank you!