Hacking Your Hacker School T-Shirt

On the last day of our Hacker School batch, we got some cool commemorative T-shirts with the stylish Hacker School logo on them. Now, this is an excellent T-shirt, and the only way I know of to get an official one is to attend the last day of a batch of Hacker School, so it’s already a pretty rad shirt. I wanted to make it radder, and I did, and now I want to tell you how.

What You’ll Need

I work with Adafruit components, although you could do this project with Sparkfun’s components as well.

  • An Adafruit GEMMA wearable microcontroller, or its big sister the Adafruit FLORA
  • A mini-USB to USB-A cable for programming your microcontroller.
  • A working Arduino IDE installation. GEMMA instructions and FLORA instructions are available from the Adafruit site. If you’re running Linux and using GEMMA, you’ll need to change a couple of udev settings.
  • 7 wearable NeoPixels, although it’s easier to buy 8.
  • A lithium-polymer battery and charger. If you have a battery with a USB port (like the Goal Zero Guide) that you don’t mind wearing, you can skip this and just use your existing battery.
  • About 12 feet of conductive thread. I prefer the 3-ply thread from Adafruit over the Sparkfun thread, as it frays less.
  • A hand sewing needle with an eye large enough for your thread. Adafruit sells a needle set, but you can buy these at any fabric store or large supermarket.
  • Several safety pins.
  • At least 20 straight pins.
  • A pair of stout, sturdy scissors.
  • A piece of fabric roughly the size of the screen on your T-shirt. I recommend canvas or a similarly sturdy material; very flimsy fabrics are hard to work with, and can cause your circuit to short out.
  • An embroidery hoop. 5” should do.
  • A fabric marker or ordinary pencil.
  • Something to permanently seal the loose ends of your conductive thread. I’ve used hot glue in other projects and been quite satisfied. I used regular paper glue for this project and it seems to have held up OK. I’m told clear nail polish and hairspray are also effective.
  • Optionally, some tape to seal the ends of your threads temporarily while you’re putting your project together. I’ve found that electrical tape works well.

How to Begin

Step 0 of any hardware project is making sure that all of your components work. Verifying your components is never a waste of time – when you’re putting things together later, you’ll be glad that you know they all work in isolation.

  • Test your microcontroller with a simple microcontroller hello world like blinking the onboard LED. This will also ensure that you can push your code to the microcontroller.
  • If you’re using a new battery, make sure it holds a charge and can power your microcontroller.

Testing LEDs

Test each LED by attaching it to the microcontroller with alligator clips. Run a simple test loop like the strandtest packaged with the NeoPixel library and verify that each pixel lights up red, green, and blue. If you’re using NeoPixels, it’s a good idea to set up a test rig with two NeoPixels and rotate out the first pixel in the strand, so you’re testing all four points on each pixel. It’s a drag to sew a pixel into your design and then realize that its data-out pin is no good - or worse, suspect that it’s no good, but have no way to prove it without tearing your circuit apart.

Readying Your Fabric

Get your canvas into your embroidery hoop by cutting out a square that’s a bit larger than the Hacker School logo on your T-shirt and your embroidery hoop. Unscrew your embroidery hoop and take the smaller hoop out from within the larger, outer hoop. Put the small hoop under the fabric, the large hoop over the fabric, and press down until the fabric is taut in the embroidery hoop. Ideally, you’ll see no wrinkles in the fabric after you’ve done this. Tighten the screw on the outer hoop until the fabric’s no longer in danger of falling out, then just a bit more. You likely don’t need to tighten the screw all the way, especially if you’re using a sturdy, thick fabric, as you’re likely to be doing.

You may find this helpful pictorial guide from an embroidery floss company to be clearer than the description above.

Placing the Design

There are a number of ways that you could get your pixels provisionally laid out in the right place, most of which are likely smarter than the way I did it. If you know a better way, probably do that. Otherwise, proceed as follows: put the canvas behind the T-shirt, place the pixels on top of the T-shirt, over the spots from which you want light to emit, and straight-pin the pixels through the shirt and canvas.

A Hacker School shirt with an embroidery hoop inside

Hoop goes in the shirt

Straight pins stuck through the shirt at the intersections of each block representing the cursor text on the shirt design

Pins go in the shirt

Flip the whole thing inside-out, so that the canvas and all the sharp ends of the pins are facing outward. (If you are attacked during this portion of the project, this doubles as a handy defensive weapon.) If you’re worried about sticking yourself, you can reverse the direction of the pins by taking one or two out at a time and re-piercing them through the fabric going the other way, but I found it easier to just be careful. Play connect-the-dots with your fabric marker to reproduce a reversed design from the shirt - these boxes will be your guide when placing the pixels on the canvas.

