Ceci est une ancienne révision du document !
* Porteur(s) du projet : Jean-Alexis Bonnet (DSAA DG2), Damien MUTI DESGROUAS (Prof. de Numérique)
Dans le cadre de mon Macro-projet qui s’articule autour de …
L’objectif de mon expérimentation est de déclancher un événement visuel lorsqu'une personne traverse une porte.
A chaque passage d'une personne à travers la porte, le visuel d'un logo est modifié et vidéoprojeté sur un mur.
Pour ce projet je me suis inspirée de Jean Thoby un pépiniériste qui voue une véritable passion pour le monde végétale. Jean Thoby avec l’aide d’ingénieurs, ont créer un instrument de musique. Par un système de boitier et de câbles (l’un fixé au sol et l’autre accroché à la plante) ils ont réussit à mesurer la résistance électrique afin de réaliser une traduction sonore de l’activité interne du vivant. Cette création renvoie l’illusion d’une forme de vie par un ornement sonore étrange. Cette partition végétale teintée de variations, de notes secondaires et de rythmes déstructurés retranscrit de manière métaphorique l’état de santé des plantes.
Le câblage sur le logiciel de simulation Arduino n'est pas exactement le même que celui sur les photos mais le principe est similaire.
Une fois les câbles bien branchés sur la TouchBoard, insérer les trois autres fils dans les plantes. Vérifiez bien que la terre est assez humides pour pourvoir être conductrice.
1 ⇒ plante_sonore_Arduino_3.ino
//Import a library from the Arduino folder #include <CapacitiveSensor.h> //Select the two pins that will act as a capacitor CapacitiveSensor cs_2[] = {CapacitiveSensor(2, 4),// 10M resistor between pins 2 & 4, pin 2 is sensor pin, add a wire and or foil if desired CapacitiveSensor(2, 6),// 10M resistor between pins 2 & 6, pin 6 is sensor pin, add a wire and or foi CapacitiveSensor(2, 11)// 10M resistor between pins 2 & 11, pin 8 is sensor pin, add a wire and or foil //CapacitiveSensor(2, 13)// 10M resistor between pins 2 & 11, pin 8 is sensor pin, add a wire and or foil }; long capSensorVal[] = {0, 0, 0}; byte Ncapteurs = 3; //Insert the minimum value provided by the sensor to detect the touch int seuilDetection = 500; // seuil de détection sur la valeur donné par le capteur capacitif const int ledPin = 13; int plante[] = {0, 0, 0}; // port série int inByte = 0; ///////////////////// debug ////////////// boolean debug1 = false, debug2 = false; ////////////////////////////////////////////SETUP //////////////////////////// void setup() { // start serial port at 9600 bps: Serial.begin(9600); while (!Serial) { ; // wait for serial port to connect. Needed for native USB port only } pinMode(ledPin, OUTPUT); // init des capteurs capacitifs cs_2[0].set_CS_AutocaL_Millis(0xFFFFFFFF); // turn off autocalibrate on channel 1 - just as an example establishContact(); // send a byte to establish contact until receiver responds } void loop() { // if we get a valid byte, read analog ins: if (Serial.available() > 0) { // get incoming byte: inByte = Serial.read(); long start = millis(); for (int i = 0; i < Ncapteurs; i++) { capSensorVal[i] = cs_2[i].capacitiveSensor(30); } if (debug1) { Serial.print(millis() - start); // check on performance in milliseconds Serial.print("\t"); // tab character for debug windown spacing for (int i = 0; i < Ncapteurs; i++) { Serial.print(capSensorVal[i]); // print sensor output 1 Serial.print("\t"); } Serial.println(""); // print sensor output 3 } // test des valeurs des capteurs for (int i = 0; i < Ncapteurs; i++) { plante[i] = testCapteur(capSensorVal[i], seuilDetection); } if (debug2) { for (int i = 0; i < Ncapteurs; i++) { Serial.print(plante[i]); // print sensor output 1 Serial.print("\t"); } Serial.println(""); // print sensor output 3 } else { // send sensor values: on envoie à Processing l'état de la plante - 0 : inactive; 255 : active for (int i = 0; i < Ncapteurs; i++) { Serial.write(plante[i]); } } } } void establishContact() { while (Serial.available() <= 0) { Serial.print('A'); // send a capital A delay(300); } } int testCapteur(long sensorVal, long seuilDetection) { // sensorVal : valeur du capteur // seuilDetection : seuil de détection if (sensorVal > seuilDetection ) { //Turn on the led digitalWrite(ledPin, HIGH); // plante i activée return 255; } //Touch undetected else { //Turn off the led digitalWrite(ledPin, LOW); // plante i inactivée return 0; } }
2 ⇒ Gestion_Interactivite
/** Plantes sonores - * Quand on touche la plante, cela lance une image, une vidéo, une annim, un son, etc... */ */ /// librairies import processing.sound.*; import processing.video.*; import processing.serial.*; // variables globales PImage im; // une image SoundFile[] son; // un son - un seul lecteur CD audio Movie vid; // une vidéo - un seul lecteur DVD vidéo // bouton image active ? // est-ce que l'image est active ? Si oui, on affiche l'image boolean animation_active = false; // true ou false (2 valleurs possibles) => 1 bit (0 ou 1) // bouton son actif ? boolean son_actif = false; float tempsDebutSon = 0; // temps du début de la musique a été joué // bouton videos active ? boolean video_active[]; /// dialogue avec la carte Arduino Serial myPort; // Create object from Serial class int inBuffer; // Data received from the serial port int donneePortSerie; // entier converti de la chaine de caractère reçue sur le port série // seuil de détection float seuil = 300; // port serie int nPlantes = 3; int[] serialInArray = new int[nPlantes]; // Where we'll put what we receive int serialCount = 0; // A count of how many bytes we receive int[] plante = {0, 0, 0}; // Starting position of the ball boolean firstContact = false; // Whether we've heard from the microcontroller // média associés aux plantes String[] nomSonPlante; String[] nomvideosPlante; void setup() { // initialisation des paramètres d'affichage & chargement des sons, vidéos, etc. size(500, 500); noStroke(); background(0); // initialisation des variables globales im = loadImage("images/chien.jpg"); // son des plantes nomSonPlante = new String[nPlantes]; nomSonPlante[0]= "sons/Chevre_2.mp3"; nomSonPlante[1]= "sons/Armstrong.wav"; nomSonPlante[2]= "sons/beat.aiff"; // chargement des sons son =new SoundFile[nPlantes]; for (int i=0; i<nPlantes; i++) { son[i] = new SoundFile(this, nomSonPlante[i]); } // videos des plantes nomvideosPlante = new String[nPlantes]; nomvideosPlante[0]= "videos/affiche.mp4"; nomvideosPlante[1]= "videos/ArmstrongAlunissage.mp4"; nomvideosPlante[2]= "videos/transit.mov"; video_active = new boolean[nPlantes]; for (int i=0; i<nPlantes; i++) { video_active[i]=false; } //println(son.duration()); // chargement de la videos vid = new Movie(this, "videos/affiche.mp4"); /// Port série // Print a list of the serial ports, for debugging purposes: printArray(Serial.list()); String portName = Serial.list()[2]; myPort = new Serial(this, portName, 9600); } void draw() { // print the values (for debugging purposes only): println("plante[0]= " +plante[0] + "\t" + "plante[1]= " +plante[1] + "\t" + "plante[2]= " +plante[2] + "\t" + "son[0].isPlaying()=" + son[0].isPlaying() + "\t" + "video[0]= " + video_active[0] + "\t" + "video[1]= " + video_active[1] + "\t" + "video[2]= " + video_active[2] ); ///////////////////////// interactivités liées aux plantes for (int i=0; i<nPlantes; i++) { // pour chacune des plantes gestionSonPlante(i); gestionVideoPlante(i, nomvideosPlante[i]); } //// affichage de la vidéo si la vidéo i est active //////////////////////////////////////// boolean une_video_active=false; for(int i=0;i<nPlantes;i++){ une_video_active = (une_video_active || video_active[i]); } if (une_video_active) { image(vid, 0, 0, width, height); } else { background(0); // fond noir } // affichage de l'animation////////////////////////////////////// //if (animation_active) { // lancerAnimation(); //} }
3 ⇒ plante_sonore_Processing_3
///////////////////////////////// Plante ///////////////////////////////////////////////////// void gestionSonPlante(int i){ if (plante[i]==255 && !son[i].isPlaying()) { // si la plante i est active // lancer le son associé à la plante i en boucle son[i].loop(); } else if (plante[i]== 0 && son[i].isPlaying()){ son[i].stop(); } // animation de la plante i } //////////////////////////////////////////////// Video /////////////////////////////////////////////////// void gestionVideoPlante(int i, String nomVideo) { if (plante[i]==255 && !video_active[i]) { // video // jouer le son SSI la distance est inférieur à un seuil, strictement supérieure à 0 et si la vidéo ne joue pas déjà // lancement du son lancerVideo(i, nomVideo); } else if (plante[i]==0 && video_active[i]) { //si la distance est supérieure au seuil ET que la video joue : arrêter la video vid.stop(); clear(); video_active[i] = false; } } void lancerVideo(int i, String nomVideo) { if (video_active[i] == false) { // la vidéo 1 ne tourne pas // chargement de la video 1 vid = new Movie(this, nomVideo ); vid.loop(); video_active[i] = true; } } //////////////////////////////////////////////// animation /////////////////////////////////////////////////// void gestionAnimation() { if (donneePortSerie > 100) { // on appuie sur la touche "espace" => lancer l'animation "image" animation_active = true; } else { animation_active = false; } } void lancerAnimation() { float x = 30 + random(-20, 20); // random sur la position float y = 30 + random(-20, 20); image(im, x, y, 200, 200); } ////////////////////////////////////// Méthodes /////////////////////////////// void movieEvent(Movie movie) { //// gestion de la vidéo vid.read(); }
4 ⇒ SerialEvent
void serialEvent(Serial myPort) { // read a byte from the serial port: int inByte = myPort.read(); // if this is the first byte received, and it's an A, // clear the serial buffer and note that you've // had first contact from the microcontroller. // Otherwise, add the incoming byte to the array: if (firstContact == false) { if (inByte == 'A') { myPort.clear(); // clear the serial port buffer firstContact = true; // you've had first contact from the microcontroller myPort.write('A'); // ask for more } } else { // Add the latest byte from the serial port to array: serialInArray[serialCount] = inByte; serialCount++; // If we have 3 bytes: if (serialCount > 2 ) { plante[0] = serialInArray[0]; plante[1] = serialInArray[1]; plante[2] = serialInArray[2]; // print the values (for debugging purposes only): //println("plante[0]= " +plante[0] + "\t" + "plante[1]= " +plante[1] + "\t" + "plante[2]= " +plante[2] ); // Send a capital A to request new sensor readings: myPort.write('A'); // Reset serialCount: serialCount = 0; } } }