Skip to content

9. Wearables

References & inspiration

Why wearables? For augmented sensing, dynamic expression, and playful communication! Here are some inspiring examples:

Sonic sound scarf by Stephanie Mars, and fiber optics AI jacket by Mika Satomi:

Sound scarf and fiber optics jacket

Pneumatics touch jacket by Sheryl Teng, and shape metal alloy (SMA) smocking by Plusea:

Pneumatics touch jacket and smocking

Suntex solar fabric by Pauline van Dongen, and SMA animated vines by Jie Qi:

Suntex solar fabric and animated vines

Interactive textile designer and sensor spinster Michelle Vossen:

Interactive textiles

Research & learning

The focus this week is to learn to integrate inputs and outputs in a microcontroller wearable project. Liza Stark started us off with a global lecture. Here are her slides.

Actuators (outputs)

An actuator is a component in a circuit that moves or controls another part of the circuit based on input — it’s basically a thing that makes another thing happen. The microcontroller is the “mini brain,’ or go-between, connecting the sensor/input device with what happens with the output device:

**Sensor —> Microcontroller board —> Output**

Types of state changes and examples

Type Outputs Example applications
Visual LEDs, neopixels, fiberoptics, thermochromic ink dBJacket as decibel meter; Movimiento for amplified body movement
Sound Fabric speakers Sonic sound scarf
Motion Shape memory alloys (SMA “muscle wire”), flip dots, vibe motors + haptics Examples

Not all LEDs (and other output components) are alike!

LED color table

The color of your LED light matters. Red is not blue is not green — they each draw different amounts of current, as do other output devices! The components in the circuit need to account for this, for example by using a different resistor or amount of power. Use Ohms Law to balance out the components: V=IR, where V is the power source voltage, I is the current in amps, and R is the resistance. Use Ohm’s law to calculate the conditions for operating the output device.

Ohm’s Law defines the relationship between voltage (V), current (I), and resistance (R).

Ohm’s Law: V=IR (and inversely I = V / R, and R = V / I).

  • If you know the voltage and the resistor value, you can calculate the current you consume: I = V / R
  • If you know the voltage and the current, you can calculate the resistor you need: R = V / I

Important: The Arduino’s power and output pins have a max of 5V and 20mA, and for the Xiao’s it’s 3.3V and 12mA. That means there’s only so much you can ask of an output. We use a 9V battery, and add a transistor circuit that acts as a switch with a one-way diode that keeps the current from going backwards, producing too much heat and damaging the transistor (For example, you can light up a string of 3 NeoPixels, but not 20). Emma Pareschi shared these examples of how much power various output devices need:

Power loads

FabriXIAO board set up

We soldered the XIAO-EXP32-S3 microcontroller and power port onto the base of the FabriXiao board. This creates a component that is sewable and easy to prototype soft circuit swatches with.

FabriXiao board construction

Here's a handy pin guide for the XIAO-ESP32-S3 that I found essential for following along on all the various tutorials:

XIAO-ESP32-S3 pin guide

Transistor driver circuit

Setting up a transistor circuit will prepare us to use actuators that need more current than the Arduino and/or Xiao pins can provide. To manage higher power sources (like a 9V battery), Jessica Stanley showed us how to construct a transistor driver circuit. Transistors act like a gate allowing behavior changes based on the voltage applied to one pin. This driver circuit allows us to try out systems that require higher power sources, such as to produce heat, sound, and movement.

Transistor circuit

Steps:

  1. Draw the diagram onto the base and solder copper tape to components
  2. Label board for clarity
  3. Test everywhere with multimeter to check for contunity and good soldering!

Coding & microntrollers

To understand Arduino’s complex C++ programming language, I found it helpful to go back to the basics. I started by trying out the blink “sketch,” as Arduino calls them, since it is super useful for testing a circuit system and individual components before sewing it all together into your creation. In short, can it blink? You can access this sketch in the Arduino menu: File > Examples > Basic > Blink.

Blink test code using built-in LED:

void setup() {
  // initialize digital pin LED_BUILTIN as an output.
  pinMode(LED_BUILTIN, OUTPUT);
}

void loop() {
  digitalWrite(LED_BUILTIN, HIGH);  // turn the LED on (HIGH is the voltage level)
  delay(1000);                      // wait for a second
  digitalWrite(LED_BUILTIN, LOW);   // turn the LED off by making the voltage LOW
  delay(1000);                      // wait for a second
}