Backside of working fabric, with straight-pin ends visible

Interior view of pins

Backside of working fabric, with lines drawn connecting the points delineated by the straight pins placed in previous photos

Now with boxes!

Once you’re satisfied with your box art, pull the straight pins out and remove the canvas from the shirt. Remove the canvas from the embroidery hoop and flip it over. Your boxes, previously horizontally reflected and on the back of the design, are now the right way ‘round! Put the canvas in the hoop with your boxes on the front. It’s now time to reuse those pins for the pixels’ final placement. Pin your pixels for the top row in place such that the LEDs are in the middle of the boxes you drew. Position the pixels for the bottom row such that the LED portion of the circuit board is at the end of the box, so you’ll have enough room for a stitch between the NeoPixel PCBs.

The rotation of the pixels is also significant, but it’s easier to figure out the general placement first and then rotate them if necessary, than to try to place them while also worrying about which way they’re facing. Once your pixels are in place, be sure that your pixels are all facing the right direction - all +’s should be facing the middle of the design, all -’s facing the outside, and the arrows should go to the right for the top line and the left for the bottom line. Straight-pin the pixels in place after you’re happy with their placement.

Three wearable NeoPixels laid out such that all arrows face the same direction; the rotation is correct.

Arrows all in the same direction; excellent!

It’s a good idea to stop and hold your pinned design up next to your shirt right about here. Does it look right? If it’s reflected, misshapen, or otherwise incorrect, now’s a much easier time to fix it than later. (The astute reader will notice that the photos in the rest of this blog post, taken of the second iteration of this design, reflect my failure to do so at this point.)

Next, figure out where you’d like the microcontroller to go. The best placement will depend on which microcontroller you’re using - my first iteration, with the FLORA, was a bit more constrained in placement because of the part’s size. I was a bit more artful with the GEMMA and placed it such that it would be beneath the keyboard when mounted behind the shirt design. If you place it very far from the pixels - more than about four inches - you may have trouble with power loss from the resistivity of the thread, plus you’ll have to do a lot more sewing. It’s best to keep the microcontroller as close to the design as you can, while keeping in mind that the outline of the microcontroller may be visible within your shirt depending on its placement and your body.

Planning Your Circuit

While you can stitch the leads of the circuit without any guiding marks, it’s easier to do it with some guidance. You’ll want to lay out four traces with your fabric marker:

  • A positive power bus from pin Vout for GEMMA, or pin VBatt for FLORA, between the rows of pixels
  • A data line from pin D1 for GEMMA, or pin D6 or D10 for FLORA, to the data-in pin of the first pixel
  • A ground bus from pin GND (on both GEMMA and FLORA) around the negative sides of each pixel. This will require you to actually draw two traces emitting from GND, one for each row of pixels, in order to avoid crossing traces.

Take care that your traces connected to different pins don’t cross - it should be possible to lay out your pixels and microcontroller such that this is not necessary. If necessary you can flip the direction of the pixels’ layout, as long as you do this to all of them. It should be the case that either all pixels have their + pins pointing at the trace running between the rows of pixels, or that all pixels have their - pins pointing in this direction.

Fabric in a hoop, with a microcontroller and sevel LEDs pinned in place.  Traces are drawn in fabric marker to show where conductive thread will be stitched.

Work imagined, but not yet done.

You will later be connecting each individual pixel to the power and ground buses, and sewing individual connections between each pixel’s data-in pin and the next pixel’s data-out pin. The power bus’s location is fairly constrained by the shirt design, but keep this in mind when placing the ground bus - the closer it is to the pixels, the fewer stitches you’ll have to take to connect the pixels to it later.

Sewing. A Lot.

To get all of the required traces down, here’s what you need to do:

  1. Sew a ground bus
  2. Sew a positive power bus
  3. Sew connections between individual LEDs and the ground bus
  4. Sew connections between individual LEDs and the power bus
  5. Sew data connections between each individual LED and its neighbors (and a connection to the microcontroller)

