Image

CHAPTER 8

Programmable
Sewn Circuit Cuff

FELT, LEATHER, AND SEWN CIRCUITS GIVE THIS MODERN TECH PROJECT AN ORGANIC FEEL. You can choose to make a plain cuff with the sewn circuit or use one of the laser-cutter files to use the laser to engrave a design on your cuff.

What You Will Learn

In this chapter, you will learn how to

Image   Sew a project with conductive thread

Image   Use a capacitive touch sensor to change lighting programs

Image   Program the Adafruit Gemma M0 in CircuitPython

Files You Will Need

Image   Python code: code.py

Image   Cuff pattern: heart_cuff.pdf

Image   Cuff pattern for laser cutter: heart_cuff.svg

Image   Optional battery holder 3D model: lipo_sleeve.stl

Tools You Will Need

Image   Sewing tools and supplies

Image   Computer

Image   Optional: Laser cutter

Image   Optional: Leather-working tools, including a leather needle and leather punch

Image   Optional: 3D printer for printing a protective battery case

Materials You Will Need

Image   Gemma M0 (www.adafruit.com/product/3501)

Image   Four or more sewable addressable light-emitting diodes (LEDs; WS2812), Adafruit Flora NeoPixels v2 (www.adafruit.com/product/1260)

Image   Stainless steel conductive thread:

Image   30 feet of stainless steel thread (www.sparkfun.com/products/10867)

Image   Or 60 feet of three-ply stainless steel thread (www.adafruit.com/product/641)

Image   Small rechargeable lithium polymer (LiPo) battery (www.adafruit.com/product/1317)

Image   Small USB battery charger (www.adafruit.com/product/1304)

Image   USB data cable for programming the Gemma M0 (Some USB cables are only for power; this requires one that is data and power.)

Image   Fray Check sealant, fabric glue, or clear nail polish to seal conductive thread knots

Image   Cuff material:

Image   5- × 10-inch (or larger) piece of wool or wool-blend felt (0.5 to 3 millimeters thick; available at JOANN stores or online retailers)

Image   Or 1.5 to 3 ounces of thin vegetable-tanned leather (0.3 to 1.2 millimeters thick; available at Tandy Leather, in store or online [www.tandyleather.com/en/])

Image   Optional: Eco-Flo leather dye in preferred color (if you want to dye your leather)

Image   Sewing needle with large eye or leather needle (if you are making your cuff out of leather)

Image   Two plastic or metal snaps (sew-on size 4 recommended) or other fasteners (buttons, studs, etc. as preferred) (Do not use brass or nickel-plated fasteners because they could be conductive and can cause short circuits with your sewn circuit.)

Image   Optional: A larger capacitive touch sensor such as a small (½ inch or less) silver or silver-plated charm to add to the capacitive touch sensor

Image   Optional: 3D printed battery case

This project uses an Adafruit Gemma M0 microcontroller and Flora NeoPixel addressable LEDs (Figure 8.1). The Gemma M0 is the third iteration of Adafruit’s tiny sewable Gemma microcontroller board. It’s only about 1 inch in diameter, yet it includes a 32-bit SAMD21 microcontroller, a USB connector, a battery connector, an on/off switch, and three pins of the microcontroller broken out to large sewable pads.

Image

Figure 8.1   Electronic components for the color-change cuff: sewable addressable LEDs, the Gemma M0 microcontroller board, the LiPo battery, and the small USB charger.

NeoPixels is Adafruit’s brand name for addressable LEDs controlled by the WS2811, WS2812, and WS2812B controller chips. These chips are paired with each LED and allow individual addressing of daisy-chained LEDs. NeoPixels can be controlled from a single pin on the microcontroller. They are directional, meaning that they need to be wired in a particular orientation. The Flora NeoPixels are about ½ inch in diameter and also have large holes on conductive pads that allow them to be easily sewn with conductive thread. Tips and tricks for sewing with conductive thread are covered in Chapter 2.

Working with Leather

A leather cuff is a great fashion-forward accessory or steampunk costume piece. There are a few tools and tips specific to working with leather. The laser cutter can etch beautiful designs into vegetable-tanned leather; other types of leathers may not etch as well and may contain dangerous materials that can release toxic gases when burned with a laser.

