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:livre-enfant-interactif-pression:accueil [2021/05/17 14:44] vincent [Programmes] |
wiki:flossmanuals:livre-enfant-interactif-pression:accueil [2021/06/01 17:33] damien.muti |
||
---|---|---|---|
Ligne 5: | Ligne 5: | ||
* **Contexte** : Micro-projet de cours | * **Contexte** : Micro-projet de cours | ||
* **Fichiers** : | * **Fichiers** : | ||
- | * **Liens** : https:// | + | * **Liens** : https:// |
* **Capteurs/ | * **Capteurs/ | ||
* 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' | + | Dans le cadre d'une édition jeunesse, l' |
{{ : | {{ : | ||
Ligne 21: | Ligne 21: | ||
===== Plans et schémas de fonctionnement ===== | ===== Plans et schémas de fonctionnement ===== | ||
- | . **Faire varier l' | + | . **Faire varier l' |
{{ : | {{ : | ||
- | ===== Programmes ===== | + | ===== Programmes |
- | + | ==== Programme | |
- | . Programme | + | < |
int fsrAnalogPin = 0; / FSR connecté a A0 | int fsrAnalogPin = 0; / FSR connecté a A0 | ||
Ligne 56: | Ligne 55: | ||
delay(100); | delay(100); | ||
} | } | ||
+ | </ | ||
- | . Programme | + | ==== Programme |
+ | < | ||
int firstSensor = 0; / first analog sensor | int firstSensor = 0; / first analog sensor | ||
Ligne 94: | Ligne 94: | ||
} | } | ||
} | } | ||
+ | |||
+ | </ | ||
+ | |||
+ | ==== Programme final : mélange des deux programmes précédents | ||
+ | A COMPLETER | ||
+ | |||
+ | ===== Programme PROCESSING ===== | ||
+ | |||
+ | ==== Variation forme graphique ==== | ||
+ | < | ||
+ | import processing.serial.*; | ||
+ | |||
+ | int bgcolor[] = {255, 255, 255}; | ||
+ | |||
+ | int fgcolor =255; | ||
+ | |||
+ | int xpos, ypos; / Starting position of the ball | ||
+ | |||
+ | int rayon = 20; | ||
+ | |||
+ | Serial myPort; | ||
+ | |||
+ | int serialInArray; | ||
+ | |||
+ | int serialCount = 0; / A count of how many bytes we receive | ||
+ | |||
+ | boolean firstContact = false; | ||
+ | |||
+ | |||
+ | void setup() { | ||
+ | size(500, 500); // Stage size | ||
+ | noStroke(); | ||
+ | |||
+ | // 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, | ||
+ | |||
+ | // espace HSB des couleurs | ||
+ | colorMode(HSB); | ||
+ | } | ||
+ | |||
+ | void draw() { | ||
+ | rectMode(CENTER); | ||
+ | background(0); | ||
+ | fill (255, 255, 200); | ||
+ | circle(xpos, | ||
+ | } | ||
+ | |||
+ | |||
+ | 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 == ' | ||
+ | myPort.clear(); | ||
+ | firstContact = true; // you've had first contact from the microcontroller | ||
+ | myPort.write(' | ||
+ | } | ||
+ | } else { | ||
+ | rayon= (int)map(inByte, | ||
+ | // print the values (for debugging purposes only): | ||
+ | println(" | ||
+ | |||
+ | // Send a capital A to request new sensor readings: | ||
+ | myPort.write(' | ||
+ | | ||
+ | } | ||
+ | } | ||
+ | |||
+ | </ | ||
===== Réalisation de la maquette ===== | ===== Réalisation de la maquette ===== | ||
+ | ==== Images ==== | ||
+ | |||
+ | {{ : | ||
+ | |||
+ | ==== Vidéos ==== | ||
+ | * Faire varier l' | ||
+ | * Faire varier une forme graphique sur Processing : https:// |