Arduino Christmas Hat
![SAM_7269.JPG](/proxy/?url=https://content.instructables.com/F8S/ZXSX/K437DXOZ/F8SZXSXK437DXOZ.jpg&filename=SAM_7269.JPG)
![SAM_7270.JPG](/proxy/?url=https://content.instructables.com/FLG/XDB7/K437DXPE/FLGXDB7K437DXPE.jpg&filename=SAM_7270.JPG)
![SAM_7275.JPG](/proxy/?url=https://content.instructables.com/F0J/VHIM/K437DXPR/F0JVHIMK437DXPR.jpg&filename=SAM_7275.JPG)
![SAM_7281.JPG](/proxy/?url=https://content.instructables.com/FRB/7MNM/K437DXQ3/FRB7MNMK437DXQ3.jpg&filename=SAM_7281.JPG)
![SAM_7268.JPG](/proxy/?url=https://content.instructables.com/FJG/SF2Z/K437DXON/FJGSF2ZK437DXON.jpg&filename=SAM_7268.JPG)
![The Ugliest Christmas Hat Ever](/proxy/?url=https://content.instructables.com/FKV/ZSNP/K437DY7L/FKVZSNPK437DY7L.jpg&filename=The Ugliest Christmas Hat Ever)
The last time I ask someone to put an ugly sweater as a dare, he came up saying the sweater was not his size, so I though "How about an ugly Christmas Hat?".
With this hat there is not excuse available!!
This is a very cheap and small project that everyone can do at home, and the best part is that you can punish your friend and they cannot escape.
Suplies
![SAM_7097.JPG](/proxy/?url=https://content.instructables.com/F26/V0XJ/K437DXVJ/F26V0XJK437DXVJ.jpg&filename=SAM_7097.JPG)
![SAM_7098.JPG](/proxy/?url=https://content.instructables.com/FV4/ZUH4/K437DXVW/FV4ZUH4K437DXVW.jpg&filename=SAM_7098.JPG)
![SAM_7103.JPG](/proxy/?url=https://content.instructables.com/FRH/PX80/K437DXW8/FRHPX80K437DXW8.jpg&filename=SAM_7103.JPG)
- Material:
- Decoration:
- Hat
- Carboard
- Christmas Balls
- Carton
-
Garland
- Arduino:
- Arduino Genuino 1
- Cables
- Small Gear Moto DC
- Ultrasonic Sensor HC-SR04
- Buzzer
- RG led
- Resistance (for the RG)
- Battery Holder (6V)
-
DRV8833
- Decoration:
- Tools:
-
insulating tape
-
Silicone & Silicone gun
-
soldering iron & tin
-
Design
![SAM_7243.JPG](/proxy/?url=https://content.instructables.com/F22/QSGS/K437DZ2O/F22QSGSK437DZ2O.jpg&filename=SAM_7243.JPG)
![SAM_7247.JPG](/proxy/?url=https://content.instructables.com/F1R/68G5/K437DZ35/F1R68G5K437DZ35.jpg&filename=SAM_7247.JPG)
![SAM_7245.JPG](/proxy/?url=https://content.instructables.com/FS3/WMC5/K437DZ2S/FS3WMC5K437DZ2S.jpg&filename=SAM_7245.JPG)
![SAM_7241.JPG](/proxy/?url=https://content.instructables.com/FBU/X57K/K437DZ2K/FBUX57KK437DZ2K.jpg&filename=SAM_7241.JPG)
I draw and wrote the general idea, I want to achieve, of course, at the end there were some changes, but this draw as well as the flow chart helps me a lot to orientate myself during the making of the hat.
Cutting the Motor
![SAM_7123.JPG](/proxy/?url=https://content.instructables.com/FVH/EJ6T/K437E158/FVHEJ6TK437E158.jpg&filename=SAM_7123.JPG)
![SAM_7124.JPG](/proxy/?url=https://content.instructables.com/FW1/RMFO/K437E15F/FW1RMFOK437E15F.jpg&filename=SAM_7124.JPG)
![SAM_7150.JPG](/proxy/?url=https://content.instructables.com/F77/WVY4/K437E15L/F77WVY4K437E15L.jpg&filename=SAM_7150.JPG)
As the motor should be put vertical, we must do the botton as plane and stable as possible. That is why I folded the metal sticks and cut the plastic.
Moreover to avoid anything getting in the way of the motor gear I covered the motor with insulating tape.
Wiring
![wiring.png](/proxy/?url=https://content.instructables.com/F4L/AMGN/K437E09V/F4LAMGNK437E09V.png&filename=wiring.png)
![SAM_7151.JPG](/proxy/?url=https://content.instructables.com/FCM/LSWL/K437E1E8/FCMLSWLK437E1E8.jpg&filename=SAM_7151.JPG)
![SAM_7153.JPG](/proxy/?url=https://content.instructables.com/FA4/UXL9/K437E1EE/FA4UXL9K437E1EE.jpg&filename=SAM_7153.JPG)
![SAM_7158.JPG](/proxy/?url=https://content.instructables.com/FV9/YTFQ/K437E1EK/FV9YTFQK437E1EK.jpg&filename=SAM_7158.JPG)
![SAM_7162.JPG](/proxy/?url=https://content.instructables.com/F86/OX26/K437E1EQ/F86OX26K437E1EQ.jpg&filename=SAM_7162.JPG)
![SAM_7164.JPG](/proxy/?url=https://content.instructables.com/FVT/Z2PA/K437E1EX/FVTZ2PAK437E1EX.jpg&filename=SAM_7164.JPG)
![SAM_7168.JPG](/proxy/?url=https://content.instructables.com/FYD/67OS/K437E1IG/FYD67OSK437E1IG.jpg&filename=SAM_7168.JPG)
![SAM_7169.JPG](/proxy/?url=https://content.instructables.com/FSE/AAVS/K437E1IM/FSEAAVSK437E1IM.jpg&filename=SAM_7169.JPG)
If it is not totally clear, I am giving you the same but wrote also:
- Ultrasonic sensor
- Echo: 6
- Trigger: 5
- Buzzer : 7
- Motor:
- 12
- 11
- RG
- Green: 9
- Red : 10
I tie the cables going to the GND and the VCC respectively (except from the RG) to only one (one for GND and another one for VCC), so I gain space and use less cables.
I also use the insulating tape to join the RG led and the Motor.
CODE
![Nuevo Presentación de Microsoft PowerPoint.png](/proxy/?url=https://content.instructables.com/FV7/JBCA/K437DZZY/FV7JBCAK437DZZY.png&filename=Nuevo Presentación de Microsoft PowerPoint.png)
The main idea is :
- If someone put on the hat, the ultrasonic sensor will detect it.
- The Merry Christmas song will be played by the buzzer
- The led will be in red
- The motor will runs to spin the reindeer draw.
- If no one puts on the hat.
- The led will be in green
- No sound would be played.
- The motor is motionless.
I am uploading at the end the code.
I code everything so it works perfectly:
// we define every note we are going to play in the song
#define doh 261,626 #define re 293,665 #define fa 349,628 #define mi 329,628 #define sol 391,995 #define la 440 #define si 493,88 #define doa 523,241 #define rea 587,33
// define the pin of your RG #define GREEN 9 #define RED 10
// define the Pin were the Echo & Trigger will be const int Echo = 6; const int Trigger = 5;
// define the Pin where the Buzzer will be const int music = 7;
// define the Pins where the motor will be const int motor1 = 12; const int motor2 = 11;
void setup() { Serial.begin(9600); pinMode(Trigger, OUTPUT); pinMode(Echo, INPUT); pinMode(music, OUTPUT); pinMode (motor1, OUTPUT); pinMode (motor2, OUTPUT); pinMode (RED, OUTPUT); pinMode (GREEN, OUTPUT);
}
void loop() {
// the Distance will be show in the computer int cm = ping(Trigger, Echo); Serial.print("Distance: "); Serial.println(cm); delay(100);
if (cm < 7) { motorON(); RG_RED(); musica(); return(cm); }
else{ RG_GREEN(); motorOFF(); noTone(music); return (cm); } } void RG_RED() {
digitalWrite(GREEN, LOW); digitalWrite(RED, HIGH);
}
void RG_GREEN() { digitalWrite(GREEN, HIGH); digitalWrite(RED, LOW);
}
void motorON() {
digitalWrite(motor1, HIGH); digitalWrite (motor2, LOW);
} void motorOFF() {
digitalWrite(motor1, HIGH); digitalWrite (motor2, HIGH);
}
void musica() { tone(music, re); delay(500);
tone(music, sol); delay(500);
tone(music, sol); delay(250);
tone(music, la); delay(250);
tone(music, sol); delay(250);
tone(music, fa); delay(250);
tone(music, mi); delay(250);
tone(music, mi); delay(250);
tone(music, mi); delay(250);
tone(music, la); delay(500);
tone(music, la); delay(250);
tone(music, si); delay(250);
tone(music, la); delay(250);
tone(music, sol); delay(250);
tone(music, fa); delay(500);
tone(music, re); delay(500);
tone(music, re); delay(500);
tone(music, si); delay(500);
tone(music, si); delay(250);
tone(music, doh); delay(250);
tone(music, si); delay(250);
tone(music, la); delay(250);
tone(music, sol); delay(500);
tone(music, mi); delay(500);
tone(music, re); delay(250);
tone(music, re); delay(250);
tone(music, mi); delay(500);
tone(music, la); delay(500);
tone(music, fa); delay(500);
tone(music, sol); delay(1000);
tone(music, re); delay(500);
tone(music, sol); delay(500);
tone(music, sol); delay(500);
tone(music, sol); delay(500);
tone(music, fa); delay(1000);
tone(music, fa); delay(500);
tone(music, sol); delay(500);
tone(music, fa); delay(500);
tone(music, mi); delay(500);
tone(music, re); delay(500);
}
int ping(int Trigger, int Echo) { long tiempo, distance;
digitalWrite(Trigger, LOW); delayMicroseconds(4); digitalWrite(Trigger, HIGH); delayMicroseconds(10); digitalWrite(Trigger, LOW);
tiempo = pulseIn(Echo, HIGH); //medimos el tiempo entre pulsos, en microsegundos
distance = tiempo * 10 / 292 / 2; //convertimos a distancia, en cm return distance; }
Downloads
Hole
![SAM_7182.JPG](/proxy/?url=https://content.instructables.com/FMU/909C/K437E1OA/FMU909CK437E1OA.jpg&filename=SAM_7182.JPG)
![SAM_7170.JPG](/proxy/?url=https://content.instructables.com/FJ8/183D/K437E1O9/FJ8183DK437E1O9.jpg&filename=SAM_7170.JPG)
I make a hole in the hat,between the middle and the back. a rectangle of about 4,3cm and 1,7cm
Cut the Box
![SAM_7175.JPG](/proxy/?url=https://content.instructables.com/FVQ/TB0R/K437E1Z0/FVQTB0RK437E1Z0.jpg&filename=SAM_7175.JPG)
- I cut the Cartoon in 4 rectangles:
- 2 of 4,5 cm * 3 cm and the other 2 of 2cm*3cm
Join the Box
![SAM_7197.JPG](/proxy/?url=https://content.instructables.com/FY1/2X5V/K437E26R/FY12X5VK437E26R.jpg&filename=SAM_7197.JPG)
![SAM_7198.JPG](/proxy/?url=https://content.instructables.com/FMT/44X2/K437E26S/FMT44X2K437E26S.jpg&filename=SAM_7198.JPG)
Glue it, and stick it to the hat, the hole must be inside the box.
Stick the Ultrasonic Sensor
![SAM_7202.JPG](/proxy/?url=https://content.instructables.com/FCH/EOFZ/K437E2DN/FCHEOFZK437E2DN.jpg&filename=SAM_7202.JPG)
With the help of the insulating tape, you stuck it to the box.
Stick the Motor & RG
![SAM_7203.JPG](/proxy/?url=https://content.instructables.com/FOT/6V59/K437E2J3/FOT6V59K437E2J3.jpg&filename=SAM_7203.JPG)
![SAM_7205.JPG](/proxy/?url=https://content.instructables.com/FED/HK76/K437E2J9/FEDHK76K437E2J9.jpg&filename=SAM_7205.JPG)
They must be in the middle, I stuck they with silicone
Stick the Buzzer
![SAM_7207.JPG](/proxy/?url=https://content.instructables.com/FGI/MGXM/K437E2QW/FGIMGXMK437E2QW.jpg&filename=SAM_7207.JPG)
The buzzer can be stick wherever, but it must not be stick upside down, otherwise the sound will be very bad.
Battery Holder
![SAM_7209.JPG](/proxy/?url=https://content.instructables.com/FQA/BRMS/K437E2Z6/FQABRMSK437E2Z6.jpg&filename=SAM_7209.JPG)
Add the battery holder with its respectively batteries, and stick it as well as the Arduino Geniuno UNO
the battery holder I stuck it with silicone meanwhile the Arduino Genuino UNO I stick it with the insulating tape.
Draw the Reindeer
![SAM_7109.JPG](/proxy/?url=https://content.instructables.com/FL6/393L/K437E3B5/FL6393LK437E3B5.jpg&filename=SAM_7109.JPG)
Meanwhile I do all the electronic stuff, I encouraged my younger sibling to draw a reindeer using the cardboards. Isn't it cute??????
Cartoon to the Reindeer
![SAM_7217.JPG](/proxy/?url=https://content.instructables.com/FRS/UV57/K437E3KK/FRSUV57K437E3KK.jpg&filename=SAM_7217.JPG)
First it made a hole for the nose in the paper and the cartoon.
I do not want the reindeer to be constanly moving so I stuck it to some carton.
Electronics + Decoration
![SAM_7220.JPG](/proxy/?url=https://content.instructables.com/F53/KPS4/K437E3TK/F53KPS4K437E3TK.jpg&filename=SAM_7220.JPG)
![SAM_7221.JPG](/proxy/?url=https://content.instructables.com/FF5/M2RD/K437E3TN/FF5M2RDK437E3TN.jpg&filename=SAM_7221.JPG)
I stuck the reindeer to the motor.
My intention was to light the nose when the hat was worn, so I stuck it very near to the nose so the light do by the led, reach the nose.
Hiding the Electronic Part
![SAM_7223.JPG](/proxy/?url=https://content.instructables.com/FNF/N312/K437E4GL/FNFN312K437E4GL.jpg&filename=SAM_7223.JPG)
![SAM_7225.JPG](/proxy/?url=https://content.instructables.com/FTW/0CQ8/K437E4HA/FTW0CQ8K437E4HA.jpg&filename=SAM_7225.JPG)
As you could see all the electronic part make the hat kind of ... less "Christmas" and do not fit a lot .
So I hide it, by surround it (do not touch) with some garland.
In this way it looks much more beautiful and fits a lot with the theme "Christmas" :)
Christmas Balls
![SAM_7227.JPG](/proxy/?url=https://content.instructables.com/F4G/WL5U/K437E517/F4GWL5UK437E517.jpg&filename=SAM_7227.JPG)
![SAM_7229.JPG](/proxy/?url=https://content.instructables.com/FGA/HMN0/K437E51J/FGAHMN0K437E51J.jpg&filename=SAM_7229.JPG)
Finally I used the silicone to add some Christmas balls, that will hang from the hat, constanly moving.
ENJOY IT!!!!!!
![SAM_7281.JPG](/proxy/?url=https://content.instructables.com/F56/XD5N/K437E5DM/F56XD5NK437E5DM.jpg&filename=SAM_7281.JPG)
Thanks for reading !!
I just hope you have enjoyed it ,reading it, the same I enjoy it making it.