Then I tried Emma Pareschi's blink test with an external LED and the FabriXIAO. I couldn't get it to work. Troubleshooting included:

  • Does the LED work? (Wrap it on two sides of a coin battery to check.)
  • Are the base board pins properly connected (soldered) to the XIAO microcontroller? (Use a multimeter to check pins and corresponding soldered points.)
  • Has Arduino selected the proper board and serial port? (Make sure it's XIAO_ESP32S3 and the port with "USB" in the name.)
  • Is your code correct? (Check pin number assignments, code conventions, etc. This one will take a LOT of practice! Turns out I needed to define LED_PIN as D8, not just 8. Whew. Now it works!)

Blink test code with external LED:

int led_pin=D8; // which pin is connected to LED

void setup() {
  // initialize digital pin LED_BUILTIN as an output.
  pinMode(led_pin, OUTPUT); // define pin of the LED as an output
}

void loop() {
  digitalWrite(led_pin, HIGH);  // turn the LED on (HIGH is the voltage level)
  delay(1000);                      // wait for a second
  digitalWrite(led_pin, LOW);   // turn the LED off by making the voltage LOW
  delay(1000);                      // wait for a second
}

Back on the Arduino Uno board, I moved on to getting a button to work using a Digital Input and "if" Statement. √ Check! Then, I learned to produce a more subtle off/on fade. I got myself a more relaxing, less blinky, result. √

Brightness test code1:

const int LEDPin = 8;  // Pin for LED

void setup()  // Start of setup - Runs once when we reset or power the board
{
  // Set pins as input or output:
  pinMode(LEDPin, OUTPUT);  // Set pin as output

}  // End of setup


void loop()  // Start of loop - Runs over and over again indefinitely
{
  // Analog write the LED:
  analogWrite(LEDPin, 255);  // ( [Pin] , [Value_0-255] )
  delay(1000);  // Wait this amount of milliseconds. 1000 milliseconds is 1 second

  // Analog write the LED:
  analogWrite(LEDPin, 20);  // ( [Pin] , [Value_0-255] )
  delay(1000);  // Wait this amount of milliseconds. 1000 milliseconds is 1 second

  // Analog write the LED:
  analogWrite(LEDPin, 0);  // ( [Pin] , [Value_0-255] )
  delay(1000);  // Wait this amount of milliseconds. 1000 milliseconds is 1 second

}  // End of loop

Onto to adjusting colors in a single LED. Three colors — red, green, and blue — can produce the entire range of the color wheel if you put different values into your code (e.g. 255, 165, 0 for orange, and 128, 0, 128 for purple). I didn’t have an RGB led, so tried it with a NeoPixel with the Arduino Uno board, and it worked! This might seem basic, but I was mad proud! Below is the result. Now I need to try it with the FabriXIAO board. My goal is to eventually work with sewable RGB NeoPixel strings and a touch sensor.

Assignment

Assignment: Integrate inputs and outputs in a microcontroller wearable project.
  • Learn how to program a microcontroller, documenting your process, the libraries added, power requirements and source code
  • Document the schematics and circuits
  • Create a swatch/sample using a microcontroller with one input and one output, using hard-soft connection solutions and battery
  • Create 2 actuator swatches and test them, choosing from examples such as: Motors or mini vibration, flip dot/electromagnet, heat pad with thermochromic coating, fabric speaker or mp3 player, SMA (shape memory alloy), LEDs or neopixels.
  • Document the concept, sketches, references also to artistic and scientific publications.
  • Upload a small video of your object working
  • Integrate it into a project (extra credit)

Ieva Dautartaite created this swatch library as an educational resource — a kit of electronic textile sensors for mobile FabLabs. A swatch library like this could be great way to start off the wearables unit, and an excellent addition to the TextileLab!

Electronic sensors swatch library

More inspiration

Check out and research alumni pages to better understand how to document and get inspired

Electromagnetism & flip dots

Emma Pareschi gave us a tutorial on creating a “flipping wing” using either an Arduino or Xiao microcontroller. We exploit the phenomenon of electromagnetism, or the interactions between electric and magnetic fields. Putting a current through a wire will generate a magnetic field, like a mini version of Earth’s north and south. Here are Emma's slides.

These next videos show the initial test with a bettery, then the full set up with the driver circuit.

Steps:

  • Wind copper wire around a cylander
  • Remove and wrap another wire around to secure ring, leaving two leads
  • Attach leads to 9V battery and driver board to test

Thermochromic paint

We mixed pink, purple, and black thermocromatic powder with water, and also tried the black with white acyrlic fabric paint. The black with water versus paint looked totally different when wet, but dried almost the same. All yielded results except the lighter pink color. I suspect it was a bad batch, or expired, given that the powder before mixed with liquid didn't change when you pressed it the way the others did.

Mixing and applying thermochromic ink to fabric

Shape memory alloy (SMA)

The shape memory alloy did not respond and bend it's shape. Perhaps the wire is expired. I'm calling this a "fail" that I hope to learn more from at some point. I decided to move on, though I was fantasizing trying out a mini version of Jie Qi's animated vines! Here are some photos of the construction, but I'm not including a video (trust me, nothing happened!). This silver lining is that we were able to use the heating wire (it got hot!) to test out the thermochromic swatches. :)