Dye the leather with water-based dye such as Eco-Flo before engraving the design on the laser cutter. Dye can be purchased at your local leather supply or craft store. The major difference between making a leather cuff and a felt cuff is that you will need to prepunch holes to sew the conductive thread through the leather. When you are constructing your cuff and need to sew regular or conductive thread, you will need to use an awl or leather punch to make the hole before stitching with the needle and any kind of thread (Figure 8.2). Use a leather needle to sew both regular sewing thread and conductive thread.

Image

Figure 8.2   Leather punch and hammer to make holes for sewing.

Step 1: Make the Cuff

1.   Download the cuff template as a .pdf file or download the laser engrave files.

2.   No-laser option: Using sharp scissors, a rotary cutter, or a hobby knife, cut your cuff out of felt or leather.

3.   Laser option: Before cutting the laser file, you will need to tell your laser which parts of the image should be engraved and which lines should be cut. The engraved images in the download file are raster graphics and are in black; the cutting lines are vector graphics and are in red (Figure 8.3). Consult your laser operating instructions for the colors and line weights that are associated with raster and vector graphics. Set up your file to cut on the laser, and consult the laser operating recommendations for the correct power and cutting speed for fabric or leather depending on your material choice. Engrave and cut the cuff.

Image

Figure 8.3   The laser engraving file uses color differentiation between laser engraving and laser cutting.

Step 2: Charge the Battery

When you first buy LiPo batteries, they will need to be charged. In this project, we are using the Adafruit Micro Lipo Charger, a small, affordable battery charger. On one side the LiPo rechargeable battery plugs into the JST-PH socket. On the other side are four long gold-plated contacts that plug into any USB port, like those on a computer or phone charger. While charging, the red LED is lighted. When the battery is fully charged and ready for use, the green LED turns on.

Be careful when using LiPo batteries. Never bend, puncture, or crush them. Only use a battery charger designed for LiPo batteries. Never use a charger meant for NiMH, NiCad, or lead-acid batteries!

Step 3: Lay Out and Sew the Electronics

1.   Lay out the electronics. With the pattern pieces cut out, decide how you are going to lay out the electrical components. The Flora NeoPixels have two arrows on top of the board that show the in and out directions. As you orient your neopixels, ensure the arrows are all pointing in the same direction when they are wired together. The Flora NeoPixels require three pins from the Gemma M0: (1) voltage out, (2) ground, and (3) single data pin. These are all conveniently located by the power slide switch on the right side of the Gemma M0. Don’t forget to leave room for the battery on the other side of the Gemma (Figure 8.4).

Image

Figure 8.4   The NeoPixels are daisy-chained on the power switch side of the Gemma M0 board.

2.   Once you are happy with where the NeoPixels are located on your cuff, you can start sewing on your board and components. Sew the components onto the cuff with regular sewing thread before making the sewn circuit because sewing thread is stronger than conductive thread and less prone to fraying. Whipstitch once or twice through the larger copper connection holes on the Gemma. Don’t cover the copper entirely because you want to leave plenty of room for your conductive thread to make a good connection. Take one whipstitch with regular sewing thread through each of the holes on the NeoPixels.

3.   Using a running stitch, sew the voltage connections with conductive thread. The voltage line, marked with a plus sign (+), will be sewn continuously from the Gemma through each Flora NeoPixel. This means that you can use one long thread to connect each NeoPixel and do not have to cut separate threads for each voltage connection. Starting at the copper pin marked “Vout,” sew through each plus sign (+) on each NeoPixel, remembering to whipstitch numerous times and tightly around the copper pads on each component to get a good connection and to make tight knots when you start and stop sewing.

4.   Using a running stitch, sew the ground connections with conductive thread. The ground connection, marked with a minus sign (−), will be sewn as a separate continuous line from the Gemma M0 through each Flora NeoPixel. Starting at the copper connector marked “GND,” sew continuously through each minus sign (−) on the NeoPixels.

5.   Using a running stitch, sew the data connections with conductive thread. Separate connections are sewn from “data out” to “data in” on each NeoPixel. Starting at the D1 pin, sew to the in arrow on the first NeoPixel. Whipstitch through the hole, and tie a tight knot. Then cut your conductive thread to sew the next connection. Starting at the out arrow, knot your thread, whipstitch around the component, and stitch to the in arrow of the next NeoPixel. You may want to take a couple backstitches in the beginning to be sure that the start is tightly connected. Repeat for all NeoPixels (Figure 8.5).

Image

Figure 8.5   The components connected with conductive thread on felt. The components are whipstitched in place with red thread.

