Skip to content

Wearables

This week is a follow-up on Week 5: E-Textiles. We learned how to include different outputs, like lights, sounds, and motion. During the lecture, we talked about NeoPixels, fiber optics, thermochromic inks, speakers, shape memory alloys, flip dots, and vibration motors. What did I do this week? I experimented with creating a knitted speaker and creating a light sequence with the NeoPixels. With that knowledge, I added an analog button input and tried making a wearable that would not be connected to a computer with cables. Check the results.

Moodboard & Research

During the lecture, we saw different inspiring projects. Four projects caught my attention.

Video Dresses by Hussein Chalayan1, the dress uses lots of lights to create the pixels for a video. I like how every light can be coded to the color output you want and create different outputs like this. It creates kind of multiple dresses in one.

The project by Jingwen Zhu2, My Heart on My Dress, gives a real wow factor with the thermochromic inks used. I like how the dress is connected to a diary application and how one dress can tell your previous days.

The Folding Frequencies by EJ Tech3 showed me that speakers don’t have to be in a box but can be integrated into the fabric. As well, the Flip-Dot Dress by Pauline van Dongen4 showed me how you can make moving patterns with the use of lights.

During the presentation, it made me think of the use of a glove that would be used to translate hand gestures like ASL (American Sign Language) to speech or written text. I found this project by Baireddy Gopala Krishna, in which he made the glove using flex sensors.

Pictures of inspiration

With this week and these projects, the recyclability of the products is low. This project was also shared during the lecture: the Development of cellulose-based optical textile sensors by Sofia Guridi, Emmi Pouta, Ari Hokkann, and Aayush Kumar Jaiswal5. Here, they explored the use of carboxymethyl cellulose (CMC) optical waveguides in yarn structures to create textile-based optical sensors.

Process

The assignment this week was to make two output swatches and one input used with an output.

Knit Speaker

I started experimenting with the speaker. In the lecture, a knitted speaker by Kobakant was shown, and it made me curious if I could replicate that. In the betaKnit Research eTextile Sweatshop & Test_Lab by Piem Wirtz and Karla Spiluttini6. They tested different swatches made with copper wire. I knitted a tiny swatch with copper wire and made a test.

Diagram of setup for speaker

To check the circuit I used the speaker and code made by Diane Wakim. I couldn't upload the code to the board because the pichtes.h libary was not found. With the notes used I asked claude which numbers the notes had and I got the list that is included in the code ("#difine NOTE"). If you have the pitches.h libary installed you can change these notes for "#include "pitches.h"".

Melody code for Arduino by Diane Wakim
/* Generating a melody with Arduino Tone() and the pitches library */

#define NOTE_B3   247
#define NOTE_CS4  277
#define NOTE_DS4  311
#define NOTE_D4   294
#define NOTE_G4   392
#define NOTE_A4   440
#define NOTE_AS4  466

const int speaker = 3; //speaker to arduino pin 3

// notes in the melody:
int melody[] = {
    NOTE_DS4, NOTE_DS4, NOTE_DS4, NOTE_DS4, NOTE_B3, NOTE_CS4, NOTE_DS4, NOTE_CS4, NOTE_DS4
};

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

void setup(){
    pinMode(speaker, OUTPUT);
}

