Skip to content

5. E-textiles

goals of the week & contents

  • Produce one digital and one analog soft sensor.
  • Try to reproduce the same sensor with different materials/techniques (hard/hard hard/soft soft/soft).
  • Create my own digital and analog soft sensor.
  • Program a LED interaction with a soft sensor.
  • Integrate it in a swatch using hard-soft connections.


Here are some inspiring projects developed by previous participants:


FOUNDATIONAL KNOWLEDGE

Voltage (V) (Unit: Volts). Is the measure of electric potential energy per unit charge. It represents the force that pushes electric charges through a circuit.

Current (I) (Unit: Amperes). Is the flow of electric charge through a conductor, like a wire. It represents how many charges are moving through the circuit per second.

Resistence (R) (Unit: Ohms Ω). Is a measure of how much a material opposes the flow of electric current. It determines how much current will flow for a given voltage.


An Input refers to the data, signals, or information that is fed into a system or device for processing. It can come from various sources, such as sensors, user commands, or other systems.

An Output is the data, signals, or information that is produced by a system or device after processing the input.

In a Series Circuit, components are connected in a single path, meaning the same current flows through each component, but the voltage is divided among them. If one component fails, the entire circuit stops working.

In a Parallel Circuit, components are connected in multiple paths, so each component gets the same voltage, but the current is split across the branches. If one component fails, the rest continue to work.


HARD & SOFT CONNECTIONS

  • Hard/Hard: Both the sensor and the conductive connections are made from rigid or stiff materials. For example, using copper tape or metal wires on a firm surface like plastic or cardboard.
  • Hard/Soft: This involves combining rigid and flexible materials. For example, using conductive thread sewn into fabric along with rigid electronic components like a circuit board.
  • Soft/Soft: Both the sensor and the conductive connections are made entirely of flexible materials. For instance, using conductive fabric for both the sensor and the connections.

A Digital Sensor provides a binary output: it only has two states, typically on (1) or off (0). It detects whether a certain condition is done or not, like a button press or a motion sensor.

An Analog Sensor, gives a range of values rather than just two. It detects continuous data, like temperature, light levels, among others. The output is typically a variable voltage that represents different levels, which is read by the Arduino as a number within a range (ex: 0-1023).

Conductive Fabrics:

  • Velostat

  • Eeontex

  • Copper Conductive Fabric

  • Pure Copper Polyester Taffeta

  • VeilShield

  • SaniSilver

  • Ripstop Silver Fabric

  • Silver Strecth Conductive Fabric

  • Safety Silk

  • Soft and Safe Shielding Fabric

  • ESD Foam

Conductive Thread & Yarns:

  • Elitex

  • Karl Grimm

  • Bekinox

  • Adafruit Stainless Steel

  • Silverspun Yarn

Conductive Inks & Tapes:

  • CuProCote by Less EMF

  • Bare Conductuve

  • Circuit Scribe

  • Copper Tape

  • Copper Foil Sheet

  • Conductive Fabric Tape


Material Details
Microcontroller Arduino UNO or ATtiny
ATtiny ATtiny45 or ATtiny85
AVR programmer or Arduino UNO
Arduino kit Arduino Starter kit
Neopixels sewable Flora neopixels
Adafruit Gemma Gemma board
FTDI cable or FTDI board
Fabrics resistive/conductive fabrics
Threads resistive/conductive threads
Inks resistive/conductive inks (thermochromic ink)
Velostat pressure-sensitive conductive sheet
Snap metal buttons +Metallic zippers
Copper tape + insulating tape
Actuators Mini vibration motors, speakers...
Wires jumpers, alligator clips

Table from Fabricademy Handbook.


tools


research & ideation

