I've built something similar before (link) using a Circuit Playground Express or CPX. The original idea came from Rob Morrill who has developed a series of excellent project for the CPX, here. Follow the instructions there to fill in the gaps of this account. Alternatively, design your own hat.
I left my neopixel hat behind in Alice so it's time to do it again, but this time using the more popular microbit.
Materials: Cardboard, cardboard cutters, duct tape, clear sticky tape, adafruit neopixel strip 0.5m, battery pack 2*AAA or 3*AA (better, I've ordered some), velcro.
The neopixel strips are advertised at adafruit to work with 3-5 volts DC. However, they can underperform without sufficient voltage as the batteries go flat. The microbit pushes out a max of 3.3 volts, so it's desirable to used a 3*AA battery pack for 4.5 volts which is then regulated down to 3.3 volts by the microbit.
I had to visit a couple of Bunnings stores to get cardboard of a suitable length, since my big head has a circumference of 58 cm. I like duct tape to stick things since they remain stuck. But use clear sticky tape to attach the neopixel strip.
What code to use? I plan to use this hat as a demo for the Adelaide Maker Space / Hacker Space groups so I opted for rainbow colours at the front which activate with sound combined with flashing white / black neopixels at the back and a sound bar graph on the microbit itself. Here's the breakdown:
Initialise the neopixel strip
Flash black and white with 16 pixels around the back of the hat
Rainbow effect on both sides at the front, needs sound to activate
Bar graph on the microbit, responding to sound
Finally, the video: