Interactive Embroidery

After finishing my “star constellation” embroidery piece, I was very disappointed that the supposedly metallic thread almost did not show at all- so the intended contrast between white and metallic thread was completely lost. This was sort of an inspiration to make it a little more interesting with a slightly different medium. I took couple of white LEDs and tried to incorporate them into the piece to achieve the promise that metallic thread did not meet. The idea was to make them blink in a consequent line, increasing the speed if the pressure on the sensor increases.

Since my coding game is very weak, with some help of Youtubers and code forums, I managed to make it work, but it was really lacking the “unexpected element” crucial for this assignment. I had an idea of including another pressure sensor which would reverse the order the LEDs light up in, but struggled to code it. With the incredible help of Jack (thank you again!) who patiently worked with me, I learned my lesson why the “for (LEDpin = 2; LEDpin < 10; LEDpin++)” did not work, if a condition including the second pressure sensor was included.  Instead, the whole code was rewritten, leaving out the “for” command, while increasing/decreasing the LEDpin number in the end of each condition.

And in case you’re wondering- the two pressure sensors are in the two ends of the metallic thread, to demonstrate the very very deep meaning of power dynamics of the two figures.

And here is the code:

int LEDpin = 0;
int pressurePinA = A0;
int pressurePinB = A1;

void setup() {

  for (LEDpin = 2; LEDpin < 10; LEDpin++)
    pinMode(LEDpin, OUTPUT);
  LEDpin = 2;

}

void loop() {
//telling arduino to check the pressure of both pins A and B and if A is bigger then lights go from left to right
//the bigger the pressure, the higher the speed
  if ( analogRead(pressurePinA) > analogRead(pressurePinB) ) {
    digitalWrite(LEDpin, HIGH);
    delay(map(analogRead(pressurePinA), 0, 1023, 1000, 10));
    digitalWrite(LEDpin, LOW);
//telling it to move to the next pin in next loop
    LEDpin = LEDpin + 1;
    if (LEDpin > 9) {
      LEDpin = 2;
    }

//if pressure in B is bigger, the lights go from right to left
  } else {
    digitalWrite(LEDpin, HIGH);
    delay(map(analogRead(pressurePinB), 0, 1023, 1000, 10));
    digitalWrite(LEDpin, LOW);

 //telling it to move to the previous pin in next loop
    LEDpin = LEDpin - 1;
    if (LEDpin < 2) {
      LEDpin = 9;
    }

  }


}

 

 

Leave a Reply