Outils pour utilisateurs

Outils du site


wiki:flossmanuals:livre-enfant-interactif-pression: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:livre-enfant-interactif-pression:accueil [2021/05/02 15:19]
vincent
wiki:flossmanuals:livre-enfant-interactif-pression:accueil [2021/06/01 17:33] (Version actuelle)
damien.muti
Ligne 5: Ligne 5:
   * **Contexte** : Micro-projet de cours   * **Contexte** : Micro-projet de cours
   * **Fichiers** :    * **Fichiers** : 
-  * **Liens** : https://www.instructables.com/Interfacing-Force-Sensitive-Resistor-to-Arduino/+  * **Liens** : https://www.instructables.com/Interfacing-Force-Sensitive-Resistor-to-Arduino/ https://courses.ischool.berkeley.edu/i262/f13/content/sydmayes/lab-4-fsr-and-processing.html
   * **Capteurs/Actionneurs** :    * **Capteurs/Actionneurs** : 
     * Carte Arduino Uno /Seeduino     * Carte Arduino Uno /Seeduino
Ligne 14: Ligne 14:
 ===== Intentions : explication du projet et objectifs ===== ===== Intentions : explication du projet et objectifs =====
  
-Dans le cadre d'une édition jeunesse, l'objectif est de réaliser un livre interactif afin de susciter la manipulation et de rendre acteur l'enfant. À l'aide d'un capteur de pression dissimulé dans une page, des sons et/ou formes seront générés sur Processing lorsque l'enfant appuieras sur celui-ci. Ces sons et/ou formes pourront varier en intensité (sonore / taille de la forme / couleur) ou bien se multiplier en fonction de la force transmise sur le capteur.+Dans le cadre d'une édition jeunesse, l'objectif est de réaliser un livre interactif afin de susciter la manipulation et de dynamiser la lecture de l'enfant. À l'aide d'un capteur de pression dissimulé dans une page, des sons et/ou formes seront générés sur Processing lorsque l'enfant appuieras sur celui-ci. Ces sons et/ou formes pourront varier en intensité (sonore / taille de la forme / couleur) ou bien se multiplier en fonction de la force transmise sur le capteur.
  
 {{ :wiki:flossmanuals:livre-enfant-interactif-pression:flossmanual_schema_explicatif.jpg |}} {{ :wiki:flossmanuals:livre-enfant-interactif-pression:flossmanual_schema_explicatif.jpg |}}
Ligne 21: Ligne 21:
 ===== Plans et schémas de fonctionnement ===== ===== Plans et schémas de fonctionnement =====
  
-. **Faire varier l'intensité d'une led**+. **Faire varier l'intensité d'une led ou d'une forme sur processing**
  
 {{ :wiki:flossmanuals:livre-enfant-interactif-pression:plan_variation_intensite_led.png |}} {{ :wiki:flossmanuals:livre-enfant-interactif-pression:plan_variation_intensite_led.png |}}
  
-===== Programmes ===== +===== Programmes ARDUINO ===== 
- +==== Programme pour faire varier l'intensité d'une led ==== 
-Programme Arduino : **faire varier l'intensité d'une led** +<code>
 int fsrAnalogPin = 0; / FSR connecté a A0 int fsrAnalogPin = 0; / FSR connecté a A0
  
Ligne 56: Ligne 55:
   delay(100);   delay(100);
 } }
 +</code>
  
 +==== Programme pour envoyer UNE donnée via le port série ====
 +<code>
 +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
 +  }
 +
 +  pinMode(2, INPUT);   // digital sensor is on digital pin 2
 +  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();
 +    // read first analog input, divide by 4 to make the range 0-255:
 +    firstSensor = analogRead(A0)/4;
 +   
 +    // send sensor values:
 +    Serial.write(firstSensor);
 +    delay(10); // patienter 10ms (à voir...)
 +    }
 +}
 +
 +void establishContact() {
 +  while (Serial.available() <= 0) {
 +    Serial.print('A');   // send a capital A
 +    delay(300);
 +  }
 +}
 +
 +</code>
 +
 +==== Programme final : mélange des deux programmes précédents  ====
 +A COMPLETER
 +
 +===== Programme PROCESSING =====
 +
 +==== Variation forme graphique ====
 +<code>
 +import processing.serial.*;
 +
 +int bgcolor[] = {255, 255, 255};      / Background color
 +
 +int fgcolor =255;      / Fill color
 +
 +int xpos, ypos;                 / Starting position of the ball
 +
 +int rayon = 20;
 +
 +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(500, 500);  // 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()[0];
 +  myPort = new Serial(this, portName, 9600);
 +
 +  // espace HSB des couleurs
 +  colorMode(HSB);
 +}
 +
 +void draw() {
 +  rectMode(CENTER);
 +  background(0);
 +  fill (255, 255, 200);
 +  circle(xpos,ypos,rayon);
 +}
 +
 +
 +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 {
 +    rayon= (int)map(inByte, 0,255,20,400);
 +    // print the values (for debugging purposes only):
 +    println("valeur lue sur le port Série = " + rayon);
 +
 +    // Send a capital A to request new sensor readings:
 +    myPort.write('A');
 +    
 +  }
 +}
 +
 +</code>
 ===== Réalisation de la maquette ===== ===== Réalisation de la maquette =====
  
 +==== Images ====
 +
 +{{ :wiki:flossmanuals:livre-enfant-interactif-pression:photos_capteur_pression.jpg |}}
 +
 +==== Vidéos ==== 
  
 +  * Faire varier l'intensité d'une LED : https://youtu.be/Ll94pqV1qZw
 +  * Faire varier une forme graphique sur Processing : https://youtu.be/0GPNYONl8aM
wiki/flossmanuals/livre-enfant-interactif-pression/accueil.1619961579.txt.gz · Dernière modification: 2021/05/02 15:19 de vincent