# Textile Potentiometer Hoodie

## Overview

https://www.youtube.com/watch?v=uVAC8efNfp8

Info: 

In this all-sewing (no soldering) project, you'll learn to stitch up a textile slide actuator to control color changing LEDs using the GEMMA sewable microcontroller. You will need:

- [Soft potentiometer by Plug&Wear](http://www.adafruit.com/product/2273)
- [Adafruit Gemma M0](https://www.adafruit.com/product/3501) or [Adafruit GEMMA](https://www.adafruit.com/product/1222)
- [Sewable NeoPixels](http://www.adafruit.com/product/1260)
- [3-ply stainless conductive thread](http://www.adafruit.com/product/641)
- [3xAAA battery pack](http://www.adafruit.com/product/727)&nbsp;and&nbsp;[JST extension](http://www.adafruit.com/product/1131)
- [Sewing needles](http://www.adafruit.com/product/615)&nbsp;and plain thread
- Scissors
- Clear nail polish
- Multimeter (optional but useful for troubleshooting)

Before you begin please read these prerequisite guides:

- [Conductive Thread](../../../../conductive-thread)
- [Introducing Gemma M0&nbsp;](../../../../adafruit-gemma-m0/)or [Introducing GEMMA](http://learn.adafruit.com/introducing-gemma)
- [Flora RGB Smart NeoPixels](../../../../flora-rgb-smart-pixels)
- [Washing Wearable Electronics](../../../../washing-wearable-electronics)
- [Battery Powering your Wearable Electronics](https://www.youtube.com/watch?v=U_Q3djsktQs)

![](https://cdn-learn.adafruit.com/assets/assets/000/022/968/medium800thumb/sensors_textile-pontentiometer-hoodie-materials.jpg?1448315757)

# Textile Potentiometer Hoodie

## Circuit Diagram

![](https://cdn-learn.adafruit.com/assets/assets/000/051/303/medium800/sensors_Textile_Potentiometer_Hoodie_bb.png?1519651833)

Info: 

Click to enlarge.

- One end of soft potentiometer is stitched to GEMMA GND
- Other end of soft potentiometer is stitched to GEMMA 3V
- Slide charm on soft pot is stitched to GEMMA A1 (also marked D2)
- NeoPixels - connected to GEMMA GND
- NeoPixels + connected to GEMMA Vout
- First NeoPixel data in (arrow pointing inward) connected to GEMMA D1
- Battery pack connected to JST port

# Textile Potentiometer Hoodie

## Prepare and Sew Sensor

![](https://cdn-learn.adafruit.com/assets/assets/000/022/974/medium800thumb/sensors_textile-pontentiometer-hoodie-gemma-placement.jpg?1448315827)

We chose to attach the sensor parallel to the zipper on the front of the hoodie and use the drawstring&nbsp;to perform the sliding action. Yes, you can install the sensor along a zipper and use the zipper pull as the slider, which would&nbsp;couple the&nbsp;temperature control action of zipping and unzipping the hoodie with the LED color change effect. For simplicity of demonstration, we've kept them separate.&nbsp;

We placed GEMMA just inside the front lapel of the hoodie. This hoodie has a front facing along the inside edge, and you could easily hide GEMMA completely inside. Again for simplicity of showing you, we've left it visible on the outside of the facing.

![](https://cdn-learn.adafruit.com/assets/assets/000/022/983/medium800/sensors_textile-potentiometer-hoodie-00.jpg?1423662991)

Cut the sensor's ribbon into two pieces. We'll use one as the pull tab and one to slide along.

![](https://cdn-learn.adafruit.com/assets/assets/000/022/969/medium800thumb/sensors_textile-pontentiometer-hoodie-thread-sensor.jpg?1448315764)

Use a needle and thread (knotted at the end) to gather up the stitches at one end of the slide-along piece&nbsp;and thread it through the small end of the charm that comes with the soft potentiometer. It's a snug fit, so you may need to try a few times.

![](https://cdn-learn.adafruit.com/assets/assets/000/022/970/medium800/sensors_Screen_Shot_2015-02-10_at_3.02.04_PM.png?1423598594)

To attach the pull tab, stitch the other piece of ribbon to the large loop on the charm. You can use regular thread for this if you wish, but conductive thread won't hurt. Cinch the ribbon to the charm tightly for a stable electrical signal.

Stitch the other end of the pull tab ribbon to the outlet of the hoodie's drawstring, then back to the pad marked A1 (also D2) on GEMMA. Refer to the circuit diagram.

![](https://cdn-learn.adafruit.com/assets/assets/000/022/971/medium800thumb/sensors_textile-pontentiometer-hoodie-shallow-stitches.jpg?1448315783)

Next stitch down both ends of the slide-along ribbon using conductive thread and connect them to GEMMA 3V and GND according to the circuit diagram using a running stitch.

For the far-away end, you can stitch along the inside of the facing to insulate your stitches.

![](https://cdn-learn.adafruit.com/assets/assets/000/022/972/medium800thumb/sensors_textile-pontentiometer-hoodie-stitch-gemma.jpg?1448315800)

When you reach GEMMA, loop around the pad many times and then use the needle to knot the thread at the back or away from the GEMMA pad. Your stitches should be nice and tight to ensure a secure connection and prevent short circuits.

![](https://cdn-learn.adafruit.com/assets/assets/000/022/973/medium800thumb/sensors_textile-pontentiometer-hoodie-seal-knots.jpg?1448315810)

Seal knots by pulling tight and dabbing on a small amount of clear nail polish. A little goes a long way! Try not to get it on the garment itself. Periodically pull the thread tight while it dries, applying more nail polish if necessary to prevent the knots from springing open.&nbsp;

Do not cut your thread tails until the nail polish is dry and you've tugged them to ensure the knots are secure.

Plug GEMMA into your compute with a USB cable and load up the following code:

```auto
//very slightly modified version of Arduino's "AnalogInput" example sketch for testing the textile potentiometer with GEMMA

int sensorPin = 1;    // select the input pin for the potentiometer, analog 1 on GEMMA is digital 2
int ledPin = 1;      // select the pin for the LED, GEMMA has one attached to D1
int sensorValue = 0;  // variable to store the value coming from the sensor

void setup() {
  // declare the ledPin as an OUTPUT:
  pinMode(ledPin, OUTPUT);  
}

void loop() {
  // read the value from the sensor:
  sensorValue = analogRead(sensorPin);    
  // turn the ledPin on
  digitalWrite(ledPin, HIGH);  
  // stop the program for <sensorValue> milliseconds:
  delay(sensorValue);          
  // turn the ledPin off:        
  digitalWrite(ledPin, LOW);   
  // stop the program for for <sensorValue> milliseconds:
  delay(sensorValue);                  
}
```

This code uses the changing value of the slide sensor to adjust the blinking speed of GEMMA's onboard LED. Slide the sensor and watch the LED blink faster or slower.

LED not changing blink speed? Unplug and try checking your circuit for shorts, using a multimeter if possible.

![](https://cdn-learn.adafruit.com/assets/assets/000/022/977/medium800thumb/sensors_textile-pontentiometer-hoodie-testing-sensor.jpg?1448315865)

Is the blinking speed changing? Great! Now let's add some color changing NeoPixels.

https://youtu.be/oUuGXWMr3sE

# Textile Potentiometer Hoodie

## Stitch Pixels

![](https://cdn-learn.adafruit.com/assets/assets/000/022/984/medium800/sensors_textile-potentiometer-hoodie-01.jpg?1423663022)

Add a chain of NeoPixels to GEMMA's GND, D1, and Vout pads.&nbsp;Any NeoPixels will work just fine (strips, sticks, rings, etc.) but in keeping with the textile theme of this project, we'll be using individual sewable pixels.

https://www.youtube.com/watch?v=eGtGoPhjmcc

![](https://cdn-learn.adafruit.com/assets/assets/000/022/986/medium800/sensors_textile-potentiometer-hoodie-04.jpg?1423663063)

Start by stitching between GEMMA D1 and the data input of your first pixel. Knot the thread at each and and seal/snip.

Stitch very long strands of conductive thread to GEMMA GND and Vout and stitch each up to - and + on the first pixel. Knot the threads at the pixel but do not seal or cut the leads short. Instead wrap the excess threads around bobbins&nbsp;or scraps of paper to keep them out of the way.

![](https://cdn-learn.adafruit.com/assets/assets/000/022/987/medium800/sensors_textile-potentiometer-hoodie-03.jpg?1423663113)

Stop stitching after&nbsp;each pixel to test your stitched connections.

![](https://cdn-learn.adafruit.com/assets/assets/000/022/980/medium800thumb/sensors_textile-pontentiometer-hoodie-changing_code-small.jpg?1448315952)

Eight pixels stitched around the inside of the hood:

![](https://cdn-learn.adafruit.com/assets/assets/000/022/988/medium800/sensors_textile-potentiometer-hoodie-05.jpg?1423663576)

![](https://cdn-learn.adafruit.com/assets/assets/000/022/989/medium800thumb/sensors_demo-textile-potentiometer-hoodie.jpg?1448315966)

# Textile Potentiometer Hoodie

## Arduino Code

Info: 

Upload the code below to GEMMA to see the interactive color changing effect using the soft potentiometer. This sketch doesn't do any smoothing of the sensor value before directly mapping it to a color, so the LEDs will flash different colors as you slide, then stay on a single color when you let go of the slide charm. We wanted to keep the code as simple as possible so you can learn exactly how the sensor works, so feel free to upgrade it to suit your project's needs!

https://github.com/adafruit/Adafruit_Learning_System_Guides/blob/main/Textile_Potentiometer_Hoodie/Textile_Potentiometer_Hoodie.ino

If this is your first time using GEMMA, work through the&nbsp;[Introducing G](http://learn.adafruit.com/introducing-gemma)[EMMA](http://learn.adafruit.com/introducing-gemma)&nbsp;guide first; you need to customize some settings in the Arduino IDE. Once you have it up and running (test the 'blink' sketch), then follow the instructions on the following page for installing the NeoPixel library:

## **[NeoPixel Überguide:&nbsp;Arduino Library Installation](../../../../adafruit-neopixel-uberguide/arduino-library-installation)**

Plug in your circuit and load up the sketch below:

# Textile Potentiometer Hoodie

## CircuitPython Code

![](https://cdn-learn.adafruit.com/assets/assets/000/051/302/medium800/sensors_gemma-cp.jpg?1519651289)

 **GEMMA&nbsp;M0** &nbsp;boards can&nbsp;run&nbsp; **CircuitPython** &nbsp;— a different approach to programming compared to Arduino sketches. In fact,&nbsp; **CircuitPython comes&nbsp;factory pre-loaded on GEMMA&nbsp;M0**. If you’ve overwritten it with an Arduino sketch, or just want to learn the basics of setting up and using CircuitPython, this is explained in the&nbsp;[**Adafruit GEMMA&nbsp;M0 guide**](../../../../adafruit-gemma-m0/circuitpython-setup-1).

Info: 

Below is CircuitPython code that works&nbsp;similarly (though not exactly the same) as the Arduino sketch shown on a prior page. To use this, plug the GEMMA M0 into USB…it should show up on your computer as a small&nbsp; **flash drive** …then edit the file “ **code.py** ” with your text editor of choice. Select and copy the code below and paste it into that file,&nbsp; **entirely replacing its contents** &nbsp;(don’t mix it in with lingering bits of old code). When you save the file, the code should&nbsp; **start running almost immediately** &nbsp;(if not, see notes at the bottom of this page).

**If GEMMA M0 doesn’t show up as a&nbsp;drive, follow the GEMMA M0 guide link above to prepare the board for CircuitPython.**

https://github.com/adafruit/Adafruit_Learning_System_Guides/blob/main/Textile_Potentiometer_Hoodie/code.py

# Textile Potentiometer Hoodie

## Wear it!

![](https://cdn-learn.adafruit.com/assets/assets/000/022/985/medium800/sensors_textile-potentiometer-hoodie-02.jpg?1423663033)

Create a small hole in the upper inside edge of the hoodie's front pocket, and thread through the JST battery wire. Store the AAA pack in the pocket, and run the JST extension up through the front facing to plug into GEMMA's JST port.

![](https://cdn-learn.adafruit.com/assets/assets/000/022/979/medium800thumb/sensors_textile-pontentiometer-hoodie-demo.jpg?1448315919)

Turn twilight into your own colored light show! You can use this basic project as a jumping-off point for your own e-textile slidey wearables; what will you make?

Info: 


## Featured Products

### Adafruit GEMMA M0 - Miniature wearable electronic platform

[Adafruit GEMMA M0 - Miniature wearable electronic platform](https://www.adafruit.com/product/3501)
The **Adafruit Gemma M0** is a super small microcontroller board, with just enough built-in to create many simple projects. It may look small and cute: round, about the size of a quarter, with friendly alligator-clip sew pads. But do not be fooled! The Gemma M0 is incredibly...

In Stock
[Buy Now](https://www.adafruit.com/product/3501)
[Related Guides to the Product](https://learn.adafruit.com/products/3501/guides)
### Adafruit GEMMA v2 - Miniature wearable electronic platform

[Adafruit GEMMA v2 - Miniature wearable electronic platform](https://www.adafruit.com/product/1222)
 **Deprecation Warning: The Gemma bit-bang USB technique it uses doesn't work as well as it did in 2014, many modern computers won't work well. So while we still carry the Gemma so that people can maintain some older projects, we no longer recommend it.** <a...></a...>

No Longer Stocked
[Buy Now](https://www.adafruit.com/product/1222)
[Related Guides to the Product](https://learn.adafruit.com/products/1222/guides)
### Soft Potentiometer Kit from Plug&Wear

[Soft Potentiometer Kit from Plug&Wear](https://www.adafruit.com/product/2273)
## Discontinued - [**you can grab** Linear SoftPot (Ribbon Sensor) - 100mm **instead!&nbsp;**](https://www.adafruit.com/product/178)

&nbsp;

This soft potentiometer is an interesting way to add an adjustable resistor / slide potentiometer to your...

No Longer Stocked
[Buy Now](https://www.adafruit.com/product/2273)
[Related Guides to the Product](https://learn.adafruit.com/products/2273/guides)
### Flora RGB Smart NeoPixel version 3 - Pack of 4

[Flora RGB Smart NeoPixel version 3 - Pack of 4](https://www.adafruit.com/product/1260)
What's a wearable project without LEDs? Our favorite part of the Flora platform is these tiny smart pixels. Designed specifically for wearables, these updated Flora NeoPixels have ultra-cool technology: these ultra-bright LEDs have a constant-current driver cooked right into the LED...

Out of Stock
[Buy Now](https://www.adafruit.com/product/1260)
[Related Guides to the Product](https://learn.adafruit.com/products/1260/guides)
### Stainless Medium Conductive Thread - 3 ply - 18 meter/60 ft

[Stainless Medium Conductive Thread - 3 ply - 18 meter/60 ft](https://www.adafruit.com/product/641)
After months of searching, we finally have what we consider to be the ultimate conductive thread. It's thin, strong, smooth, and made completely of 316L stainless steel. Once you start working with this thread you'll quickly agree its optimal for any wearables work!  
  
This...

In Stock
[Buy Now](https://www.adafruit.com/product/641)
[Related Guides to the Product](https://learn.adafruit.com/products/641/guides)
### 3 x AAA Battery Holder with On/Off Switch and 2-Pin JST

[3 x AAA Battery Holder with On/Off Switch and 2-Pin JST](https://www.adafruit.com/product/727)
This battery holder connects 3 AAA batteries together in series for powering all kinds of projects. We spec'd these out because the box is slim, and 3 AAA's add up to about 3.3-4.5V, a very similar range to Lithium Ion/polymer (Li-Ion) batteries and have an on-off switch. That makes...

In Stock
[Buy Now](https://www.adafruit.com/product/727)
[Related Guides to the Product](https://learn.adafruit.com/products/727/guides)
### Needle set - 3/9 sizes - 20 needles

[Needle set - 3/9 sizes - 20 needles](https://www.adafruit.com/product/615)
Mighty needles, sew like the wind! This needle set is the only one you'll need for any sort of hand sewing, especially using our conductive thread and wearable electronics parts.  
  
Each pack contains 20 gold-eye sharps, with eye sizes ranging from #3 (1.75" long) to #9...

Out of Stock
[Buy Now](https://www.adafruit.com/product/615)
[Related Guides to the Product](https://learn.adafruit.com/products/615/guides)
### JST-PH Battery Extension Cable - 500mm

[JST-PH Battery Extension Cable - 500mm](https://www.adafruit.com/product/1131)
By popular demand, we now have a handy extension cord for all of our JST PH-terminated battery packs (such as our LiIon/LiPoly and 3xAAA holders). One end has a JST-PH compatible socket, and the other end has a matching plug. Between the two, 500mm of color coded wire. Handy for wearable...

Out of Stock
[Buy Now](https://www.adafruit.com/product/1131)
[Related Guides to the Product](https://learn.adafruit.com/products/1131/guides)

## Related Guides

- [Using MCP23008 & MCP23017 with CircuitPython](https://learn.adafruit.com/using-mcp23008-mcp23017-with-circuitpython.md)
- [Light-Activated Pixel Heart](https://learn.adafruit.com/light-activated-pixel-heart.md)
- [CircuitPython Basics: Analog Inputs & Outputs](https://learn.adafruit.com/circuitpython-basics-analog-inputs-and-outputs.md)
- [CircuitPython 101: Basic Builtin Data Structures](https://learn.adafruit.com/basic-datastructures-in-circuitpython.md)
- [Sparkle Skirt](https://learn.adafruit.com/sparkle-skirt.md)
- [Adafruit Gemma M0](https://learn.adafruit.com/adafruit-gemma-m0.md)
- [CircuitPython I2C and SPI Under the Hood](https://learn.adafruit.com/circuitpython-basics-i2c-and-spi.md)
- [Sensor Plotting with Mu and CircuitPython](https://learn.adafruit.com/sensor-plotting-with-mu-and-circuitpython.md)
- [Mystical LED Halloween Hood](https://learn.adafruit.com/mystical-led-halloween-hood.md)
- [Your Very First Circuit Sculpture](https://learn.adafruit.com/first-simple-circuit-sculpture.md)
- [DIY Thermal Light Painting - Heat Map Photography](https://learn.adafruit.com/diy-flir-light-painting-heat-map-photography.md)
- [AdaBox 007](https://learn.adafruit.com/adabox007.md)
- [Porting an Arduino library to CircuitPython: VL6180X Distance Sensor](https://learn.adafruit.com/porting-an-arduino-library-to-circuitpython-vl6180x-distance-sensor.md)
- [Flora-Powered TARDIS Costume (for Dogs!)](https://learn.adafruit.com/wearable-flora-powered-tardis-costume-dogs.md)
- [3D Printed Unicorn Horn](https://learn.adafruit.com/3d-printed-unicorn-horn.md)
