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:table-mixage-images:accueil [2021/06/07 15:02] lea.hermann [Programmes Arduino] |
wiki:flossmanuals:table-mixage-images:accueil [2021/06/28 14:45] (Version actuelle) damien.muti |
||
---|---|---|---|
Ligne 17: | Ligne 17: | ||
{{ : | {{ : | ||
+ | |||
+ | {{ : | ||
===== Algorithme ===== | ===== Algorithme ===== | ||
Ligne 30: | Ligne 32: | ||
==== Programmes Arduino ==== | ==== Programmes Arduino ==== | ||
- | Le code permettant : | + | Le code permettant |
- | * | + | * {{ : |
< | < | ||
Ligne 86: | Ligne 88: | ||
===== Programme Processing ===== | ===== Programme Processing ===== | ||
+ | Le programme Processing permettant de récupérer les données envoyées par la cartes et de les considérer comme des paramètres permettant de faire varier les aspects visuels d'une images (rouge, vert, bleu, luminance, saturation et un paramètre de filtrage) est le suivant : | ||
+ | * {{ : | ||
+ | |||
+ | < | ||
+ | /** //<>// | ||
+ | * Serial Call-Response | ||
+ | * by Tom Igoe. | ||
+ | | ||
+ | * Sends a byte out the serial port, and reads 3 bytes in. | ||
+ | * Sets foregound color, red, and green of a circle onstage | ||
+ | * using the values returned from the serial port. | ||
+ | * Thanks to Daniel Shiffman | ||
+ | | ||
+ | * Note: This sketch assumes that the device on the other end of the serial | ||
+ | * port is going to send a single byte of value 65 (ASCII A) on startup. | ||
+ | * The sketch waits for that byte, then sends an ASCII A whenever | ||
+ | * it wants more data. | ||
+ | */ | ||
+ | |||
+ | // | ||
+ | PImage img1; | ||
+ | //je ne sais pas encore quels sont ces entiers | ||
+ | int picAlpha = 255; | ||
+ | |||
+ | import processing.serial.*; | ||
+ | |||
+ | int bgcolor; | ||
+ | //int fgcolor; | ||
+ | Serial myPort; | ||
+ | int N = 5 ; // nombre de valeurs lue, venant de la carte Arduino | ||
+ | int[] serialInArray = new int[N]; | ||
+ | int serialCount = 0; // A count of how many bytes we receive | ||
+ | int red, green, blue, alpha, filt; | ||
+ | boolean firstContact = false; | ||
+ | |||
+ | void setup() { | ||
+ | size(420, 420); // Stage size | ||
+ | noStroke(); | ||
+ | |||
+ | img1= loadImage(" | ||
+ | //img1= loadImage(" | ||
+ | //img1= loadImage(" | ||
+ | img1.resize(410, | ||
+ | |||
+ | |||
+ | // parametres associés aux boutons Sensor lus par la carte arduino | ||
+ | red = width/2; | ||
+ | green = height/2; | ||
+ | blue=0; | ||
+ | alpha=0; | ||
+ | filt=2; | ||
+ | |||
+ | // Print a list of the serial ports, for debugging purposes: | ||
+ | printArray(Serial.list()); | ||
+ | |||
+ | // I know that the first port in the serial list on my mac | ||
+ | // is always my FTDI adaptor, so I open Serial.list()[0]. | ||
+ | // On Windows machines, this generally opens COM1. | ||
+ | // Open whatever port is the one you're using. | ||
+ | String portName = Serial.list()[11]; | ||
+ | myPort = new Serial(this, | ||
+ | } | ||
+ | |||
+ | void draw() { // affichage dans la fenêtre graphique | ||
+ | |||
+ | //je ne sais pas encore ce que c'est | ||
+ | //picAlpha = int(map(red, | ||
+ | |||
+ | background(255); | ||
+ | fill(255); | ||
+ | |||
+ | tint(green+100, | ||
+ | image(img1, 5, 5);//imoage + positionnement de l' | ||
+ | |||
+ | // Draw the shape | ||
+ | // | ||
+ | | ||
+ | filter(POSTERIZE, | ||
+ | } | ||
+ | |||
+ | void serialEvent(Serial myPort) { // gestion du dialogue avec la carte Arduino | ||
+ | // 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 == ' | ||
+ | myPort.clear(); | ||
+ | firstContact = true; // you've had first contact from the microcontroller | ||
+ | myPort.write(' | ||
+ | } | ||
+ | } else { | ||
+ | // Add the latest byte from the serial port to array: | ||
+ | serialInArray[serialCount] = inByte; | ||
+ | serialCount++; | ||
+ | |||
+ | // If we have N bytes: | ||
+ | if (serialCount > N-1 ) { | ||
+ | red = serialInArray[0]; | ||
+ | green = serialInArray[1]; | ||
+ | blue = serialInArray[2]; | ||
+ | alpha = serialInArray[3]; | ||
+ | filt = serialInArray[4]; | ||
+ | |||
+ | // print the values (for debugging purposes only): | ||
+ | println(" | ||
+ | |||
+ | // Send a capital A to request new sensor readings: | ||
+ | myPort.write(' | ||
+ | // Reset serialCount: | ||
+ | serialCount = 0; | ||
+ | } | ||
+ | } | ||
+ | } | ||
+ | |||
+ | </ | ||
===== Réalisation de la maquette et visuels ===== | ===== Réalisation de la maquette et visuels ===== | ||
- | {{ : | + | |
{{ : | {{ : | ||
{{ : | {{ : |