Ci-dessous, les différences entre deux révisions de la page.
Les deux révisions précédentes Révision précédente Prochaine révision | Révision précédente | ||
wiki:flossmanuals:capacitif_pante_son_video:accueil [2021/06/24 00:51] justine |
wiki:flossmanuals:capacitif_pante_son_video:accueil [2021/07/14 23:21] justine |
||
---|---|---|---|
Ligne 1: | Ligne 1: | ||
- | ====== Plantes Sonores ====== | + | ====== Plantes Sonores |
- | ====== | + | ====== |
- | ====== Planta-Phonique ====== | + | ===== Des plantes interfaces |
{{: | {{: | ||
{{: | {{: | ||
Ligne 17: | Ligne 18: | ||
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, | 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, | ||
- | ===== Protocole pour 3 plantes: ===== | + | ===== Protocole pour 8 plantes: ===== |
{{: | {{: | ||
===== Installation: | ===== Installation: | ||
- | {{: | + | {{: |
- | 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 | + | Une fois les câbles bien branchés sur la BreadBoard, insérer les trois autres fils dans les plantes. Vérifiez bien que la terre est assez humide |
- | {{: | + | {{: |
- | ===== Incrémentation: | + | {{ : |
- | {{: | + | |
- | ===== Code: ===== | + | ===== À Télécharger |
- | **1** => __plante_sonore_Arduino_3.ino__ | + | {{ : |
- | < | + | |
- | //Import a library from the Arduino folder | + | |
- | #include < | + | |
- | //Select the two pins that will act as a capacitor | + | |
- | CapacitiveSensor | + | |
- | | + | |
- | | + | |
- | // | + | |
- | | + | |
- | long capSensorVal[] = {0, 0, 0}; | + | |
- | byte Ncapteurs = 3; | + | **Télécharger les librairies :** |
+ | * Vidéo | ||
+ | * Sound | ||
+ | * Serial | ||
- | //Insert the minimum value provided by the sensor to detect the touch | + | **Problèmes récurrents :** |
- | int seuilDetection = 500; // seuil de détection sur la valeur donné par le capteur capacitif | + | * Vérifier si c'est bien le bon port série. |
- | const int ledPin | + | * Si vous utilisez un mac laissez charger le programme pendant plusieurs minutes. |
+ | * Attention aux vidéos et musiques trop lourdes. | ||
+ | * Et si le programme ne marche toujours pas, vérifiez l' | ||
+ | ===== Code: ===== | ||
+ | **1** => **Processing :** __test_7plantes_sonores > Gestion_interactivite.pde__ | ||
- | int plante[] = {0, 0, 0}; | ||
- | |||
- | // port série | ||
- | int inByte = 0; | ||
- | |||
- | ///////////////////// | ||
- | boolean debug1 = false, debug2 = false; | ||
- | //////////////////////////////////////////// | ||
- | 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, | ||
- | // init des capteurs capacitifs | ||
- | cs_2[0].set_CS_AutocaL_Millis(0xFFFFFFFF); | ||
- | |||
- | establishContact(); | ||
- | } | ||
- | |||
- | 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); | ||
- | Serial.print(" | ||
- | |||
- | for (int i = 0; i < Ncapteurs; i++) { | ||
- | Serial.print(capSensorVal[i]); | ||
- | Serial.print(" | ||
- | } | ||
- | Serial.println("" | ||
- | } | ||
- | |||
- | |||
- | |||
- | // test des valeurs des capteurs | ||
- | for (int i = 0; i < Ncapteurs; i++) { | ||
- | plante[i] = testCapteur(capSensorVal[i], | ||
- | } | ||
- | if (debug2) { | ||
- | for (int i = 0; i < Ncapteurs; i++) { | ||
- | Serial.print(plante[i]); | ||
- | Serial.print(" | ||
- | } | ||
- | Serial.println("" | ||
- | } | ||
- | else { | ||
- | // send sensor values: on envoie à Processing l' | ||
- | for (int i = 0; i < Ncapteurs; i++) { | ||
- | Serial.write(plante[i]); | ||
- | } | ||
- | } | ||
- | } | ||
- | } | ||
- | |||
- | void establishContact() { | ||
- | while (Serial.available() <= 0) { | ||
- | Serial.print(' | ||
- | 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, | ||
- | // plante i activée | ||
- | return 255; | ||
- | } | ||
- | //Touch undetected | ||
- | else { | ||
- | //Turn off the led | ||
- | digitalWrite(ledPin, | ||
- | // plante i inactivée | ||
- | return 0; | ||
- | } | ||
- | |||
- | } | ||
- | </ | ||
- | |||
- | **2** => __Gestion_Interactivite__ | ||
< | < | ||
- | /** Plantes sonores | + | /** Plante sonore |
- | | + | |
- | */ | + | |
- | */ | + | |
/// librairies | /// librairies | ||
import processing.sound.*; | import processing.sound.*; | ||
import processing.video.*; | import processing.video.*; | ||
import processing.serial.*; | import processing.serial.*; | ||
+ | |||
Ligne 177: | Ligne 78: | ||
// port serie | // port serie | ||
- | int nPlantes = 3; | + | int nPlantes = 8;///////////////////// |
int[] serialInArray = new int[nPlantes]; | int[] serialInArray = new int[nPlantes]; | ||
int serialCount = 0; // A count of how many bytes we receive | int serialCount = 0; // A count of how many bytes we receive | ||
- | int[] plante | + | int[] plante; |
boolean firstContact = false; | boolean firstContact = false; | ||
Ligne 189: | Ligne 90: | ||
void setup() { // initialisation des paramètres d' | void setup() { // initialisation des paramètres d' | ||
- | size(500, 500); | + | size(1300, 860); |
noStroke(); | noStroke(); | ||
background(0); | background(0); | ||
- | // initialisation des variables | + | // initialisation des variables |
im = loadImage(" | im = loadImage(" | ||
+ | // création et initialisation de tableau de valeur " | ||
+ | plante = new int[nPlantes]; | ||
+ | for (int i=0; i< | ||
+ | plante[i] = 0; | ||
+ | } | ||
// son des plantes | // son des plantes | ||
nomSonPlante = new String[nPlantes]; | nomSonPlante = new String[nPlantes]; | ||
- | nomSonPlante[0]= "sons/Chevre_2.mp3"; | + | |
- | nomSonPlante[1]= "sons/Armstrong.wav"; | + | // |
- | nomSonPlante[2]= "sons/beat.aiff"; | + | //} |
+ | nomSonPlante[0]= " | ||
+ | nomSonPlante[1]= "sons/inst3.mp3"; | ||
+ | nomSonPlante[2]= "sons/silence.mp3"; | ||
+ | nomSonPlante[3]= " | ||
+ | nomSonPlante[4]= " | ||
+ | nomSonPlante[5]= " | ||
+ | nomSonPlante[6]= " | ||
+ | nomSonPlante[7]= " | ||
// chargement des sons | // chargement des sons | ||
Ligne 211: | Ligne 125: | ||
// videos des plantes | // videos des plantes | ||
nomvideosPlante = new String[nPlantes]; | nomvideosPlante = new String[nPlantes]; | ||
- | nomvideosPlante[0]= " | + | nomvideosPlante[0]= " |
- | nomvideosPlante[1]= " | + | nomvideosPlante[1]= " |
- | nomvideosPlante[2]= " | + | nomvideosPlante[2]= " |
+ | | ||
+ | nomvideosPlante[4]= " | ||
+ | nomvideosPlante[5]= " | ||
+ | nomvideosPlante[6]= " | ||
+ | nomvideosPlante[7]= " | ||
+ | | ||
video_active = new boolean[nPlantes]; | video_active = new boolean[nPlantes]; | ||
for (int i=0; i< | for (int i=0; i< | ||
Ligne 239: | Ligne 158: | ||
// print the values (for debugging purposes only): | // print the values (for debugging purposes only): | ||
- | println(" | + | println(" |
- | + " | + | |
+ | + " | ||
+ | |||
+ | // | ||
+ | // | ||
///////////////////////// | ///////////////////////// | ||
Ligne 250: | Ligne 173: | ||
//// affichage de la vidéo si la vidéo i est active //////////////////////////////////////// | //// affichage de la vidéo si la vidéo i est active //////////////////////////////////////// | ||
boolean une_video_active=false; | boolean une_video_active=false; | ||
- | for(int i=0; | + | for (int i=0; i< |
une_video_active = (une_video_active || video_active[i]); | une_video_active = (une_video_active || video_active[i]); | ||
} | } | ||
Ligne 270: | Ligne 193: | ||
</ | </ | ||
- | + | **2** => **Processing :** __ test_7plantes_sonores > test_7plantes_sonores.pde__ | |
- | **3** => __plante_sonore_Processing_3__ | + | |
< | < | ||
///////////////////////////////// | ///////////////////////////////// | ||
Ligne 328: | Ligne 250: | ||
} | } | ||
</ | </ | ||
- | + | **3** => **Processing :** __test_7plantes_sonores > SerialEvent.pde__ | |
- | **4** => __SerialEvent__ | + | |
< | < | ||
void serialEvent(Serial myPort) { | void serialEvent(Serial myPort) { | ||
Ligne 343: | Ligne 264: | ||
firstContact = true; // you've had first contact from the microcontroller | firstContact = true; // you've had first contact from the microcontroller | ||
myPort.write(' | myPort.write(' | ||
- | } | + | } |
- | } | + | } else { |
- | | + | |
// Add the latest byte from the serial port to array: | // Add the latest byte from the serial port to array: | ||
serialInArray[serialCount] = inByte; | serialInArray[serialCount] = inByte; | ||
Ligne 351: | Ligne 271: | ||
// If we have 3 bytes: | // If we have 3 bytes: | ||
- | if (serialCount > 2 ) { | + | if (serialCount > nPlantes-1 |
- | plante[0] = serialInArray[0]; | + | |
- | plante[1] = serialInArray[1]; | + | plante[i] = serialInArray[i]; |
- | plante[2] = serialInArray[2]; | + | } |
+ | //plante[0] = serialInArray[0]; | ||
+ | | ||
+ | | ||
+ | //plante[3] = serialInArray[3]; | ||
+ | //plante[4] = serialInArray[4]; | ||
+ | //plante[5] = serialInArray[5]; | ||
+ | //plante[6] = serialInArray[6]; | ||
+ | //plante[7] = serialInArray[7]; | ||
// print the values (for debugging purposes only): | // print the values (for debugging purposes only): | ||
Ligne 365: | Ligne 293: | ||
} | } | ||
} | } | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | |||
+ | </ | ||
+ | |||
+ | **4** => **Arduino** : test_7plantes_sonores.ino.ino | ||
+ | < | ||
+ | |||
+ | //Import a library from the Arduino folder | ||
+ | #include < | ||
+ | /////////////////////////////// | ||
+ | byte Ncapteurs = 8; | ||
+ | |||
+ | //Select the two pins that will act as a capacitor | ||
+ | CapacitiveSensor | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | }; | ||
+ | long* capSensorVal ; // mémorise la valeur lue sur chaque capteurs | ||
+ | |||
+ | //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 ; | ||
+ | |||
+ | // port série | ||
+ | int inByte = 0; | ||
+ | |||
+ | ///////////////////// | ||
+ | boolean debug1 = false, debug2 = false; | ||
+ | //////////////////////////////////////////// | ||
+ | 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 | ||
+ | } | ||
+ | |||
+ | // création des tableaux | ||
+ | capSensorVal = malloc(Ncapteurs * sizeof(long)); | ||
+ | plante = malloc(Ncapteurs * sizeof(int)); | ||
+ | // initialisation des tableaux | ||
+ | for (int i = 0; i < Ncapteurs; i++) { | ||
+ | capSensorVal[i] = 0; | ||
+ | plante[i] = 0; | ||
+ | } | ||
+ | |||
+ | pinMode(ledPin, | ||
+ | // init des capteurs capacitifs | ||
+ | cs_2[0].set_CS_AutocaL_Millis(0xFFFFFFFF); | ||
+ | |||
+ | establishContact(); | ||
+ | } | ||
+ | |||
+ | 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); | ||
+ | Serial.print(" | ||
+ | |||
+ | for (int i = 0; i < Ncapteurs; i++) { | ||
+ | Serial.print(capSensorVal[i]); | ||
+ | Serial.print(" | ||
+ | } | ||
+ | Serial.println("" | ||
+ | } | ||
+ | |||
+ | |||
+ | |||
+ | // test des valeurs des capteurs | ||
+ | for (int i = 0; i < Ncapteurs; i++) { | ||
+ | plante[i] = testCapteur(capSensorVal[i], | ||
+ | } | ||
+ | if (debug2) { | ||
+ | for (int i = 0; i < Ncapteurs; i++) { | ||
+ | Serial.print(plante[i]); | ||
+ | Serial.print(" | ||
+ | } | ||
+ | Serial.println("" | ||
+ | } | ||
+ | else { | ||
+ | // send sensor values: on envoie à Processing l' | ||
+ | for (int i = 0; i < Ncapteurs; i++) { | ||
+ | Serial.write(plante[i]); | ||
+ | } | ||
+ | } | ||
+ | } | ||
+ | } | ||
+ | |||
+ | void establishContact() { | ||
+ | while (Serial.available() <= 0) { | ||
+ | Serial.print(' | ||
+ | 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, | ||
+ | // plante i activée | ||
+ | return 255; | ||
+ | } | ||
+ | //Touch undetected | ||
+ | else { | ||
+ | //Turn off the led | ||
+ | digitalWrite(ledPin, | ||
+ | // plante i inactivée | ||
+ | return 0; | ||
+ | } | ||
+ | |||
} | } | ||
</ | </ | ||