L’idée de ce projet est d’utiliser une matière qui donne envie d’être manipulée comme traducteur de sensation en visuel.
L’échantillon de fourrure est utilisé comme un interrupteur grâce à du fil et du thermocollant conducteurs. Deux bandes de « poils » conducteurs sont dissimulés dans la fourrure.
import processing.serial.*;
import cc.arduino.*;
Arduino arduino;
int xspacing = 1;
int w = 2; // Width of entire wave
int maxwaves = 4; // total # of waves to add together
float theta = 0.0;
float[] amplitude = new float[maxwaves]; // Height of wave
float[] dx = new float[maxwaves]; // Value for incrementing X, to be calculated as a function of period and xspacing
float[] yvalues; // Using an array to store height values for the wave (not entirely necessary)
//int interrupteur = 8;
void setup() {
size(displayWidth, displayHeight);
frameRate(30);
//colorMode(RGB, 255, 255, 255, 100);
w = width + 16;
for (int i = 0; i < maxwaves; i++) {
amplitude[i] = random(10, 30);
float period = random(100, 300); // How many pixels before the wave repeats
dx[i] = (TWO_PI / period) * xspacing;
}
yvalues = new float[w/xspacing];
println(Arduino.list());
arduino = new Arduino(this, Arduino.list()[2], 57600);
arduino.pinMode(8, Arduino.INPUT);
}
void draw() {
//interrupteur = arduino.analogRead(0);
background(0);
calcWave();
renderWave();
}
void calcWave() {
if (arduino.digitalRead(8) == Arduino.HIGH) {
println("ON");
// Increment theta (try different values for 'angular velocity' here
theta += 0.1;
// Set all height values to zero
for (int i = 0; i < yvalues.length; i++) {
yvalues[i] = 0;
}
// Accumulate wave height values
for (int j = 0; j < maxwaves; j++) {
float x = theta;
for (int i = 0; i < yvalues.length; i++) {
// Every other wave is cosine instead of sine
if (j % 2 == 0) yvalues[i] += sin(x)*amplitude[j];
else yvalues[i] += cos(x)*amplitude[j];
x+=dx[j];
}
}
} else {
for (int i = 0; i < yvalues.length; i++) {
yvalues[i] = 0;
}
}
}
void renderWave() {
// A simple way to draw the wave with an ellipse at each location
noStroke();
fill(255,50);
ellipseMode(CENTER);
for (int x = 0; x < yvalues.length; x++) {
ellipse(x*xspacing,height/1.5+yvalues[x],5,5);
ellipse(x*xspacing*2,height/2+yvalues[x],5,5);
ellipse(x*xspacing*4,height/3.5+yvalues[x],5,5);
ellipse(x*xspacing*8,height/5+yvalues[x],5,5);
}
}