inspiraçao

  1. GALAXY (2006), MAGGIE ORTH, interactive installation that allows viewers to control light patterns by touching a field of soft and tactile electronic pompoms and tufts.
  2. KNITTED VU METER, JESSE SEAY, machine-knitted with Kevlar and copper wire. Circuit is a volume meter that responds to sound.
  3. FIREFLY DRESS & NECKLACE (1998), MAGGIE ORTH, when the wearer moves, the conductive Velcro brushes against the conductive fabric, completing the circuit and causing the LEDs to light. The necklace gets it power from conductive tassels brushing an embroidered power plane on the front of the dress, each tassel sends a different amount of current to the necklace, causing the LEDs to flicker and change color.
  4. NICOLA WOODHAM, Nicola has been exploring ways to generate music with hand-made e-textile sensors and wearables, placing soft sensors on the body to control sound during live performance.
  5. TAPIS MAGIQUE: A CHOREOMUSICAL INTERACTIVE CARPET, IRMANDY WICAKSONO, pressure-sensitive, knitted electronic textile carpet that generates three-dimensional sensor data based on body postures and gestures and drives an immersive sonic environment in real-time.
  6. E-TEXTILES MAKE SOUNDS LIKE ELETRONIC MUSICAL INSTRUMENTS WHEN USERS TOUCH OR STRETCH THEM, SOPHIE SKACH & VICTOR SHEPARDSON, these smart fabrics can generate sounds that may complement music composition and, in a way, transform instruments into intelligent devices through their surfaces.
  7. NEUROKNITTING: SCARVES MADE FROM BRAINWAVE ACTIVITY, VARVARA GULJAJEVA, MAR CANET & SEBASTIAN MEALLA, collection of scarves made with ‘knitic’, an open hardware knitting machine that translates brainwaves into physical garments. Using a wearable, non-invasive EEG headset, the system records a users’ effective brain state while listening to music, after down-sampling 10 minutes of data into special software, the knitting machine measures signals from relaxation, excitement, and cognitive load responses, converting the wave-lengths into a unique pattern.


While I was researching, I discovered a YouTube channel that serves as an archive for the work of Hannah Perner-Wilson. Later I found out that she is one of the co-founders of KOBAKANT, along with the artist and designer Mika Satomi. Her channel features a wealth of documentation, tutorials, and project showcases, all shared as open-source resources.

She focuses on exploring the electrical properties of various materials, blending traditional and contemporary craft techniques to develop innovative methods for building electronics that emphasize both materiality and the creative process. You can check her personal website.




workflow

materials

Here, I have a collection of materials we used during the classes. Among them, we worked with a Multimeter (using the black wire for negative and the red wire for positive connections) to test conductivity and resistance in various components. We also experimented with Conductive Fabric, like copper taffeta, which is ideal for integrating into soft circuits due to its excellent conductivity.

The Microcontroller we used is XIAO_ESP32S3 by Seeed Studio.

materials


circuit testing

I’ve never worked with electronics before, so everything was new to me, and this week was packed with information that was a bit overwhelming to absorb. Despite being a bit lost with some of the concepts, I’m completely amazed by this world. The possibilities are endless, and the potential to create unique and extraordinary results is incredibly exciting.

Two things that really stood out to me this week are the use of stretch, squeeze and touch sensors with conductive materials to control sound in a MIDI setup, even allowing the creation of a custom keyboard. It was so much fun! I have some people in the music industry around me, and while I never felt particularly skilled in that area, the idea of having a sample connected to a controller and simply playing with it to trigger different sounds, along with the ability to manipulate those sounds, really sparked my curiosity. It’s a direction I’m eager to explore further, experimenting with different ways and materials.

The other concept that caught my attention was using movement to manipulate conductive samples and control LEDs switching on and off. I experimented with this a bit during the week, and I’m excited about the potential to continue developing this idea.


leds

The first practical class was an opportunity for us to familiarize ourselves with the concepts we had learned the day before and to experiment with simple circuits. I may have done a few short circuits along the way, but it's all part of the process :D.

  1. Basic LED Circuit: I connected a 3V battery to an LED, with the positive leg of the LED connected to the battery's positive terminal and the negative leg connected to the battery's negative terminal.
  2. Parallel Circuit: I built a parallel circuit with two LEDs powered by a 3V battery, using alligator clip wires for the connections. Both LEDs were connected to the battery in parallel, meaning each LED receives the same voltage, but current is shared between them. This setup ensures that if one LED fails, the other continues to function.
  3. Foil Circuit: The foil acted as a conductor between the power source and the LED.
  4. Pressure Sensor with Velostat: I modified the previous foil circuit by placing a piece of Velostat (a pressure-sensitive material) between the layers of foil. This created a pressure-sensitive circuit where the LED lights up or dims based on the amount of pressure applied to the Velostat.
  5. Button Circuit: In this circuit, I replaced the continuous conductive path with pressed buttons. These buttons acted as switches, when pressed or touched, lighting up the LED.
  6. Non-Conductive Fabric Circuit: Similar to the third experiment, but with a non-conductive fabric with a hole in between the foil layers. The hole in the fabric allowed the two foil layers to make contact only through the hole, acting as a simple switch.


DIGITAL SENSOR

