9. E-Textiles and Wearables II#
The assignmetn for this week are:
(1) Create a swatch using an ATtiny with one input and one output of your choice
(2) Create 2 actuator swatches. Test them with the Arduino or ATtiny.
The day after the fablab we examined the available material and considered the different possibilities that Liza showed us.
During the lesson I was attracted by the soft speacker that you can create with a magnet, a fabric and creating a COIL TIGHTNESS by a dense track with conductive material.
When you connect an audio signal to either end of your electromagnet (the coil), it forms a magnetic field. The magnetic field fluctuates based on the electrical frequencies of the audio signal. If you place a strong permanent magnet near the electromagnet (i.e. coil), the electromagnet’s field will attract and repel to the magnet’s field The membrane will vibrate as the fields attract and repel, causing the air around it to move. This creates the waves that our brain interprets as sound!
COIL TIGHTNESS The tighter the coil, the louder. (It will be since it will have a stronger magnetic field.) MATERIAL You can hear noise because the sound waves vibrate off the material. How stiff or thick the material is effects the loudness. MAGNET SIZE The larger the magnet, the louder the volume. You can combine many small magnets or just get a big one BUT be careful - neodymium magnets are very strong. MAGNET PLACEMENT The volume will be louder the closer the magnet is to the center of the coil.
Useful links#
How to build the basic board and weld the pieces and how to add the AtTiny to the Arduino boards
Connecting Headphone Wires to the amplifier
Useful video#
How to build the basic board and weld the pieces for AtTiny
Let’s start:#
Speaker#
I want to specify that I have recovered cables from broken headsets with which I have encountered some problems.
First of all I mistakenly thought that they were all the same and once the cables of the one I chose were stripped, with particular difficulty, since they are very small and the cables to the intro are very fragile, I found myself with five wires instead of three. This is because those earphones had the ability to manage volume and not just direct from the cable.
Once the normal headphones cables were open, I found that there were four wires available and not three. This is because having two cables, one for each headset, each contained a positive and a negative wire.
I have connected the ground cables and the colored cables together.
I grounded the ground to a black cable while others I welded them to a red cable.
Once all soldered to the amplifier I connected the end to the coil he had created.
The first I created with the copper tape on eco-leather close I created a flower with a wire mesh but can not replace the function of the coil. With the eco-leather it is probably not possible to create the vibrations necessary to create the sound. It didn’t work.
I replaced the eco-leather with a simple sheet of paper and lasered a copper fabric with a spiral shape and glued it to the paper. In this case it works but the volume was very low.
I then created another coil on a very thin fabric, the tulle and I hand drawn with a conductive thread the coil. Does not work.
In my opinion there is to consider the resistance inside the wire and also the thickness of the fabric but I bypassed by adding a piece of paper between the fabric and the magnet.
To use AtTiny, I decided to connect the speker with the circuit shown during liza’s lesson.
First I followed the instructions from the link above to use Mauro Alfieri’s borad.
Despite having checked with Giorgia that every passage was done correctly and that brings, processor and card were recognized for AtTiny85, I encountered problems and I could not load the sketch.
According to Gianni’s suggestion I downloaded the CH340 drive but even in this way I was not able to load the sketch.
Giorgia with the Mac could upload it with both the board of mauro alfieri and the red board of sparkfun.
Sound Code:#
/*
Melody
Plays a melody
circuit:
- 8 ohm speaker on digital pin 8 ->1 AtTiny
created 21 Jan 2010
modified 30 Aug 2011
by Tom Igoe
This example code is in the public domain.
http://www.arduino.cc/en/Tutorial/Tone
*/
#include "pitches.h"
// notes in the melody:
int melody[] = {
NOTE_C4, NOTE_G3, NOTE_G3, NOTE_A3, NOTE_G3, 0, NOTE_B3, NOTE_C4
};
// note durations: 4 = quarter note, 8 = eighth note, etc.:
int noteDurations[] = {
4, 8, 8, 4, 4, 4, 4, 4
};
void setup() {
// iterate over the notes of the melody:
/*
for (int thisNote = 0; thisNote < 8; thisNote++) {
// to calculate the note duration, take one second divided by the note type.
//e.g. quarter note = 1000 / 4, eighth note = 1000/8, etc.
int noteDuration = 1000 / noteDurations[thisNote];
tone(1, melody[thisNote], noteDuration);
// to distinguish the notes, set a minimum time between them.
// the note's duration + 30% seems to work well:
int pauseBetweenNotes = noteDuration * 1.30;
delay(pauseBetweenNotes);
// stop the tone playing:
noTone(1);*/
}
}
void loop() {
// no need to repeat the melody.
// iterate over the notes of the melody:
for (int thisNote = 0; thisNote < 8; thisNote++) {
// to calculate the note duration, take one second divided by the note type.
//e.g. quarter note = 1000 / 4, eighth note = 1000/8, etc.
int noteDuration = 1000 / noteDurations[thisNote];
tone(1, melody[thisNote], noteDuration);
// to distinguish the notes, set a minimum time between them.
// the note's duration + 30% seems to work well:
int pauseBetweenNotes = noteDuration * 1.30;
delay(pauseBetweenNotes);
// stop the tone playing:
noTone(1);
}
}
I used it with arduino non AtTinybecause it doesn’t work.
Thermochromic pigment#
As a second actuator I decided to test the thermochromic pigment.
I colored a red linen fabric with a blue color ready for use, which reacts at a temperature of about 37 degrees, and a black color to be mixed that reacts at a much lower temperature, around 25 degrees.
In theory with only the heat of the hand the pigment should clear.
Also in this case I wanted to use an AtTiny to create a sketch and a circuit to connect the fabric with the color to a serpentine.
Thermochromic Code:#
//Thermochromic circuit
// AtTiny carica con programmatore
void setup() {
// put your setup code here, to run once:
pinMode(1, OUTPUT);
// Serial.begin(9600);
}
void loop() {
// put your main code here, to run repeatedly:
analogWrite(1, 150);
// 150 valore della corrente che passa nella serpentina
// Serial.println("ON"); AtTiny non stampa
delay(2000);
analogWrite(1, 150);
// 150 valore della corrente che passa nella serpentina
//Serial.println("OFF"); AtTiny nn stampa
delay(5000);
}
The circuit taken into consideration by the Liza Stark project according to Gianni was not correct. Here the two models:
For both circuits I used a mosfet.
Wearable 1#
I also took over the wearable sensor 1 that did not work.
The reasons were many.
First I added a piece of conductive fabric to the base of the resistive fabric to oppose less resistance.
Secondly, I checked the various contacts that with the wire created false contacts between the various pins and components. I preferred to weld as much as possible and add some scoch of paper to isolate the components well with the felt on which I had sewed.
I have thus been able to better calibrate the values of the potentiometer sensor and act on the LEDs, however, except one was mounted on the contrary.
Not always the shorter leg corrisonde to the ground !!!!!!
Here the Sketch with the right range:
const int analogInPin = A3; // Analog input pin that the potentiometer is attached to
const int analogLEDpin3 = 9; // Analog output pin that the LED3 (the last one) is attached to
const int analogLEDpin2 = 3; // Analog output pin that the LED2 (the middle one) is attached to
const int analogLEDpin1 = 2; // Analog output pin that the LED1 (the first one) is attached to
const int analogLEDpin = 11; // Analog output pin that the BIG LED (the only one on the left) is attached to
int sensorValue = 0; // value read from the pot
//int outputValue3 = 0; // value output to the PWM (LED3)
//int outputValue2 = 0; // LED2
//int outputValue1 = 0; // LED1
void setup() {
// initialize serial communications at 9600 bps:
Serial.begin(9600);
// Giorgia per digitale, il mapping, l?analogread e
//l'analogwrite sono corretti ma non vanno bene per il digitale high low
pinMode(analogLEDpin1, OUTPUT);
pinMode(analogLEDpin2, OUTPUT);
pinMode(analogLEDpin3, OUTPUT);
pinMode(analogLEDpin, OUTPUT);
}
void loop() {
// read the analog in value:
sensorValue = analogRead(analogInPin);
/*
| map it to the range of the analog out:
| outputValue3 = map(sensorValue, 0, 1023, 0, 255);
| outputValue2 = map(sensorValue, 0, 1023, 0, 255);
| outputValue1 = map(sensorValue, 0, 1023, 0, 255);
change the analog out value: con questo non c'e il controllo dll'if
| analogWrite(analogLEDpin3, outputValue3);
| analogWrite(analogLEDpin2, outputValue2);
| analogWrite(analogLEDpin1, outputValue1);*/
// print the results to the Serial Monitor:
Serial.print(" sensor ");
Serial.println(sensorValue);
/*
| // Serial.print(" LED3 ");
| // Serial.println(outputValue3);
| // Serial.print(" LED2 ");
| // Serial.println(outputValue2);
| // Serial.print(" LED1 ");
| // Serial.println(outputValue1);
| // delay(500);*/
if (sensorValue <16) {
// turn LED1 on:
digitalWrite(analogLEDpin1, HIGH);
} else {
// turn LED off:
digitalWrite(analogLEDpin1, LOW);
}
if (sensorValue >=16 && sensorValue<=600) {
// turn LED1 on:
digitalWrite(analogLEDpin2, HIGH);
} else {
// turn LED off:
digitalWrite(analogLEDpin2, LOW);
}
if (sensorValue >601 && sensorValue<=900) {
// turn LED1 on:
digitalWrite(analogLEDpin3, HIGH);
} else {
// turn LED off:
digitalWrite(analogLEDpin3, LOW);
}
if (sensorValue >901) {
// turn BIG LED on the left on:
digitalWrite(analogLEDpin, HIGH);
} else {
// turn BIG LED on the left off:
digitalWrite(analogLEDpin, LOW);
}
delay(500);
} const int analogInPin = A3; // Analog input pin that the potentiometer is attached to
const int analogLEDpin3 = 9; // Analog output pin that the LED3 (the last one) is attached to
const int analogLEDpin2 = 3; // Analog output pin that the LED2 (the middle one) is attached to
const int analogLEDpin1 = 2; // Analog output pin that the LED1 (the first one) is attached to
const int analogLEDpin = 11; // Analog output pin that the BIG LED (the only one on the left) is attached to
int sensorValue = 0; // value read from the pot
int outputValue3 = 0; // value output to the PWM (LED3)
int outputValue2 = 0; // LED2
int outputValue1 = 0; // LED1
void setup() {
// initialize serial communications at 9600 bps:
Serial.begin(9600);