Introduction: Arduino Sorting Hat
You will need the following
- 1 yard brown fabric (we used fleece)
- Construction paper (for supporting the hat brim, can substitute with other material)
- Arduino board
- Breadboard or perfboard
- 2 9V batteries
1 push button
- 10 RGB LEDs
- 20 330 ohm resistors (dependent on your LEDs)
- 10 360 ohm resistors (dependent on your LEDs)
3 PNP transistors
3 NPN transistors
- 3 3K ohm resistors (dependent on your transistors)
- 3 22K ohm resistors (dependent on your transistors)
Step 1: Making the Body of the Hat
Cut out the top hat shape so that it is 17 inches tall and 15 inched across. You will need two pieces like this.
Turn the two pieces so the front side of the fabric is together and the outside of the fabric is facing outwards. Sew along the perimeter of the hat 1 inch in from the edge.
Flip the hat right side out.
Step 2: Making the Brim of the Hat
The brim will be 6 inches wide with a 13 in diameter on the inside.
The brim will need support so it isn't too floppy. We used construction paper to craft this support.
Begin by taping 4 pieces of construction paper together. Make a second layer in the same way. Draw a 20 inch circle on the construction paper. This is the outer brim boarder. Now in the center of that circle, draw a 12 inch circle. This will be the inner part of the hat. Cut out the "donut".
Trace the "donut" on the material of the hat. Cut out two pieces of fabric donuts.
Take the two pieces of fabric and lay one on top of the other so the front side of the fabric of both pieces is touching and the back side of the fabric is on the outside of both pieces. Sew around the outer boarder of the hat 1 inch from the edge.
Flip the sewn hat brim right side out. Insert the cardboard support into the brim between the two layers of fabric to ensure that it fits. Trim any of the support if necessary to ensure it fits in the fabric of the hat brim
Step 3: Making the Hat Support
To give it the fullness commonly thought of with the sorting hat, we used a wire frame to help support the tall part. This will also be where we attach the Ardiuno board and batteries for the LEDs
Cut a piece of wire approximately 42 inches. Make a circle that is 13 inches in diameter. Twist the wire together and reinforce with hot glue.
Then cut 6 pieces of wire 10 inches. With needle nose pliers, make a small hook at one end of a wire and insert the wire circle into it. Use the pliers to pinch the hook shut over the wire circle. Hold the wire so it stands up, curving in to the center of the circle. Reinforce the loop of wire with hot glue. Repeat for second wire, placing it directly across from the initial wire. Once you have secured the second wire with hot glue, glue the tops together with hot glue also. Repeat until you have added all 6 wires.
Take a piece of scrap fabric and sew a pouch approximately 5 in x 7 in with a 7 in open mouth. Then sew velcro on each side of the opening so that the pouch can be closed and opened. Sew this pouch to the wire hat support. This pouch will hold the arduino and batteries.
Step 4: Sewing the Brim to the Hat
Turn the hat and the brim inside out. Pin one of the inside edges of the brim to the bottom of the hat all the way around the circle. Sew along this pinned edge, making sure you don't accidentally sew the other fabric of the hat into the seam! Once you are done sewing, flip the hat right side out. You should start to see your sorting hat take shape.
Step 5: Setting Up and Coding Ardiuno
We're going to use the Arduino to turn the RGB LEDs on and off according do the house colors.
You can learn how to use and RGB LED here:
We need to use transistors as switches for the LEDs, so we do not ruin our Arduino board. Since we have common cathode LEDs (each inner LED is connected to ground) we have to perform high side switching use PNP transistors. Unfortunately, since we are powering the transistors with 9V from the battery and controlling them with 5V from the Arduino we can't just use the PNP transistors alone as in normal high side switching. Since the power voltage is greater than the control voltage, the PNP transistor is always "on". To fix this we have to use NPN transistors as well. We will use the Arduino to control the NPN transistors which in turn controls the PNPs and the LEDS. This transistor combination is called a Sziklai pair.
Follow the schematic and use the code listed below*. Once finished, tape LED array to hat brim support.
* there are plenty of instructables that cover transistors and their accompanying resistors better than I could. Also, the transistors I used are actually being ran at their maximum current rating, since they were the only ones on had.
Step 6: Soldering Lights and Attaching to Brim Support
The green and blue pins should all have a 330 ohm resistor soldered to it. Each red pin should have a 360 ohm resistor soldered to it.* Then solder up the wires to the resistors. Run each respective wire to the next LED with resistors soldered onto the pins. Continue this process until you have soldered all 10 LEDs together.
Take the LED array and tape them to the brim support. Run the button on the bottom side of the brim support and tape it down.
* The difference in resistors used for the green and blue versus the red is due to a difference in voltage drop between the pins. We can calculate this as follows using Ohm's Law: V=IR -> R=V/I. From our data sheet we see that our blue and green LEDs have a voltage drop of 3V and a max current of 20mA. Plugging this into Ohm's law we get R=(V_source-V_LED)/I = (9-3)/.02 = 300 Ohms. For the red LED we have: R = (V_source-V_LED)/I = (9-2)/.02 = 350 Ohms. We used the next highest standard resistor which is 360 Ohms.
Step 7: Assembling the Parts and Finishing Off
Insert the metal hat support with the arduino pouch into the sorting hat. Then insert the brim support with LEDs attached into the brim. With a needle and thread, sew the brim closed and the wire support to the brim.
Take a marker and put a mark over the button on the bottom of the brim so you can find it.
Open up the arduino pouch and insert the arduino and two 9V batteries, then velcro shut. Your hat is now ready to amaze people at your next party!
We have a be nice policy.
Please be positive and constructive.