In Nuria Robles' class, we constructed a textile-based circuit using non-conductive fabric, conductive tape, a 3V battery, an LED, foil, non-conductive thread, and alligator clip wires. The goal was to explore soft circuit design, using fabric and materials commonly found in e-textiles.

We began by creating the battery holder. First, we applied conductive tape to the circular ends of the piece of non-conductive fabric. This conductive tape would later form the contact points for the battery. After that, we folded the fabric into a pocket shape, stitching along the sides to secure it, creating a small pouch to hold the battery. The battery was then inserted, with careful attention paid to ensure the positive (+) and negative (-) terminals were correctly aligned with the conductive tape on the fabric.

Next, we made a soft switch. For this, I used three circular pieces of non-conductive fabric. The middle layer had a hole cut out in the center. The switch was assembled as follows: first, a circle of fabric, then a piece of foil, followed by the middle circle (with the hole), another piece of foil, and finally, the top circle of fabric. The foil layers acted as conductive elements in the switch, while the non-conductive fabric isolated the connection until the button was pressed. I glued conductive tape to the edges of the foil layers to ensure solid connections. To secure the switch components, I sewed around the perimeter of the fabric layers, keeping everything in place.

With the battery holder and switch prepared, the next step was to assemble the full circuit on a larger piece of non-conductive fabric. I glued the conductive tape, that is taped on the button, on the fabric base.

Now, was time to make the circuit:

  • The positive terminal of the battery (connected via conductive tape) was linked to the positive leg of the LED using the red alligator clip wire.

  • The negative terminal of the battery was connected to one side of the soft switch, using the black alligator clip wire.

  • The white alligator clip wire connected the other side of the soft switch to the negative leg of the LED.

  • Once everything was connected, pressing the soft switch allowed the circuit to close, lighting up the LED.


DIGITAL SENSOR SWATCH

swatch

For this swatch, I replaced all the alligator clips with conductive tape to eliminate any hard materials. The circuit begins at the positive terminal of the battery, which connects to the positive leg of the LED. From there, conductive tape is used to carry the connection through to the switch button (which is connected to a piece of foil), and finally, the circuit completes by connecting to the negative terminal of the battery.


arduino IDE work

graphic

Scheme from Seeed Studio website.

The Seeed Studio website is an excellent resource for troubleshooting and finding solutions to your projects. They have a wealth of information that is clearly explained, making it easy to follow along. If you're using a microcontroller from Seeed Studio, especially the same one I’m using, I highly recommend keeping their pinout diagrams handy while working on your breadboard connections, and will save you time and help avoid mistakes when setting up your circuit.



2aula

1 FADE LED

Building this Circuit on a Breadboard:

  • Start by inserting the LED and the microcontroller into the Breadboard.

  • Connect the 220Ω Resistor. Attach one end of the resistor to the longer leg (+) of the LED and the other end to pin A0 of the microcontroller.

  • Connect the short leg (-) of the LED to the GND, using a jumper wire.


CODE:

const int LED_pin = A0;  // Pin the LED is attached to

int brightness = 0;  // how bright the LED is
int fadeAmount = 5;  // how many points to fade the LED by

// the setup function runs once when you press reset or power the board
void setup() {
  // initialize LED_pin as an output
  pinMode(LED_pin, OUTPUT);
}

// the loop routine runs over and over again forever:
void loop() {
  // set the brightness of the LED:
  analogWrite(LED_pin, brightness);

  // change the brightness for next time through the loop:
  brightness = brightness + fadeAmount;

  // reverse the direction of the fading at the ends of the fade:
  if (brightness <= 0 || brightness >= 255) {  // if brightness is smaller or equal to 0 or if brightness is bigger or equal to 255
    fadeAmount = -fadeAmount;
  }
  // wait for 30 milliseconds to see the dimming effect
  delay(30);
}


fade led


2 LDR AnalogRead SERIAL + FADE LED

Building this Circuit on a Breadboard:

  • Start by inserting the LED and the microcontroller into the Breadboard.

  • Connect the 220Ω Resistor. Attach one end of the resistor to the longer leg (+) of the LED and the other end to pin A0 of the microcontroller.

  • Connect the short leg (-) of the LED to the GND, using a jumper wire.

  • Connect one leg of the LDR to pin A1 on the microcontroller. The other leg to 3V3, using a jumper wire.

  • Connect one of the legs of the 10KΩ Resistor to the LDR leg that its on pin A1. The other leg connect to GND, using a jumper wire.


CODE:

