Introduction: Sorting Hat

About: tinkerer, teacher, developer, dreamer... follow me @echundotcom on twitter, instagram to see my other creations

As we near that time of the year where we dress up in various costumes, one year our school staff decided to have themes by department. Harry Potter was a popular choice, and as I was really getting in to my craft of crocheting Amigurumi dolls and scarves, I challenged myself to make a Sorting Hat. Furthermore, I took it another step to add electronics to it, and some good ole programming, so that the wearer will then be presented with which House the Sorting Hat puts you in.

The programming part was the easy part, as it's a simple random number generator... the circuitry was the hard part, but after much fiddling, and playing around with various circuits and components, a working product emerges.


  • Arduino Nano
  • LCD display
  • Servo
  • push button
  • 220 ohm resistor (LCD display)
  • 10 Kohm resistor (pull up resistor for push button)
  • 0.5W speaker
  • capacitor
  • breadboard

Yarn (brown colour) for the crocheting of the Sorting Hat

Step 1: Crochet Hat

No real pattern here... just started with a magic circle, and then single crochet adding doubles every so often until I got to a size that was wide enough for my head (around 70 stitches)

At the eye brow portion of the hat, did a half crochet for half the circle, and then pulled it in a few times for the eye sockets.

At the mouth portion, just did a chain stitch for half of the circle, and then connected again at the other end of the mouth.

For the brim, reversed it, and did a single crochet to get a corner around the brim, and then added as I saw fit, so that it created the actual brim of the hat.

There are so many resources for crochet on the Internet, and this Instructable is about a mash up of different formats, so I won't spend much time on the specifics of crochet (of course, other materials and hats can be used for this)

Step 2: Make Base and Program Arduino

Using a laser cutter, cut the base to match the diameter of the hat, and also lasered out holes from which I can stitch the hat to the base of the electronics.

Housed all the circuit on the base plate, and added batteries to power the device.

Attached is the SortingHat.ino source code that also plays my rendition of the Harry Potter theme.

The Fritzing image shows you how I wired it up for my specific LCD panel and servo... you'll need to wire up the LCD accordingly based upon the specific model that you use. I also found that there wasn't enough power to push up the servo, so had to add an additional power source for just the servo, as the lit LCD panel drew too much current.

When the push button is activated at the bottom of the base, it plays the song, and then randomly chooses a house to display on the LCD screen.

Step 3: Put It All Together

Here's the final product.

The push button at the bottom of the hat is activated when it rests on a person's head, and the song plays with the mouth opening and displaying the chosen house (it's random...but only as random as can be... or does it really know which house at Hogwarts you belong to?)

Randomly, two of my colleagues were actually put in to the house that they most associate with... how did it know?

The next step to this challenge is to add an audio player circuit, that plays a voice recording of the actual house names, and then to animate the mouth accordingly with the audio sound track. In addition to that, adding another servo so that the eye brows move in conjunction are also in the works for version 2.0 of this Sorting Hat.

Halloween Contest

Participated in the
Halloween Contest