Outils pour utilisateurs

Outils du site


wiki:flossmanuals:capteur-distance-slideshow:accueil

Différences

Ci-dessous, les différences entre deux révisions de la page.

Lien vers cette vue comparative

Les deux révisions précédentes Révision précédente
Prochaine révision
Révision précédente
wiki:flossmanuals:capteur-distance-slideshow:accueil [2021/05/17 16:47]
mathilde
wiki:flossmanuals:capteur-distance-slideshow:accueil [2023/03/22 20:03]
mathilde supprimée
Ligne 1: Ligne 1:
-====== Dating Burnout ======+====== Capteur de distance slideshow ======
  
   * **Porteur(s) du projet** : Mathilde Verdu Ibañez, Ugo Berzal, Chloé Chapal (DSAA 1) & Damien MUTI (Prof. de Numérique)   * **Porteur(s) du projet** : Mathilde Verdu Ibañez, Ugo Berzal, Chloé Chapal (DSAA 1) & Damien MUTI (Prof. de Numérique)
   * **Date** : 03/2021   * **Date** : 03/2021
-  * **Contexte** :  +  * **Capteurs/Actionneurs** : Capteur de distance
-  * **Fichiers** :  +
-  * **Liens** : +
-  * **Capteurs/Actionneurs** :  +
-    * Capteur de distance+
  
 ---- ----
Ligne 13: Ligne 9:
 ===== Intentions : explication du projet et objectifs ===== ===== Intentions : explication du projet et objectifs =====
  
 +Intentions Chloé : [[wiki:flossmanuals:tableaux-vivants:accueil|Tableaux vivants avec capteur de distance]]\\
 +Intentions Mathilde : [[wiki:flossmanuals:digital-dating-burnout:accueil|Digital Dating Burnout]]
  
 ===== Plans et schémas de fonctionnement ===== ===== Plans et schémas de fonctionnement =====
  
 +{{:wiki:flossmanuals:capteur-distance-slideshow:untitled_sketch_bb_copie.jpg|}}
 +{{:wiki:flossmanuals:capteur-distance-slideshow:190885245_309380357412091_2352791358108117506_n.jpg|}}
 +{{:wiki:flossmanuals:capteur-distance-slideshow:191157980_826833747943382_638515641192184510_n.jpg|}}
  
 ===== Programmes ===== ===== Programmes =====
 +
 +**ARDUINO**
 +
 +
 +#include "Ultrasonic.h"
 +
 +Ultrasonic ultrasonic(7);
 +
 +long distance=0; / variable qui stoke la valeur de la distance
 +
 +int firstSensor = 0;    / first analog sensor 
 +
 +int inByte = 0;         / incoming serial byte
 +
 +
 +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
 +  }
 +  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();
 +
 +    // lecture de la distance
 +    distance = ultrasonic.MeasureInCentimeters();
 +    // conversion de la valeur en un octet
 +    firstSensor = map(distance,0,400,0,255);
 +    
 +    // send sensor values:
 +    Serial.write(firstSensor);
 +    delay(200);
 +   
 +  }
 +}
 +
 +void establishContact() {
 +  while (Serial.available() <= 0) {
 +    Serial.print('A');   // send a capital A
 +    delay(300);
 +  }
 +}
 +
 +
 +
 +
 +**PROCESSING**
 +
 +
 +
 +import processing.serial.*;
 +
 +/ graphisme
 +
 +int bgcolor;      / Background color
 +
 +int fgcolor;      / Fill color
 +
 +int xpos, ypos;                 / Starting position of the ball
 +
 +int distance;
 +
 +PImage[] tabImages;
 +
 +int NImages = 3;
 +
 +/port serie
 +
 +Serial myPort;                       / The serial port
 +
 +int serialInArray;    / Where we'll put what we receive
 +
 +int serialCount = 0;                 / A count of how many bytes we receive
 +
 +boolean firstContact = false;        / Whether we've heard from the microcontroller
 +
 +void setup() {
 +  size(600, 485);  // Stage size
 +  noStroke();      // No border on the next thing drawn
 +
 +  // Set the starting position of the ball (middle of the stage)
 +  xpos = width/2;
 +  ypos = height/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()[9];
 +  myPort = new Serial(this, portName, 9600);
 +
 +  // espace HSB des couleurs
 +  colorMode(HSB);
 +
 +  //creation tableau images
 +  tabImages=new PImage[NImages];
 +  for (int i=0; i<NImages; i++) {
 +    tabImages[i]= loadImage("images"+i+".jpg");
 +  }
 +}
 +
 +void draw() {
 +  background(bgcolor);
 +  // test distance
 +  if (distance >= 0 && distance < 50) {
 +    image(tabImages[0], 0, 0, width, height);
 +  } else if (distance >= 50 && distance < 100) {
 +    image(tabImages[1], 0, 0, width, height);
 +  } else if (distance >= 100 && distance < 150) {
 +    image(tabImages[2], 0, 0, width, height);
 +  } else {
 +    image(tabImages[0], 0, 0, width, height);
 +    //fill(0);
 +    //rect(0, 0, width, height);
 +  }
 +
 +
 +
 +   //fill(fgcolor, 255, 255);
 +  // Draw the shape
 +  //ellipse(xpos, ypos, 20, 20);
 +}
 +
 +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:
 +    distance = (int) map(inByte, 0, 255, 0, 400); // remplir le donnée "utile"
 +    // print the values (for debugging purposes only):
 +    println("valeur lue sur le port Série = " +  distance);
 +
 +    // Send a capital A to request new sensor readings:
 +    myPort.write('A');
 +    // Reset serialCount:
 +  }
 +}
  
  
-===== Réalisation de la maquette =====