Junru Xu
Build a sensor swatch using conductive materials listed below. Program and test the sensor with LED. Then replicate a second sensor and test both the swatches.

Since these are a pair of swatches, I want to make the two resonate with each other. As shown in the sketch below, I want to create two soft buttons, one flower and one leaf. For the flower swatch, I will use Copper Taffeta Fabric; and stretchy conductive fabric for the leaf swatch. The conductive pieces will be stuffed inside non-conductive fabric covers, stitched with flower/leaf patterns. And when touched, the two conductive sides will touch each other for electricity flow.

The sketch for flower/leaf design

Making process of flower swatch

Making process of leaf swatch
For the closing stitch, I also referenced the blanket stitch tutorial from Red Ted Art on YouTube
For the closing stitch, I also referenced the blanket stitch tutorial from Red Ted Art on YouTube

The LED program sketch from Wk4

Testing with LED
int sensorPin = A0;
int sensorValue = 0;
int LEDpin = 9;
int newSensorValue;
const int numReadings = 20;
int readings[numReadings];      // the readings from the analog input
int readIndex = 0;              // the index of the current reading
int total = 0;                  // the running total
int average = 0;                // the average
int inputPin = A0;
void setup() {
  // configure pins
  pinMode(sensorPin, INPUT);
  pinMode(LEDpin, INPUT);
  // initialize serial communication with computer:
  Serial.begin(9600);
  // initialize all the readings to 0:
  for (int thisReading = 0; thisReading < numReadings; thisReading++) {
    readings[thisReading] = 0;
  }
}
void loop() {
  // read raw data to compare
  sensorValue = analogRead(sensorPin);
  Serial.print("Raw = ");
  Serial.print(sensorValue);
  Serial.print("\\t\\t");
  // start smoothing
  // subtract the last reading:
  total = total - readings[readIndex];
  // read from the sensor:
  readings[readIndex] = analogRead(sensorPin);
  // add the reading to the total:
  total = total + readings[readIndex];
  // advance to the next position in the array:
  readIndex = readIndex + 1;
  // if we're at the end of the array...
  if (readIndex >= numReadings) {
    // ...wrap around to the beginning:
    readIndex = 0;
  }
  // calculate the average:
  average = total / numReadings;
  // send it to the computer as ASCII digits
  Serial.print("Average = ");
  Serial.print(average);
  Serial.print("\\t\\t");
  //map the range from your average values to the range of
  //an LED output
  newSensorValue = map(average, 180, 400, 0, 255);
  //constrain the input range to LED output values
  newSensorValue = constrain(newSensorValue, 0, 255);
  Serial.print("New = ");
  Serial.println(newSensorValue);
  analogWrite(LEDpin, newSensorValue);
  delay(1);
}
Program: