Computational Craft | Salil Parekh

Week 6 | Fabricating Sensor

Fabricating copper traces on fabric is incredible and moves us from a breadboard board to proto-board or PCB level of finish. This particular trace is created with copper fabric cut by a vinyl cutter and stuck on a piece of cotton fabric. The circuit contains 2 LEDs, one regular and one SMD–the same with the resistors. Soldering these components was tricky and it takes a considerable amount of patience to solder the SMD parts on to the copper traces.

image of copper traces on fabric Copper traces on fabric with iffy soldering

Once the traces were stuck on the fabric and the components were soldered, the edges of the fabric were sewn up to for a better finish and to provide easier access to the crocodile clips.

A resistive sensor was used to control the brightness of the LEDs.

image the circuit connected to an arduino and resistive sensor The circuit connected to an Arduino Uno and a yarn sensor

The code for the sketch, taken from Liza Stark's GitHub.

/*
  Week 6 Soft Testing Board - Switch sketch

  Use this to test your vinyl cut or embroidered test board.
  To simplify, we do not have a pull down resistor
  on the switch pins, so we need to account for this in software.

  You can also use this board for a sensor but will need to adapt
  the mapping on the sketches from Week 4: https://github.com/lizastark/Teaching/tree/master/Comp_Craft/Week_4_Code

  Unlike pinMode(INPUT), there is no pull-down resistor necessary. An internal
  20K-ohm resistor is pulled to 5V. This configuration causes the input to read
  HIGH when the switch is open, and LOW when it is closed.

  created 14 Mar 2012
  by Scott Fitzgerald

  This example code is in the public domain.

  https://www.arduino.cc/en/Tutorial/BuiltInExamples/InputPullupSerial
*/

int topLED = 9;
int bottomLED = 6;
int switchPin = A0;

void setup() {
  //start serial connection
  Serial.begin(9600);
  //configure pin 2 as an input and enable the internal pull-up resistor
  pinMode(switchPin, INPUT_PULLUP);
  pinMode(topLED, OUTPUT);
  pinMode(bottomLED, OUTPUT);

}

void loop() {
  //read the sensor value into a variable
  int switchVal = analogRead(switchPin);
  //print out the value of the sensor mapped to the LED brightness
  Serial.println(map(switchVal, 670, 370, 0, 255));

  analogWrite(bottomLED, map(switchVal, 670, 370, 0, 255));
  analogWrite(topLED, map(switchVal, 670, 370, 0, 255));
}