5. E-Textiles and Wearables I#

In this weeks assignment i worked with the materials and components i found in the lab, the one thing that was shipped on time was conductive fabric - Conductive fabrics
- LEDs - Arduino
- Servos - Photoresistors
- Ultrasonic sensors

First i wanted to try out Series and parallel circuits on felt, so i used single core wire as a thread since i dont have conductive thread and put two LEDs. With parellel circuit the intensity of both LEDs was similar as shown below. I needed to apply pressure on the battery to close the cercuit probably because the conductive fabric pocket wasnt tight.

But with the series circuit the intensity of one of the lights was higher than the other. And for this circuit i added an LDR (Photoresistor) which is a component that has a (variable) resistance that changes with the light intensity that falls upon it. Basically its resistance decreases when its exposed to light, and vice versa.

But! I wanted the LEDs to light up when the LDR doesnt detect light ( in the dark) and turn off when there is light. For that i looked up a circuit that allows me to do that.

For this cisuit i used - 22 kΩ resistor - to LED - 27 Ω resistor - to LDR - BC547 Transistor - LDR

And it worked! you can see the internsity of the light decrease when i move my finger away from the LDR

And here is an attempt with laser-cut conductavice fabric on felt. The result was not very secceful, in the beggining the LED would not light up with 3V baterry so i used a smaller LED but it was barely lighting up. So i did some research and figured that it could be because the width or the length of the con. fabric piece that affects the delivery of the current to the LED. ‘’Resistance is a force found in currents that opposes the flow of electrons around a circuit. When this occurs energy is needed to push the charged particles around the circuit. The circuit itself can resist the flow of particles if the wires are either very thin or very long.’‘

So for this one i used two 3V batteries for a small LED.

For the next part, i used an arduino and an ultrasonic sensor. Ultrasonic sensors measure distance by using ultrasonic waves. The sensor head emits an ultrasonic wave and receives the wave reflected back from the target. Ultrasonic Sensors measure the distance to the target by measuring the time between the emission and reception.

The sensor connects to the arduino as follows: - Vcc pin –> 5V pin - Trig pin –> pin 9 - Echo pin –> pin 8 - Gnd pin –> Gnd pin

As for the servo, i used a small one and connected to the following pins on the arduino

I did not really know how to create a code that allows to move the the servo using the sensor so i downloaded one and changed the trigger distance for the sensor and the movement degree for the servo.

So if distance < 10 cm ; servo moves 90 degrees.

At this step i got really excited and wanted to add more servos and sensors and i was able to connect two servos to one sensor but was facing some difficulties connecting two sensors ( one servo for each sensor) *** more photos to be uploaded for final project

Code#

This the code i used to control two servos.

#include <Servo.h>
#define trigPin 9
#define trigPin2 3
#define echoPin 8
#define echoPin2 2
Servo servo1;
Servo servo2;
long duration, distance,duration2, distance2;

void s1(){
digitalWrite(trigPin, LOW);
delayMicroseconds(2);
digitalWrite(trigPin, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin, LOW);
duration = pulseIn(echoPin, HIGH);
distance = (duration/2) / 29.1;
Serial.print(distance);Serial.print("  ");
if (distance < 15){
servo1.write(45);}
else
{
servo1.write(0);}
}

void s2(){
digitalWrite(trigPin2, LOW);
delayMicroseconds(2);
digitalWrite(trigPin2, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin2, LOW);
duration2 = pulseIn(echoPin2, HIGH);
distance2 = (duration2/2) / 29.1;
Serial.print(distance2);Serial.print("  ");
if (distance2 < 15){
servo2.write(45);}
else
{
servo2.write(0);}
}

void setup()
{
Serial.begin (9600);
pinMode(trigPin, OUTPUT);
pinMode(echoPin, INPUT);
pinMode(trigPin2, OUTPUT);
pinMode(echoPin2, INPUT);
servo1.attach(10);
servo2.attach(5);
}

void loop()
{
s1();
s2();
Serial.println();
//delay (50);
}