CODE ARDUINO :
const int vent1 = 3;
const int vent2 = 5;
const int vent3 = 6;
const int vent4 = 10;
const int button1 = A2;
const int button2 = A3;
const int button3 = A4;
const int button4 = A5;
int button1Valeur;
int button2Valeur;
int button3Valeur;
int button4Valeur;
int button1ValeurMap;
int button2ValeurMap;
int button3ValeurMap;
int button4ValeurMap;
void setup() {
pinMode(vent1, OUTPUT);
pinMode(vent2, OUTPUT);
pinMode(vent3, OUTPUT);
pinMode(vent4, OUTPUT);
pinMode(button1, INPUT);
pinMode(button2, INPUT);
pinMode(button3, INPUT);
pinMode(button4, INPUT);
Serial.begin(9600);
}
void loop() {
button1Valeur = analogRead(button1);
button2Valeur = analogRead(button2);
button3Valeur = analogRead(button3);
button4Valeur = analogRead(button4);
button1ValeurMap = map(button1Valeur, 0, 1024, 0, 255);
button2ValeurMap = map(button2Valeur, 0, 1024, 0, 255);
button3ValeurMap = map(button3Valeur, 0, 1024, 0, 255);
button4ValeurMap = map(button4Valeur, 0, 1024, 0, 255);
Serial.print(« button1Valeur = »);
Serial.print(button1Valeur);
Serial.print(« \t »);
Serial.print(« button2Valeur = »);
Serial.print(button2Valeur);
Serial.print(« \t »);
Serial.print(« button3Valeur = »);
Serial.print(button3Valeur);
Serial.print(« \t »);
Serial.print(« button4Valeur = »);
Serial.println(button4Valeur);
analogWrite(vent1, button1ValeurMap);
analogWrite(vent2, button2ValeurMap);
analogWrite(vent3, button3ValeurMap);
analogWrite(vent4, button4ValeurMap);
delay(10);
}
CODE PROCESSING :
import processing.serial.*;
import cc.arduino.*;
import fullscreen.*;
FullScreen fs;
float previousDeplacementX;
float previousDeplacementY;
int rec;
int erase;
float deplacementY;
float deplacementX;
int i = 1;
int N;
int S;
int E;
int O;
Arduino arduino;
void setup() {
size(800, 600);
smooth();
println(Serial.list());
arduino = new Arduino(this, Arduino.list()[0], 57600);
arduino.pinMode(3, Arduino.INPUT);
arduino.pinMode(7, Arduino.INPUT);
background(0);
frameRate(30);
fs = new FullScreen(this);
}
void draw() {
N = (arduino.analogRead(A2));
S = (arduino.analogRead(A3));
E = (arduino.digitalRead(A4));
O = (arduino.digitalRead(A5));
deplacementX=O;
deplacement-X=E;
deplacementY=S;
deplacement-Y=N;
deplacementX=map(deplacementX, 0, 1023, 100, 700);
deplacementY=map(deplacementY, 0, 1023, 100, 500);
rec=c;
erase=d;
stroke(random(0, 255), random(0, 255),random(0, 255));
strokeWeight(4);
line(previousDeplacementX, previousDeplacementY, deplacementX,deplacementY);
if (rec == Arduino.HIGH) {
save(i+ »vent.jpg »);
i++;
println(« SAVE »);
delay(100);
}
if (erase == Arduino.LOW) {
background(0);
println(« ERASE »);
}
if (keyPressed) {
if (key == ‘f’ || key == ‘F’){
fs.enter();
}
}
if (keyPressed) {
if (key == ‘l’ || key == ‘L’){
fs.leave();
}
}
previousDeplacementX=deplacementX;
previousDeplacementY=deplacementY;
print(« deplacementX = « );
print(deplacementX);
print(« \t »);
print(« deplacementY = « );
println(deplacementY);
}