int sensor_pin = A1;
int LED_pin = A0;  // Pin the LED is attached to
int brightness = 0;  // how bright the LED is

// the setup routine runs once when you press reset:
void setup() {
  // initialize serial communication at 115200 bits per second:
  Serial.begin(115200);
  pinMode(LED_pin, OUTPUT);
}

// the loop routine runs over and over again forever:
void loop() {
  // read the input on analog pin 0:
  int sensorValue = analogRead(sensor_pin);
  // print out the value you read:
  Serial.println(sensorValue);
  brightness = map(sensorValue, 3950, 4013, 0, 255);
  brightness = constrain(brightness, 0, 255);
  Serial.println("Mapped brightness value:");
  Serial.println(brightness);
  analogWrite(LED_pin, brightness);

  delay(100);  // delay in between reads for stability
}


fritzing

  • Fritzing is an open-source software designed to help create and document electronic circuits in a visual way. It provides tools for creating breadboard layouts, schematic diagrams, and printed circuit board (PCB) designs. Although it was initially free, Fritzing now requires a one-time payment to download the software.

Issy and I used Fritzing to create this schematic below of the circuit above, which helped us understand the software's interface and tools. Fritzing is quite intuitive, allowing us to visualize and build electronic circuits easily. However, after making the connections on the breadboard, we had to arrange and simplify the schematic, because proper organization is key for better readability and understanding of the design.


3 PIEZZO BUZZER INTEGRATION & SQUEEZE SENSOR

The video below showcases four different circuits we built, each highlighting a different interaction.

  • First Circuit (CODE 1): This circuit features a piezzo buzzer connected to the microcontroller through the breadboard, playing sounds based on the predefined code.
  • Second Circuit (LED synced with sound): In this circuit, we added a LED that blinks in sync with the sound from the piezzo buzzer. To achieve this, I modified the code by introducing a digitalWrite function to turn the LED on and off according to the tone’s duration. I used the same timing logic for the sound and LED, ensuring that the LED blinked in rhythm with the notes being played.
  • Third Circuit (Squeeze sensor): We used a squeeze digital sensor integrated with a knitted sample that had conductive thread. This sensor was connected to a LED, and the behavior was straightforward: when the sample was squeezed, the LED turned on; when released, it turned off. This circuit demonstrated the functionality of a pressure sensor using fabric-based interaction.
  • Fourth Circuit (Combined) (CODE 2): In the final circuit, both the speaker and LED were activated by squeezing the knitted sensor. When pressure was applied, the melody played on the speaker while the LED turned on.

These are the pitch values or the "pitches.h" file referenced in the code, download here1.


CODE 1:

#include "pitches.h"

int speakerPin = 1;

// notes in the melody:
int melody[] = {
  NOTE_C4, NOTE_G3, NOTE_G3, NOTE_A3, NOTE_G3, 0, NOTE_B3, NOTE_C4
};

// note durations: 4 = quarter note, 8 = eighth note, etc.:
int noteDurations[] = {
  4, 8, 8, 4, 4, 4, 4, 4
};

void setup() {
}

void loop() {
  // iterate over the notes of the melody:
  for (int thisNote = 0; thisNote < 8; thisNote++) {

    // to calculate the note duration, take one second divided by the note type.
    //e.g. quarter note = 1000/4, eighth note = 1000/8, etc.
    int noteDuration = 1000 / noteDurations[thisNote];
    tone(D0, melody[thisNote], noteDuration);

    // to distinguish the notes, set a minimum time between them.
    // the note's duration + 30% seems to work well:
    int pauseBetweenNotes = noteDuration * 1.30;
    delay(pauseBetweenNotes);
    // stop the tone playing:
    noTone(D0);
  }
}



CODE 2:

#include "pitches.h"

int speaker_pin = A2;  // Pin the LED is attached to
int touch_pin = T2;    // Pin that we're going to touch
int melody[] = {
NOTE_C4, NOTE_G3, NOTE_G3, NOTE_A3, NOTE_G3, 0, NOTE_B3, NOTE_C4
};

// note durations: 4 = quarter note, 8 = eighth note, etc.:
int noteDurations[] = {
4, 8, 8, 4, 4, 4, 4, 4
};

// change with your threshold value
int threshold = 100000;
// variable for storing the touch pin value
int touchValue;

// the setup function runs once when you press reset or power the board
void setup() {
// initialize serial communication at 115200 bits per second:
Serial.begin(115200);
// initialize LED_pin as an output
pinMode(A2, OUTPUT);
}

