Introduction: Arduino Christmas Hat
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.
Step 1: Suplies
- 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
Step 2: Design
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.
Step 3: Cutting the Motor
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.
Step 4: Wiring
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.
Step 5: CODE
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; }
Step 6: Hole
I make a hole in the hat,between the middle and the back. a rectangle of about 4,3cm and 1,7cm
Step 7: Cut the Box
- I cut the Cartoon in 4 rectangles:
- 2 of 4,5 cm * 3 cm and the other 2 of 2cm*3cm
Step 8: Join the Box
Glue it, and stick it to the hat, the hole must be inside the box.
Step 9: Stick the Ultrasonic Sensor
With the help of the insulating tape, you stuck it to the box.
Step 10: Stick the Motor & RG
They must be in the middle, I stuck they with silicone
Step 11: Stick the Buzzer
The buzzer can be stick wherever, but it must not be stick upside down, otherwise the sound will be very bad.
Step 12: Battery Holder
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.
Step 13: Draw the Reindeer
Meanwhile I do all the electronic stuff, I encouraged my younger sibling to draw a reindeer using the cardboards. Isn't it cute??????
Step 14: Cartoon to the Reindeer
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.
Step 15: Electronics + Decoration
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.
Step 16: Hiding the Electronic Part
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" :)
Step 17: Christmas Balls
Finally I used the silicone to add some Christmas balls, that will hang from the hat, constanly moving.
Step 18: ENJOY IT!!!!!!
Thanks for reading !!
I just hope you have enjoyed it ,reading it, the same I enjoy it making it.