6.   After sewing the conductive thread, trim the thread tails on the knots to ensure you won’t get a short circuit. To help keep your knots in place, put a small dot of Fray Check sealant, fabric glue, or clear nail polish on all the conductive thread knots.

7.   Finish your cuff by sewing on snaps, buttons, or other fasteners to hold it securely around your wrist.

Step 4: Program the Gemma

The Gemma M0 can be programmed using either CircuitPython or the Arduino IDE. Because the Gemma M0 ships with the CircuitPython firmware installed, we’ll be using the CircuitPython. It’s an extension of MicroPython with support for Adafruit products. The CircuitPython firmware mounts the Gemma M0 as a small USB drive on your computer, allowing you to create, edit, and store your program directly on the device. CircuitPython will detect when a program file has been saved and automatically run the program. CircuitPython looks for a file named code.txt, code.py, main.txt, or main.py in this order and will run the first one it finds.

1.   Download the Python program. It will be named code.py and looks like this:

Images

2.   Plug the Gemma M0 in to your computer using a USB data cable. Turn the Gemma M0 on using the power switch on the board. The built-in status light might be green, indicating that a program is running, or it might be swirling through the colors of the rainbow in a demo program. Either way, the Gemma M0 should mount as a small 64K flash drive.

3.   Copy the code.py file to the Gemma M0. After the file has finished copying, the program should run, randomly flashing the NeoPixels.

4.   Make sure to eject the Gemma M0 before unplugging it from a computer.

Step 5: Use the Capacitive Touch Sensor

Capacitive touch sensors can measure the electrical properties of the human body. This is similar to how the touchscreen on your phone or computer can tell where your finger is touching. The Gemma M0 can measure capacitive touch on the copper pin pads, and we will use these to change between the LED patterns that are programmed on the cuff.

1.   Be sure that you have loaded the code.py program onto your Gemma M0.

2.   Turn the Gemma M0 on using the on/off switch. Briefly touch the A1 pad to change the pattern.

3.   Optional: Because the A1 pad is so small, you can add a conductive silver jewelry charm to make the sensor a little bigger. You don’t want a big charm because that might accidentally cause a short circuit. Whipstitch the charm to pad A1 with conductive thread, just going through the charm and the pad. Do not sew all the way through the cuff because then the thread will touch your wrist and constantly activate the sensor. Keep a tight connection between the charm and the A1 pad. To keep the charm from banging around, whipstitch the other end of the charm down with regular sewing thread. If you accidentally sewed all the way through the cuff, place a piece of tape to insulate the connection (Figure 8.6).

Image

Figure 8.6   Whipstitch a silver charm to pad A1 of the Gemma for a bigger capacitive touch target.

Step 6: Print a Battery Case

Optionally, you can 3D print a battery sleeve with little sewing tabs that will protect the battery from accidental harm (Figure 8.7). The model is downloadable from the book website or available online.

Image

Figure 8.7   This small 3D-printable battery case can help project your LiPo battery from harm.

Step 7: Going Further

In this project, we used two of the three available input-output (IO) pins, leaving the third pin available to add a sensor or an actuator to your project. Another possibility is adding a small charger breakout board between the battery and the Gemma so that the battery can be charged from a USB cable directly on the cuff without having to remove the battery.

Step 8: Troubleshooting

If your cuff is not working properly, use the following steps to find the problem:

1.   Is the status indicator LED on? If the indicator light is not lighted, check that the power slide switch is in the “on” position. If the power switch is on but the indicator LED is not lighted, check the battery. Unplug the battery, and plug it in to the battery charger to make sure that the battery is charged.

2.   The status indicator LED in the program we have provided should light up green. This is the default behavior that indicates that a program is running. If the LED is flashing different colors, check the Gemma M0 troubleshooting guide online (https://learn.adafruit.com/adafruit-gemma-m0/troubleshooting).

3.   If the Gemma does not show up as a USB drive on your computer but the status indicator light is green, check to be sure that the USB cable is not a USB power-only cable. Always remember to eject or dismount the Gemma M0 before unplugging it from a computer.

4.   If one or more Flora NeoPixels are not lighting, check for loose connections. Make sure that your knots have not come undone and the whipstitching at the connection pads is tight.

5.   If the circuit is behaving erratically, check that your stitches are not crossed. Make sure that your knots have not come undone and the ends are trimmed short. Seal the knots with Fray Check sealant or clear nail polish to prevent unraveling.