Making a shape metal alloy swatch

Speaker swatch

I tried out two speaker coil approaches, one with conductive thread on fabric, sewn as the bobbin in a sewing machine, the other with conductive ink on paper (by BareConductive, who has sadly gone out of business). The conductive thread speaker did work, but was pretty faint. Piling up more batteries helped, but still underwhelming. I include the results of Maddie's much louder speaker for comparison. Her theory is that my thread, going in and out of the fabric, is creating much more resistance than her streamlined copper wire solution sewn down into a coil. The difference is drammatic! I'd like to revisit soft speakers with amplifier components at a future date, given I was inspired by the sonic sound scarf in my inspiration, above!)

Fabric and paper speakers

Touch sensor + NeoPixels swatch

At last, time to integrate the input (touch sensor) with an output (light) using a microcontroller! I worked on the output and input separately, then integrated them.

1. Coding the output: LED NeoPixel

First up: Controlling the colors on an LED NeoPixel. Below is the result (video) and code.

RGB code for a single NeoPixel2:

/*
Cycles through three colors in a single NeoPixel
*/

#include <Adafruit_NeoPixel.h>

#define LED_PIN     D8     // XIAO ESP32 data pin (D2)
#define LED_COUNT   1     // One sewable NeoPixel

Adafruit_NeoPixel pixel(LED_COUNT, LED_PIN, NEO_GRB + NEO_KHZ800);

void setup() {
  pixel.begin();          // Initialize NeoPixel
  pixel.show();           // Turn off at startup
  pixel.setBrightness(50); // Brightness (0–255)
}

void loop() {
  // Simple color cycle: red → green → blue → off
  setColor(255, 0, 0);   // Red
  delay(500);

  setColor(0, 255, 0);   // Green
  delay(500);

  setColor(0, 0, 255);   // Blue
  delay(500);

  setColor(0, 0, 0);     // Off
  delay(500);
}

void setColor(uint8_t r, uint8_t g, uint8_t b) {
  pixel.setPixelColor(0, pixel.Color(r, g, b));
  pixel.show();
}

2. Coding the input: Touch sensor

I decided to recycle the speaker coil experiment and use it as a touch sensor. The code is below. After hooking it all up, it didn't work. Why? Troubleshooting:

  • Was the circuit correct? (Check, check, check.)
  • How about the connections? (Jiggle and multimeter everything.)
  • What about the conductive coil? Using a multimeter revealed that, indeed, the thread had somehow, somewhere, gotten separated. Bingo. Easy solution: Use a different coil or touch pad.

Serial monitor for touch sensor

3. Touch sensor & light swatch construction

There are so many ways to manifest this combination of touch and light. My solution falls in the categories of dynamic expression, and playful communication, but with a different input such as a temperature sensor, there's lots of potential for augmented sensing. I would love to riff on Ieva Dautartaite's swatch library by doing an exquisite corpse version of a swatch library: You could switch out the inputs and outputs in a single swatch, and have a computer alongside to play with the code. I can also envision a fashion prototyping swatch with a similar system.

This swatch represents the potential for a full-scale version of a hoodie scarf with a NeoPixel LED string inside the hood, and a touch sensor in the pocket at the end of the scarf. As a proof of concept, the sensor is currently coded to change from green to blue when you touch it, but variations can happen based on the intent, for example, a holiday-themed color palette, or just pure color fun. V2 would have options for the wearer to customize.

Hoodie sketches

Hoodie final swatch

Hoodie swatch detail

Hoodie swatch detail

Hoodie scarf concept

Troubleshooting why it stopped working...

  • I may need to adjust the tolerance, as I'm using a different touch sensor
  • Humidity change
  • What else...?

Tools

Resources


Fabrication files