Piece of fabric for the handkerchief.
Pressure sensor (made with 2 pieces of conductive fabric sewn together, with a cotton piece with two holes in between).
Sewn pressure sensor onto handkerchief fabric.
Sewn wire onto conductive fabric of pressure sensor.
Other side of previous wires connected to card extracted from keyboard (using tape). Card sewn to handkerchief.
I used a text application to test the connection of the wires (the other side of the wires connected to the pressure sensor) before positioning them on the handkerchief and sewing them together. I checked that they function as keys, by moving them around and checking what appeared on the screen) in order to be able to understand where the connection is successful and can be useful. I decided to connect them in a way that they would function as keys: 0, 1, 2 and 8.
Sow usb cable to handkerchief in order for it to be connected to the computer.
I used Processing to create a sketch. The following is the code of that sketch:
Particle myParticle;
ArrayList<Particle> particles;
void setup (){
size(500,500);
particles = new ArrayList();
Particle p = new Particle();
particles.add( new Particle() );
}
void draw(){
background(192,148,206);
for (int i = 0; i < particles.size(); i++){
Particle p=particles.get(i);
p.update();
p.display();
}
}
void keyPressed(){
if (key == ‘n’);
particles.add(new Particle() );
println( particles.size() );
}
class Particle{
//variables
float x;
float y;
float velX;
float velY;
Particle(){
x = random(width);
y = random(height);
velX = random (-5,5);
velY = random(-5,5);
}
void display(){
ellipse(x,y,10,10);
fill (40,110,129);
}
void update(){
x += velX;
y += velY;
velX -= velX*.1;
velY -= velY*.1;
}
}
When pressing one of the keys (0, 1, 2 or 8) on the keyboard, moving ellipses appear. I connected the cable to the computer and used the pressure sensor to see the result: ellipses will appear in Processing. Depending on the code, many variations of this can be made to experiment.