5. E-textiles¶
Electronic basics¶
Electrical current => is the flow of electrons in a wire. Electrons flow when you have a “closed loop” – a path from the negative (ground) to the positive terminal of a battery.
Circuit¶
=> closed circuit would allow the flow of electricity between power and ground vs. open circuit would break the flow of electricity between power and ground
- voltage (V) => pressure / force between two points
- current (I) rate at which the electrical charge flows
- Resistance (R) determine how much charge flows through a circuit - Ohms amount of material that resist current flow => measured in ohms => the lower the R more current flows so the higher the R less current flows
Types of circuit¶
General rules¶
-
Electrons are lazy: electrical energy follows the path of least resistance to ground
-
Electricity hates waste: all electrical energy in the circuit must be used => otherwise it will dissipate as heat and possible damage to the circuit components
Materials¶
Fabrics threads and yarns:
=> we can use any conductive material any material that allowed the energy to pass
=> consider properties : resistance, stretchiness, solderability, feel substrate & productive process
Hand tools:
- scissors
- needles
- pins
- non conductive fabrics
- embroidery tools
Electrical tools - alligator clips - connectors - resistors - breadboard - tensiometer - 3V Battery - LED lights - electrical Tape - Aurdino UNO - Arduino IDE
INPUTs¶
=> info or data that enter a system
=> it can be digital (switches - on/off) or analog (sensors - range of values) (fotos de ambos): key differences between them is their output resolution - analog sensors provide variable resolution since they provide a continuous range of values, while digital sensors have a finite resolution determined by the number of bits used to represent the signal.
Digital
=> switches: is a break on a circuit => since the circuit is not complete, no electricity can flow through the components
- Momentary switches: stay open as long as you hold them by pressing conductive materials into contact
- Toggle switches: press, slip, slide, etc two pieces of conductive material together - its stays open in one possition and close in the other
Analog
=> Sensor: we can use resistance to get a broader range of values - by allowing more current to get through, you can change your Output activity - ex; a led brightness , a sound frequency, a motor´ speed
=> factors that change R:
- distance: R increases over d
- contact: material that are pressure sensitive will decrease in R when p is applied
- surface area: the + s.a - R
Microcrontollers & Programming¶
Arduino => open source microcontroller that can be programed to create specific/reactive outputs and collect data. => Board > Arduino UNO: control leds, read sensors, control leds based on interaction with sensors => In it connect input and output devices
=> Pin : is how INPUTS (button, sensor) and OUTPUTS (leds, motos, etc) communicate with arduino
References
⧫ let's get on with it! ⧫¶
Just remember:
- Electricity rules: electrons are lazy + hates waste + circuits are a system
- R can be manipulated in 3 ways => distance - contact - surface area create secure connections & keep your circuits clean
First aproximations
Digital switch experiments¶
materials
- sewing pins
- conductive thread
- 3V battery
- diodo leds
- agar bioplastic (surface)
- tangerine dehydrated skin
materials
- pins
- conductive wire
- 3V battery
- two diodo led
- embroidery thread
- 2 hook pins
Arduino¶
Arduino UNO and a led
My first aproach to Arduino consisted on turning on a led
I use d code from Emma Pareschi
void set up() {
// put your set up pin, to run once:
pinmode(3,OUTPUT);
}
void loop() {
//put your main code here, to run repeatedly:
digitalWrite(3,HIGH);
delay(1000);
digitalWrite(3,LOW);
delay(1000);
digitalWrite(3,HIGH);
delay(2000);
digitalWrite(3,LOW);
delay(500);
}
Analog sensor (ultrasonic)¶
At the BDC we had some sensors and I decided to try the ultrasonic to light a led. This sensor meassures distance and proximity
First step is to read de sensor
Emma Pareschi code to read analog sensor:
int analog_sensor_pin = A0; //change the pin, where the sensor is connected?
int analog_sensor_value = 0;
void setup() {
// put your setup code here, to run once:
pinMode(analog_sensor_pin, INPUT);
Serial.begin(9600);
}
void loop() {
// put your main code here, to run repeatedly:
analog_sensor_value = analogRead(analog_sensor_pin); //read the Voltage of the pin sensor
Serial.println(analog_sensor_value); // print the value on the Serial monitor
delay(100);
}
Once I had the values of the sensor (distance in cm)I looked up for a code wich I modified a little bit in order to work how I wanted ultrasonic sensor. I took the code from David Portilla
Utrasonic sensor Code
const int Trigger = 2; //Pin digital 2 para el Trigger del sensor
const int Echo = 3; //Pin digital 3 para el Echo del sensor
int led = 6; // the PWM pin the LED is attached to
int brightness = 0; // how bright the LED is
int fadeAmount = 12; // how many points to fade the LED by
void setup() {
Serial.begin(9600);//iniciailzamos la comunicación
pinMode(6, OUTPUT); //pin como salida
pinMode(Echo, INPUT); //pin como entrada
digitalWrite(Trigger, LOW);//Inicializamos el pin con 0
pinMode(Trigger, OUTPUT); // Sets the trigPin as an OUTPUT
pinMode(Echo, INPUT); // Sets the echoPin as an INPUT
digitalWrite(Trigger, LOW);
}
void loop() {
long t; //timepo que demora en llegar el eco
long d; //distancia en centimetros
digitalWrite(Trigger, HIGH);
delayMicroseconds(10); //Enviamos un pulso de 10us
digitalWrite(Trigger, LOW);
t = pulseIn(Echo, HIGH); //obtenemos el ancho del pulso
d = t/59; //escalamos el tiempo a una distancia en cm
Serial.print("Distancia: ");
Serial.print(d); //Enviamos serialmente el valor de la distancia
Serial.print("cm");
Serial.println();
if (d < 5){
analogWrite(led, brightness);
brightness = brightness + fadeAmount;
if (brightness <=0 || brightness >=255) {
fadeAmount = -fadeAmount;
}
}else{
digitalWrite(led, LOW);
}
}
𖦹 Notes & thoughs 𖦹¶
- I want to keep on experimenting with soft sensor and Arduino