For a very good tutorial on sewing with conductive thread, Adafruit once again has your back. I’ll limit myself to a few tips:

  • Sew the power and ground buses with doubled-up conductive thread. You can easily double thread to sew two passes in one - just pull the tail all the way through the eye of the needle, until it’s the same length as your working thread, then knot the end. The data connections, and the connections between each pixel and the buses, can be done with single threads.
  • Sewing around straight pins in your design is a pain. If you’re having trouble sewing around the pins, you may choose to instead sew the pixels in place with nonconductive thread temporarily; you’ll remove this thread when you’re ready to connect the pixels to the circuit. You can also mark the locations of the pixels very carefully and remove the pins and pixels when sewing the buses, but the pixels will need to be in place when sewing the data connections and the per-pixel connections to the buses.
  • Do be sure to seal the ends of your thread somehow, as soon as you can. Conductive thread is prone to fraying, and is stiff enough to slowly work its way out of knots over time when left to its own devices. Adafruit recommends clear nail polish for this, but I prefer hot glue or, in a pinch, regular paper glue. I’ve experimented with electrical tape and found it to be a little cumbersome, but excellent for keeping things in place until the project is debugged enough for a more permanent solution.
  • As many loops as you think you need to do through any pin, do at least one more. Always pull your thread very taut during this stage; loose connections with a microcontroller, pixel, or bus will cause you a lot of heartache down the road.

Sewing Buses

Start out with doubled-up conductive thread. Sew a few loops around the pin of your microcontroller, then follow the trace you drew out with a running stitch. Once you reach the end of the trace, make a couple of extra loops, then secure the thread with a knot.

Threads make an inchoate knot, ready to be drawn taut.

How to secure a bus knot.

Attaching LEDs to Buses

Sewing the LEDs into the buses is a little tricky. One needs to ensure that the thread is both well connected to the pin on the LED, and well-connected to the power or ground bus. I do this by sewing a single thread in a loop, through the gap between the two threads that constitute the bus, multiple times. I sew through the gap between the threads, rather than around the bus, because then the tension of the thread will help keep the connection strong. The natural tendency of the metallic thread to straighten over time causes thread that’s just looped around other thread, rather than sewn through, to lose its connection over time.

A needle pierces the space between two threads of the power bus, the first stitch of the connection for an individual LED.

Coming up through the power bus.

I think there is a best order of operations for projects like this one, after quite a lot of experimentation with Secret Project Glow Cloud. First, sew both power buses, then:

  • Sew the connection between the ground pin and the ground bus for the first LED in the sequence
  • Test the first LED, using alligator clips to connect the LED’s power and data pins to the microcontroller
  • If the LED lights up and does the right thing, sew the power connection for that LED
  • Test the LED again, using an alligator clip to connect the data pin
  • If the LED lights up properly, repeat for the second LED

A nice feature of the NeoPixel LEDs is that you can test the data connection for each individually.

In my experience, it’s best to get the power to each pixel established and tested before sewing the data connections between each pixel; this makes it easier to detect and fix problems when they occur, rather than having to debug a circuit with many possible problems.

Attaching the Data Lines

Once all the LEDs have their power pins connected, it’s time to start getting data to them. The data connection is not a bus with many LEDs hanging off of it, but rather a serial connection from the microcontroller to the first LED, another connection from the first LED to the second LED, and so on until the last LED is connected.

It can be difficult to get a full stitch between the LEDs on the bottom row of the design, because they’re so close together. You can cheat by sewing stitches that go a bit out of their way - meandering up or down from the connection they need to make - in order to make sure the thread itself is well-connected in the fabric.

Seven pixels fully stitched into the design.  The bottom pixels, particularly the two in the middle, are quite close together

The bottom pixels are CLOSE.

Do continue to check the operation of the circuit after each finished connection. It’s quite possible to create a short between a data line and a main power line at this stage; it’s easy enough to fix this if there’s only one possible place for a problem, but quite a bit harder to debug if you’re not sure which connection made the problem.

Verify and Publish

Once everything’s sewn in, power on your circuit and make sure all of your LEDs light up. If not, you can troubleshoot individual connections by reattaching the alligator clips; if this fixes the problem, you have a connection to remove and sew again. It’s also worthwhile to test the circuit on battery power, if you’ve been testing by powering the microcontroller over USB.

Hopefully, all is well and you’re happy with your circuit. In a fair and just world, you’d be done with this project and ready to wear it around! Unfortunately, the whole thing will unravel and bring you to grief if you don’t do something to keep the conductive thread’s stiffness from sabotaging your project. Take some glue and use it to immobilize the knots you made, and also run some glue toward the end of the thread. Once everything’s dry, snip the long ends off all of your threads to prevent fraying and shorts.

Upload Code

Your microcontroller is likely still running the strandtest, or some other code that doesn’t look great under your shirt. Now’s the time to push some real code! You’re welcome to use my blinky cursor code. If you’d rather write your own, now’s the time to do it!

Pin It In and Show It Off

Attach your battery to the fabric of your circuit, and pin your circuit to the inside of your shirt (taking care not to pin through, or close to, any conductive thread to prevent shorts). Turn it on and bask in the glow of your awesomeness. Wear it everywhere so everyone knows how great you are! Take a video of yourself and use it as your avatar!