// the loop function runs over and over again forever
void loop() {
touchValue = touchRead(touch_pin);
Serial.println(touchValue);

if (touchValue > threshold) {


    for (int thisNote = 0; thisNote < 8; thisNote++) {

    // to calculate the note duration, take one second divided by the note type.
    //e.g. quarter note = 1000 / 4, eighth note = 1000/8, etc.
    int noteDuration = 1000 / noteDurations[thisNote];
tone(1, melody[thisNote], noteDuration);

// to distinguish the notes, set a minimum time between them.
// the note's duration + 30% seems to work well:
int pauseBetweenNotes = noteDuration * 1.30;
delay(pauseBetweenNotes);
// stop the tone playing:
noTone(1);

delay(50);
}

schematic


Important Notes and Tips:

  • If you encounter a certain fatal error (not all of them can be soluted with this, google first!) while plugging the microcontroller, press and hold the 'B' button, to enter boot mode.
  • If the microcontroller is not being recognized or the mapping stops working, press the 'R' button to reset the board and reconnect it to the computer.
  • After resetting, wait a few seconds for the microcontroller to reboot before attempting to upload the code again.
  • To obtain a wider range of values from your sensor, increase the resistor value to 20k ohms. You can achieve this by connecting resistors in series to add up to the desired resistance. You can also adjust the fixed resistor value in your voltage divider setup to better match the resistance range of your e-textile sensor. Ideally, the fixed resistor should have a value within a similar range to your sensor’s resistance. For example, if your e-textile sensor’s resistance varies between 20kΩ and 50kΩ, selecting a fixed resistor value within this range (ex. 30kΩ or 40kΩ) can optimize the voltage divider's performance and sensitivity.
  • If you're experimenting with textiles and want to measure resistance across a fabric sample, you can replace the 10k ohms resistor with a jumper wire with an alligator clip. This setup allows you to clip onto the conductive areas of your textile, letting the fabric act as part of the circuit and providing a variable resistance based on touch or stretch.


4 JUMPER WIRE WITH ALLIGATOR CLIP

Michelle guided us through the process of creating our own jumper wires, with an alligator clip on one end, so we could connect our textile samples or other components to the circuits we were building on the breadboard.

jumperaligatorwire

Here's a step-by-step breakdown of the process:

  • Start by cutting the jumper wire and the alligator clip wire in half using a wire stripper. Then, strip about 5 mm of insulation from the ends of both wires to expose the copper strands.
  • Take the stripped ends of the wires and carefully twist them together to create a secure connection.
  • Before soldering, slide a piece of heat shrink tubing onto the jumper wire, leaving enough space to cover the exposed solder joint later.
  • Heat the twisted wire joint with the soldering iron. Once the wire is hot, apply a small amount of solder to the joint. Be careful not to apply too much solder, and avoid inhaling the smoke. Let the joint cool down for a moment.
  • Next, position the heat shrink tubing over the exposed area of the wire. Use a hot gun to carefully shrink the tubing, ensuring it molds tightly around the wire and covers the solder joint completely.
  • After the heat shrink has cooled for about a minute, test the connection by clipping the alligator clip to something and plugging in the jumper wire.


5 EMBEDDING LEDs INTO TEXTILES

Michelle also demonstrated a simple method for embedding an LED into textile, allowing us to create an e-textile that could illuminate when connected to a power source. For this, we used conductive tape, a soldering iron, an LED, non-conductive fabric (denim in our case), a 3V battery, and a battery holder.

Here's the step-by-step process:

  • Begin by gluing two strips of conductive tape onto the fabric, to form a pathway for the electrical circuit. The tape will act as the conductive trace.
  • Carefully add a small amount of solder to the ends of each strip of tape. Be mindful not to overheat or melt the tape, the soldering process should only take a few seconds.
  • Take the LED and gently twist its legs so they lie flat. Position the legs onto the conductive tape and solder them in place.
  • Next, solder the battery holder to the ends of the conductive tape, ensuring the positive and negative connections correspond to the LED's legs.
  • Finally, insert the battery into the battery holder, and the circuit should now be complete!


knitting with conductive thread

The knitting process was so much fun! Two years ago, during my Erasmus in Barcelona, I took a class focused on knitwear, which gave me a little experience with knitting machines, and I also used to hand-knit a lot.

Michelle began by demonstrating how to make a simple sample on the knitting machine. Unfortunately, we didn’t have punch cards available to create patterns, so we made samples with a single color of yarn, with some portions of conductive thread, to later on play with different sensors.

Here's a simple guide how to use a knitting machine:

Casting on:

  • First, pass the yarn through the tension dial, ensuring it has the right tension.
  • The machine is threaded in a counterclockwise looping motion, beginning at position 0, and continuing through as many hooks as needed.

Knitting:

  • After the yarn is cast on, move the handle of the machine side to side to knit the fabric. The machine will push the needles back and forth, interlocking the yarn to form stitches in a continuous row.
  • If you're adding conductive thread, simply place it alongside the regular yarn and let the machine knit them together. You can experiment with different tension settings.

Casting Off:

  • Carefully lift each stitch off the needle using a small tool, like a crochet hook or a thicker needle. Pass the stitches over the next one, like the last clip of video below, until all stitches are off the machine.
  • Leave a small tail of yarn at the end and secure it by tying a knot to prevent it from unraveling.


I ended up creating two knitting samples using conductive thread, which I used as stretch and squeeze sensors to trigger sound in a MIDI setup. Initially, I planned to create a knitted glove with conductive thread embedded in the areas where the knots of the fingers would be, so that when I moved my fingers would trigger sound. However, I ultimately didn’t complete the glove. Instead, for my second sample, I knitted the ends of the knitted piece together to create a shape that would wrap around my hand, but the results were not the best.

While the first sample was highly conductive and worked well with the MIDI setup, the second sample didn’t perform as well. The conductivity in the second sample was lower, likely due to the conductive thread I used in the knit (that was different from the first sample), which resulted in less response when I interacted with it. Despite this, I enjoyed experimenting with the interaction between the conductive knit and sound!


DIGITAL TOUCH SENSOR with BLINKING LEDs

touchsensor

With this sensor I wanted to create a Digital Touch Sensor that features two LEDs to create one lighting pattern. My goal was to develop a sensor swatch that responded to touching the conductive thread on my knit sample. I used ChatGPT to help me creating the code and fixing any errors I encountered along the way.

I faced some challenges in translating the circuit design for integration into fabric, and the touch sensor wasn't working perfectly, likely because of the conductive thread, which put a hold on my progress.

Looking ahead, I’m excited to further develop this project by incorporating additional LEDs and experimenting with different patterns and configurations.


Building this Circuit on a Breadboard:

  • Use a jumper wire with an alligator clip to connect one side of your Touch Sensor to the microcontroller in pin 2.

  • Insert a 10K Ω Resistor, connect one leg to the other side of your Touch Sensor, and the other leg to GND.

  • Insert the first LED and connect a 220Ω Resistor. Attach one end of the resistor to the negative leg (-) of the LED and connect it to the GND.

  • Connect the long leg (+) of the first Led to pin 4.

  • Repeate the same process of the first LED with your second LED, but connect the long leg (+) to pin 5.


CODE:

// Define pins for the LEDs and touch sensor
const int touchPin = 2;   // Conductive thread connected to Pin 2
const int led1Pin = 4;    // First LED connected to Pin 4
const int led2Pin = 5;    // Second LED connected to Pin 5

// Timing variables
unsigned long startTime;  // Variable to track when the sensor is first touched
bool sensorTouched = false;  // Tracks the current state of the touch sensor
unsigned long lastTouchTime = 0;    // Stores the last time the sensor was touched to handle debounce
const unsigned long debounceDelay = 50;  // Ensures quick touches aren't mistakenly registered as multiple touches

void setup() {
  // Initialize the LED pins as outputs
  pinMode(led1Pin, OUTPUT);
  pinMode(led2Pin, OUTPUT);

  // Start with both LEDs off
  digitalWrite(led1Pin, LOW);
  digitalWrite(led2Pin, LOW);

  Serial.begin(115200);  // Initializes the Serial Monitor for debugging
}

void loop() {
  // Read the input from the conductive thread (touch sensor)
  bool currentTouchState = digitalRead(touchPin);  
  // `digitalRead()` checks whether the touch sensor is HIGH (touched) or LOW (not touched)

  // Check if enough time has passed for debouncing
  if (currentTouchState != sensorTouched && (millis() - lastTouchTime) > debounceDelay) {
    sensorTouched = currentTouchState;  // Update the sensor state
    lastTouchTime = millis(); // Update the last time the sensor was touched

    // Debugging: Print the touch sensor state to Serial Monitor
    Serial.print("Touch Sensor Value: ");
    Serial.println(sensorTouched);  // Helps in monitoring touch detection in real time
  }

  if (sensorTouched) {
    Serial.println("Sensor touched, starting LED sequence...");
    // When touch is detected, start the LED sequence
    digitalWrite(led1Pin, HIGH);  // Turn on the first LED
    Serial.println("LED 1 ON");
    delay(1000); // Wait for 1 second

    digitalWrite(led2Pin, HIGH);  // Turn on the second LED
    Serial.println("LED 2 ON");
    delay(1000); // Wait for 1 second

    // Blink both LEDs for 6 seconds
    unsigned long blinkEndTime = millis() + 6000;  // Calculate when to end blinking
    while (millis() < blinkEndTime) {  // Loop until 6 seconds pass
      digitalWrite(led1Pin, HIGH);
      digitalWrite(led2Pin, HIGH);
      Serial.println("Both LEDs ON");
      delay(200);   // LEDs on for 200 ms

      digitalWrite(led1Pin, LOW);
      digitalWrite(led2Pin, LOW);
      Serial.println("Both LEDs OFF");
      delay(200);   // LEDs off for 200 ms
    }

    // Turn off both LEDs after the blinking sequence
    digitalWrite(led1Pin, LOW);
    digitalWrite(led2Pin, LOW);
    Serial.println("Both LEDs OFF");
  } else {
    // When the sensor isn't touched, ensure both LEDs remain off
    digitalWrite(led1Pin, LOW);
    digitalWrite(led2Pin, LOW);
    Serial.println("Both LEDs OFF (sensor not touched)");
  }
}


Key Explanations:

  • Debounce Logic: The debounceDelay prevents the sensor from registering rapid, false touches caused by noise or brief accidental contacts.
  • digitalRead: Checks the current state of the touch sensor.
  • digitalWrite: Turns the LEDs on or off depending on the sensor's state.
  • LED Sequence: Turning LEDs On: LEDs light up in sequence when the touch sensor is activated. Blinking: A timed loop blinks both LEDs for 6 seconds before turning them off.
  • Serial Monitor Debugging: Useful messages printed to the Serial Monitor help track the state of the touch sensor and LEDs during testing.
  • Timing (millis and delay): Millis: Used for precise timing in debounce checks and blinking sequences without disrupting the program flow. Delay: Introduces pauses during the LED sequence to make actions visible.


REFLECTIONS

1. After discussing my project with Michelle and receiving her feedback, she identified the issue with my touch sensor. The sensor was only lighting up the LEDs when I touched the alligator clip, rather than responding to touches along the conductive thread in my sample. The problem lay in the code, I was using digitalRead instead of touchRead, which is necessary for properly utilizing a touch sensor.

Additionally, I had connected two alligator clips to the same sensor and routed it through a resistor to ground, which is not an ideal setup. Michelle explained that I only needed to connect one alligator clip to the sensor. She pointed out, "Did you try to wire it as if it were a digital switch? That will not work with this sensor setup; for touch detection, you only need to connect to one pin. Maybe that's why it’s only lighting up when you touch the alligator clip directly."

In the Wearables week, I created another touch sensor and ensured I connected it correctly using a single pin. This resolved the issue, and the sensor worked better.


2. I had included this line in my code:

void setup() {
// Initialize the touch sensor pin as input with a pull-down resistor
pinMode(touchPin, INPUT);  // Sets the touch sensor pin to detect signals from the conductive thread

But after Michelle’s feedback, I realized it was incorrect. My circuit neither includes nor requires a pull-down resistor because I am using a touch sensor, not a digital switch. To use a touch sensor properly, I need to determine the appropriate touch threshold and incorporate an IF statement to compare the sensor's readings against this threshold, as I did in my other codes. This is how you should use a pulldown resistor.


needle felting with conductive fiber

conductive fiber

Conductive fiber.

For my first felt sample, I started with a piece of denim and placed it in a circular felting frame. I chose two colors of wool from the lab inventory, and used carding brushes to gently blend the two colors together along with a small amount of conductive fiber.

After blending, I began the needle felting process. Using the needle, I poked through the wool and into the denim, interlocking the fibers and fabric together. I experimented by adding extra wool to create shapes, giving the sample more texture. Once I was finished with the design, I tested the conductivity of the fibers with a multimeter to measure the resistance.

sample 1 felt


ANALOG SENSOR SWATCH

This final sensor project began with an ambitious goal, I envisioned creating a sound-responsive touch sensor, made from my felt sample, with the idea of something similiar to a keyboard. For this version, I used three different colors of wool from the lab inventory. I started by blending conductive thread with pink and green wool using carding brushes, the grey wool was left as is since it doesn’t contain conductive fibers.

felt

Next, I started the needle felting process, carefully creating a tartan pattern by laying down stripes of wool and poking them through to the denim. I aimed for precision to ensure the lines looked as straight as possible.

Initially, I encountered several challenges with my code. What worked best for me was using ChatGPT, which was a good resource. By providing detailed information about my circuit and components, I was able to get advice on troubleshooting my Arduino code. After discussing my issues with Michelle, she kindly shared a corrected version of my code.


CODE:


int speaker_pin = D0;    // Pin the speaker is attached to
int touch_pin = T2;  // Pin that we're going to touch
int pitch;

// variable for storing the touch pin value and threshold. change threshold if needed
int touchValue;
int threshold = 75000; // Adjusted threshold

// the setup function runs once when you press reset or power the board
void setup() {
// initialize serial communication at 115200 bits per second:
Serial.begin(115200);
// initialize speaker_pin as an output
pinMode(speaker_pin, OUTPUT);
}

// the loop function runs over and over again forever
void loop() {
touchValue = touchRead(touch_pin);
Serial.println(touchValue);
// constrain touchValue range for useful pitch generation
touchValue = constrain(touchValue, 50000, 200000);
pitch = map(touchValue, 50000, 200000, 31, 2000);  // Reduced max pitch to 2000

Serial.println(pitch);

  // Play tone if touchValue exceeds threshold
 if (touchValue > threshold) {
  tone(speaker_pin, pitch);
} else {
noTone(speaker_pin);  // Stop tone when under threshold
}

delay(50);
}


I’ve ended up putting the more complex keyboard project on hold to focus on a simpler Digital Touch Sensor Swatch. In this design, when I touch the felt area that has a bigger concentration of conductive fibers, the speaker plays specific notes that are programmed into the code. If the felt isn’t touched, the speaker stays silent.

I used conductive thread to securely attach the speaker to a piece of wool fabric. To ensure a solid connection, I made multiple zig-zag hand stitches, carefully linking the conductive thread to the jumper wires soldered onto the speaker’s positive and negative terminals. After establishing this connection, I hand-stitched a line, leaving some extra thread at the end. This excess thread allows me to easily clip it onto an alligator clip, which connects to the microcontroller on the breadboard.

Building this Circuit on a Breadboard:

  • With a jumper wire with an alligator clip, connect the positve wire (red) of the speaker to D0.

  • Conncet the negative wire (black) to 5V.

  • Connect your Touch Sensor through pin T2 of the microcontroller.


FINAL CODE:

#include "pitches.h"

int speakerPin = D0;  // Pin connected to the speaker
int touchPin = T2;    // Pin connected to the touch sensor (T2 corresponds to GPIO2)

// Notes in the melody:
int melody[] = {
NOTE_C4, NOTE_G3, NOTE_G3, NOTE_A3, NOTE_G3, 0, NOTE_B3, NOTE_C4
};

// Note durations: 4 = quarter note, 8 = eighth note, etc.:
int noteDurations[] = {
4, 8, 8, 4, 4, 4, 4, 4
};

// Threshold for detecting a touch
int touchThreshold = 60000;  // Updated threshold closer to non-touch value
int touchBuffer = 5000;       // Buffer to handle fluctuations/noise

void setup() {
// Initialize serial communication for debugging
Serial.begin(115200);

// You can tune the touch sensor threshold if needed
touchAttachInterrupt(touchPin, NULL, touchThreshold);
}

void loop() {
// Read touch sensor value
int touchValue = touchRead(touchPin);

// Debugging: Print touch value to the serial monitor
Serial.print("Touch Value: ");
Serial.println(touchValue);

// If touch is detected, play the melody
if (touchValue > (touchThreshold + touchBuffer)) {
Serial.println("Touch detected! Playing melody...");

// Iterate over the notes of the melody
for (int thisNote = 0; thisNote < 8; thisNote++) {
// Calculate the note duration
int noteDuration = 1000 / noteDurations[thisNote];

// Play the note using tone function
Tone(speakerPin, melody[thisNote], noteDuration);

// Delay between notes to distinguish them
int pauseBetweenNotes = noteDuration * 1.30;
delay(pauseBetweenNotes);

// Stop the tone before playing the next one
noTone(speakerPin);
}
} else {
Serial.println("No touch detected.");
}

// Small delay to prevent overwhelming the serial monitor
delay(100);
}


fabrication files


  1. File: pitches.h