Ligne 156 : |
Ligne 156 : |
| | | |
| === Mesures FSR analogique (code simple) === | | === Mesures FSR analogique (code simple) === |
− | Here is a code example for measuring the FSR on an analog pin.
| + | Voici un code d'exemple qui mesure un senseur FSR avec un entrée analogique. |
| | | |
| [[Fichier:FSR-SAMLE2-1.jpg]] | | [[Fichier:FSR-SAMLE2-1.jpg]] |
Ligne 164 : |
Ligne 164 : |
| [[Fichier:FSR-SAMLE2-3.jpg]] | | [[Fichier:FSR-SAMLE2-3.jpg]] |
| | | |
− | This code doesn't do any calculations, it just prints out what it interprets as the amount of pressure in a qualitative manner. For most projects, this is pretty much all thats needed!
| + | Ce code ne fait aucun calcul, il affiche juste ce qui est interprété comme la pression (information qualitative). Cela est suffisant dans la plupart des projets! |
| | | |
| <nowiki> | | <nowiki> |
− | /* FSR simple testing sketch. | + | /* Simple test de FSR (sketch). |
− | Connect one end of FSR to power, the other end to Analog 0. | + | Connectez une broche du FSR sur l'alimentation et l'autre |
− | Then connect one end of a 10K resistor from Analog 0 to ground | + | broche sur la pin analogique Analog 0. |
| + | Connectez ensuite une résistance de 10K entre l'entrée |
| + | analogique Analog 0 et la masse (GND) |
| | | |
| Pour plus d'information, voir le wiki de MC Hobby (en Français) | | Pour plus d'information, voir le wiki de MC Hobby (en Français) |
Ligne 177 : |
Ligne 179 : |
| */ | | */ |
| | | |
− | int fsrPin = 0; // the FSR and 10K pulldown are connected to a0 | + | int fsrPin = 0; // Le senseur FSR et la résistance PullDown de 10K connectés sur A0 |
− | int fsrReading; // the analog reading from the FSR resistor divider | + | int fsrReading; // Lecture analogique du pont diviseur FSR+Résistance |
| | | |
| void setup(void) { | | void setup(void) { |
− | // We'll send debugging information via the Serial monitor | + | // Envoyons des information de débogage sur le port série |
| Serial.begin(9600); | | Serial.begin(9600); |
| } | | } |
Ligne 187 : |
Ligne 189 : |
| void loop(void) { | | void loop(void) { |
| fsrReading = analogRead(fsrPin); | | fsrReading = analogRead(fsrPin); |
− | Serial.print("Analog reading = "); | + | Serial.print("Lecture Analogique = "); |
− | Serial.print(fsrReading); // the raw analog reading | + | Serial.print(fsrReading); // La valeur brute (valeur analogique lue) |
− | // We'll have a few threshholds, qualitatively determined | + | // Utilisons quelques seuils, pour faire une détermination qualitative |
| if (fsrReading < 10) { | | if (fsrReading < 10) { |
− | Serial.println(" - No pressure"); | + | Serial.println(" - Pas de pression (No pressure)"); |
| } else if (fsrReading < 200) { | | } else if (fsrReading < 200) { |
− | Serial.println(" - Light touch"); | + | Serial.println(" - Touché léger (Light touch)"); |
| } else if (fsrReading < 500) { | | } else if (fsrReading < 500) { |
− | Serial.println(" - Light squeeze"); | + | Serial.println(" - Pression légère (Light squeeze)"); |
| } else if (fsrReading < 800) { | | } else if (fsrReading < 800) { |
− | Serial.println(" - Medium squeeze"); | + | Serial.println(" - Pression moyenne (Medium squeeze)"); |
| } else { | | } else { |
− | Serial.println(" - Big squeeze"); | + | Serial.println(" - Forte pression (Big squeeze)"); |
| } | | } |
| delay(1000); | | delay(1000); |