void loop(){
    noTone(speaker);     // Stop sound...
    delay(1000);        // ...for 1sec

for (int thisNote = 0; thisNote < 9; 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(speaker, 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(speaker);
    }
}

The circuit was working at this point, but when attaching my copper wire swatch no sound was heard. I decided to test some different materials, I knitted a swatch with E-Textile Linen GiMP and Merinox-Cordonner.

Knit speaker swatches

Sadly, those two were not working either with this setup. I asked for advice from the group and was introduced to the site of Nadia Campo Woytuk, who made a knitted speaker before. She made the same tests as in the betaKnit research with some copper thread. She used some paper to make the vibration/sound. When I tried that, I finally heard a faint sound from the copper wire. The linen and merino were still not working.

NeoPixels

During the tutorial from Jessica Stanley, we attached the NeoPixel to the board and learned how to code it. I did not have the correct cable, so I couldn’t upload the code to the board (Adafruit QT Py ESP32-S3 No PSRAM) to see if the circuit was working. The next day, I soldered the board onto the flexible pad.

Soldering

I made one mistake here: I soldered the board on the wrong side, which resulted in the labels not aligning. This made the following steps more difficult, I needed to look closely at the lines on the flexible pad where every connection was. Either way, I made the circuit with a 3-pixel NeoPixel, uploaded the code with a working cable, and started exploring the options.

Diagram of circuit Neopixel

After I knew the circuit was working. I opened Tinkercad and started exploring the code, with the help of Claude. I created a three-color sequence that looks like the colors (red, yellow, and purple) are following each other.

Red-Yellow-Purple sequence code for Arduino
#include <Adafruit_NeoPixel.h>

#define PIN       SDA
#define NUMPIXELS 3

Adafruit_NeoPixel pixels(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);

// Colors (R, G, B)
const uint32_t OFF    = 0;
const uint32_t RED    = Adafruit_NeoPixel::Color(255, 0, 0);
const uint32_t YELLOW = Adafruit_NeoPixel::Color(255, 160, 0);
const uint32_t PURPLE = Adafruit_NeoPixel::Color(150, 0, 255);

// Each row is one step: {light 1, light 2, light 3}
const uint32_t steps[][3] = {
  {RED,    OFF,    OFF},     // 1: first light red
  {YELLOW, RED,    OFF},     // 2: second red, first yellow
  {PURPLE, YELLOW, RED},     // 3: third red, second yellow, first purple
  {OFF,    PURPLE, YELLOW},  // 4: first off, second purple, third yellow
  {OFF,    OFF,    PURPLE},  // 5: first and second off, third purple
  {OFF,    OFF,    OFF},     // 6: all off
};
const int NUMSTEPS = sizeof(steps) / sizeof(steps[0]);

const int STEP_DELAY = 1500;  // milliseconds between steps

void setup() {
  pixels.begin();
  pixels.setBrightness(20);
}

void loop() {
 for (int s = 0; s < NUMSTEPS; s++) {
    for (int i = 0; i < NUMPIXELS; i++) {
      pixels.setPixelColor(i, steps[s][i]);
    }
pixels.show();
delay(STEP_DELAY);
}
}

This was working in Tinkercad.

I wanted to add another sequence, but I didn’t want to have this one disappear. I added an input and changed up the code.

Input

I chose to attach an analog input because I wanted it to change the sequence and nothing in between, which I would get with a digital input. Before making changes to my physical circuit, I tested it out in Tinkercad. I added a switch connected to GND and A2 (in Tinkercad)/ A0 (in physical version). I first made a code where the switch needs to be on to play the existing sequence. I added the if function in the “void loop" to create this.

Diagram of circuit NeoPixel with one button

Red-Yellow-Purple sequence with one switch code for Arduino
#include <Adafruit_NeoPixel.h>

#define PIN        SDA   // NeoPixel
#define BUTTON_PIN A0   // button between this pin and GND
#define NUMPIXELS  3

Adafruit_NeoPixel pixels(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);

// Colors (R, G, B)
const uint32_t OFF    = 0;
const uint32_t RED    = Adafruit_NeoPixel::Color(255, 0, 0);
const uint32_t YELLOW = Adafruit_NeoPixel::Color(255, 160, 0);
const uint32_t PURPLE = Adafruit_NeoPixel::Color(150, 0, 255);

// Each row is one step: {light 1, light 2, light 3}
const uint32_t steps[][3] = {
  {RED,    OFF,    OFF},     // 1: first light red
  {YELLOW, RED,    OFF},     // 2: second red, first yellow
  {PURPLE, YELLOW, RED},     // 3: third red, second yellow, first purple
  {OFF,    PURPLE, YELLOW},  // 4: first off, second purple, third yellow
  {OFF,    OFF,    PURPLE},  // 5: first and second off, third purple
  {OFF,    OFF,    OFF},     // 6: all off
};
const int NUMSTEPS = sizeof(steps) / sizeof(steps[0]);

const unsigned long STEP_DELAY = 1500;  // milliseconds between steps

// Waits for the given time, but returns false immediately if the button is released
bool waitWhilePressed(unsigned long ms) {
  unsigned long start = millis();
  while (millis() - start < ms) {
    if (digitalRead(BUTTON_PIN) == HIGH) return false;  // released
  }
  return true;
}

void setup() {
  pinMode(BUTTON_PIN, INPUT_PULLUP);
  pixels.begin();
  pixels.setBrightness(20);
  pixels.clear();
  pixels.show();
}

void loop() {
  if (digitalRead(BUTTON_PIN) == LOW) {          // button pressed
    for (int s = 0; s < NUMSTEPS; s++) {
      for (int i = 0; i < NUMPIXELS; i++) {
        pixels.setPixelColor(i, steps[s][i]);
        }
        pixels.show();
        if (!waitWhilePressed(STEP_DELAY)) break;  // stop early if released
    }
} else {                                       // button not pressed
    pixels.clear();
    pixels.show();
}
}

For adding another sequence, I made a new switch and added it into the code. This sequence will have three colors as well: blue, orange, and green, and will not follow each other like sequence 1, but will be a bit more random. The new switch is connected to GND and A3 (in Tinkercad) / A2 (in physical version).

Diagram of circuit NeoPixel with two buttons

Two sequences with two switches code for Arduino
#include <Adafruit_NeoPixel.h>

#define PIN         SDA   // NeoPixel
#define BUTTON_A    A0   // button 1 between this pin and GND
#define BUTTON_B    A2   // button 2 between this pin and GND
#define NUMPIXELS   3

Adafruit_NeoPixel pixels(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);

// Colors (R, G, B)
const uint32_t OFF    = 0;
const uint32_t RED    = Adafruit_NeoPixel::Color(255, 0, 0);
const uint32_t YELLOW = Adafruit_NeoPixel::Color(255, 160, 0);
const uint32_t PURPLE = Adafruit_NeoPixel::Color(150, 0, 255);
const uint32_t BLUE   = Adafruit_NeoPixel::Color(0, 0, 255);
const uint32_t GREEN  = Adafruit_NeoPixel::Color(0, 255, 0);
const uint32_t WHITE  = Adafruit_NeoPixel::Color(255, 255, 255);

// Sequence A (button 1): your original one
const uint32_t stepsA[][3] = {
  {RED,    OFF,    OFF},
  {YELLOW, RED,    OFF},
  {PURPLE, YELLOW, RED},
  {OFF,    PURPLE, YELLOW},
  {OFF,    OFF,    PURPLE},
  {OFF,    OFF,    OFF},
};
const int NUMSTEPS_A = sizeof(stepsA) / sizeof(stepsA[0]);

    // Sequence B (button 2): change these to whatever you like
const uint32_t stepsB[][3] = {
  {BLUE,  OFF,   OFF},
  {GREEN, BLUE,  OFF},
  {WHITE, GREEN, BLUE},
  {OFF,   WHITE, GREEN},
  {OFF,   OFF,   WHITE},
  {OFF,   OFF,   OFF},
};
const int NUMSTEPS_B = sizeof(stepsB) / sizeof(stepsB[0]);

const unsigned long STEP_DELAY = 1500;

bool pressed(int pin) {
  return digitalRead(pin) == LOW;
}

// Waits for the given time, but returns false immediately if the button is released
bool waitWhilePressed(int pin, unsigned long ms) {
  unsigned long start = millis();
  while (millis() - start < ms) {
    if (!pressed(pin)) return false;
  }
  return true;
}

// Plays a sequence while the given button is held
void playSequence(const uint32_t steps[][3], int numSteps, int buttonPin) {
  for (int s = 0; s < numSteps; s++) {
    for (int i = 0; i < NUMPIXELS; i++) {
      pixels.setPixelColor(i, steps[s][i]);
    }
    pixels.show();
    if (!waitWhilePressed(buttonPin, STEP_DELAY)) break;
  }
}

void setup() {
  pinMode(BUTTON_A, INPUT_PULLUP);
  pinMode(BUTTON_B, INPUT_PULLUP);
  pixels.begin();
  pixels.setBrightness(20);
  pixels.clear();
  pixels.show();
}

void loop() {
  bool a = pressed(BUTTON_A);
  bool b = pressed(BUTTON_B);

  if (a && !b) {
    playSequence(stepsA, NUMSTEPS_A, BUTTON_A);
  } else if (b && !a) {
    playSequence(stepsB, NUMSTEPS_B, BUTTON_B);
  } else {
    // nothing pressed, or both pressed: lights off
    pixels.clear();
    pixels.show();
  }
}

This worked perfectly in Tinkercad, but it took some time to make this work in my physical circuit. Probably because of how the NeoPixel was attached to the alligator clips and how the board was soldered onto the flexible pad. Because the labels don’t align, the A1 was going to the ground of the flexible pad, and those didn’t seem to work, and the A2 and A3 didn’t have a place on the flexible pad. To connect them, I needed to clip the alligator clip to the board itself and not to the flexible pad. This seemed to fix the problem with the board, and for the attachment of the NeoPixel, I pressed down on the switches, and that worked fine.

I found it a bit boring that when both switches were on, the first turned-on sequence was running, so no difference. I added another sequence to the code for when both switches were turned on. This sequence is random colors, random brightness, random placement, and random switching times.

Final NeoPixel code for Arduino
#include <Adafruit_NeoPixel.h>

#define PIN         SDA   // NeoPixel
#define BUTTON_A    A0   // button 1 between this pin and GND
#define BUTTON_B    A2   // button 2 between this pin and GND
#define NUMPIXELS   3

Adafruit_NeoPixel pixels(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);

// Colors (R, G, B)
const uint32_t OFF    = 0;
const uint32_t RED    = Adafruit_NeoPixel::Color(255, 0, 0);
const uint32_t YELLOW = Adafruit_NeoPixel::Color(255, 160, 0);
const uint32_t PURPLE = Adafruit_NeoPixel::Color(150, 0, 255);
const uint32_t BLUE   = Adafruit_NeoPixel::Color(0, 0, 255);
const uint32_t GREEN  = Adafruit_NeoPixel::Color(0, 255, 0);
const uint32_t ORANGE = Adafruit_NeoPixel::Color(255, 143, 0);

// Sequence A (button 1) - Each row is one step: {light 1, light 2, light 3}
const uint32_t stepsA[][3] = {
  {RED,    OFF,    OFF},     // 1: first light red
  {YELLOW, RED,    OFF},     // 2: second red, first yellow
  {PURPLE, YELLOW, RED},     // 3: third red, second yellow, first purple
  {OFF,    PURPLE, YELLOW},  // 4: first off, second purple, third yellow
  {OFF,    OFF,    PURPLE},  // 5: first and second off, third purple
  {OFF,    OFF,    OFF},     // 6: all off
};
const int NUMSTEPS_A = sizeof(stepsA) / sizeof(stepsA[0]);

// Sequence B (button 2)
const uint32_t stepsB[][3] = {
  {BLUE, ORANGE, GREEN},
  {ORANGE, OFF, ORANGE},
  {GREEN, ORANGE, BLUE},
  {ORANGE, BLUE, ORANGE},
  {BLUE, OFF, BLUE},
  {GREEN, BLUE, ORANGE},
  {OFF, OFF, OFF},
};
const int NUMSTEPS_B = sizeof(stepsB) / sizeof(stepsB[0]);

const unsigned long STEP_DELAY = 1500;  // milliseconds between steps

bool pressed(int pin) {
  return digitalRead(pin) == LOW;
}

// Waits for the given time, but returns false immediately if the button is releasd
bool waitWhilePressed(int pin, unsigned long ms){
  unsigned long start = millis();
  while (millis() - start < ms){
    if (!pressed(pin)) return false;
    if (pressed(BUTTON_A) && pressed(BUTTON_B)) return false;
  }
  return true;
}

// Plays a sequence while the given button is held
void playSequence(const uint32_t steps[][4], int numSteps, int buttonPin){
  for (int s= 0; s < numSteps; s++){
    for (int i = 0; i < NUMPIXELS; i++){
      pixels.setPixelColor(i, steps[s][i]);
   }
    pixels.show();
    if (!waitWhilePressed(buttonPin, STEP_DELAY)) break;
  }
}

// Party mode: fast, random colors on every pixel
void playParty() {
  for (int i = 0; i < NUMPIXELS; i++) {
    pixels.setPixelColor(i, pixels.ColorHSV(random(65536), 255, 255));
  }
  pixels.show();
  delay(100);  // lower = faster
}

void setup() {
  pinMode(BUTTON_A, INPUT_PULLUP);
 pinMode(BUTTON_B, INPUT_PULLUP);
 pixels.begin();
  pixels.setBrightness(20);
  pixels.clear();
  pixels.show();
  randomSeed(analogRead(A1));
}

void loop() {
  bool a = pressed(BUTTON_A);
  bool b = pressed(BUTTON_B);

  if (a && !b){
    playSequence(stepsA, NUMSTEPS_A, BUTTON_A);
  } else if (b && !a) {
    playSequence(stepsB, NUMSTEPS_B, BUTTON_B);
  } else if (a && b) {
    playParty();                                // both pressed: party mode
  } else {
    //nothing pressed, or both pressed: lights off
    pixels.clear();
    pixels.show();
  }
}

In Tinkercad, this code had no problems and was exactly what I would like to replicate in my physical copy.

I uploaded the code to the board, it worked! I played a bit with it myself and asked if my boyfriend wanted to test it. It made me think of other ways to make it more interactive. For example, adding more buttons and sequences, maybe even colored ones. So, when you close the blue button, the NeoPixel will show a blue sequence, and the same for an orange. But when you close them both at the same time, the sequence becomes blue and orange. And so on, when all the buttons are closed, it’s a random sequence.

Light bracelet

This week is called wearable, and at this point the circuit is still attached to the computer. To change this, I tested the circuit by connecting the 5V and GND to a 9V battery.

Diagram of circuit NeoPixel with two buttons and battery

It lit up the NeoPixel, and the sequences were still working when pressing the buttons. With this knowledge, I cut out a piece of stretchy fabric that was a bit bigger than the board and the battery. I made it double-layered so the lights would diffuse a bit and be less bright.

Start of bracelet drawing

From this point, I slowly started to take away the alligator clips and sew in the circuit. Starting with the NeoPixel and the board. Before going on, I tested whether the lights still worked by connecting the board to my laptop. Sadly, the lights didn’t turn on.

That is how far I got for now. I will use a multimeter to test whether the sewn parts are working well or if there is another problem in the circuit. Hopefully, I will find where the problem is and fix it.

Results

References