Modifications

Sauter à la navigation Sauter à la recherche
990 octets ajoutés ,  23 juillet 2012 à 17:21
Ligne 312 : Ligne 312 :     
  <nowiki>
 
  <nowiki>
    /* FSR simple testing sketch.
+
  /* sketch de test pour senseur FSR .
     Connect one end of FSR to power, the other end to pin 2.
+
     Connectez une borne du FSR à +5V, l'autre sur la pin 2 Digital.
     Then connect one end of a 0.1uF capacitor from pin 2 to ground
+
     Connectez ensuite une broche d'une capacité de 0.1uF sur la pin 2 et l'autre à la masse/GND.
     For more information see www.ladyada.net/learn/sensors/fsr.html */
+
   
     int fsrPin = 2; // the FSR and cap are connected to pin2
+
     Pour plus d'information, voir le wiki de MC Hobby (en Français)
     int fsrReading; // the digital reading
+
        http://mchobby.be/wiki/index.php?title=Senseur_FSR
     int ledPin = 13; // you can just use the 'built in' LED
+
    Ou le site de Lady Ada (AdaFruit, en anglais)
 +
        http://www.ladyada.net/learn/sensors/fsr.html  
 +
  */
 +
 +
     int fsrPin = 2; // Le senseur FSR et capacité connectés sur pin2
 +
     int fsrReading; // Lecture digitale
 +
     int ledPin = 13; // LED sur Pin 13 (vous pouvez utiliser la LED disponible sur la carte)
 
     void setup(void) {
 
     void setup(void) {
    // We'll send debugging information via the Serial monitor
+
      // Faisons également un peu de débogage sur le moniteur série 
    Serial.begin(9600);
+
      Serial.begin(9600);
    pinMode(ledPin, OUTPUT); // have an LED for output
+
     
 +
      pinMode(ledPin, OUTPUT); // Utiliser la LED comme sortie
 
     }
 
     }
 +
 
     void loop(void) {
 
     void loop(void) {
    // read the resistor using the RCtime technique
+
      // Lire la résistance en utilisant la technique du temps de chargement RC
    fsrReading = RCtime(fsrPin);
+
      //  (technique "RCtime" en anglais)
    if (fsrReading == 30000) {
+
      fsrReading = RCtime(fsrPin);
    // if we got 30000 that means we 'timed out'
+
      if (fsrReading == 30000) {
    Serial.println("Nothing connected!");
+
        // si nous avons atteint 30000 c'est un 'timed out'
    } else {
+
        Serial.println("Rien de connecté!");
    Serial.print("RCtime reading = ");
+
      } else {
    Serial.println(fsrReading); // the raw analog reading
+
        Serial.print("Lecture temps RC = ");
    // Do a little processing to keep the LED blinking
+
        Serial.println(fsrReading); // La lecture analogique brute
    fsrReading /= 10;
+
     
    // The more you press, the faster it blinks!
+
        // faire un peut de traitement pour faire
    digitalWrite(ledPin, HIGH);
+
        // clignoter la LED
    delay(fsrReading);
+
        fsrReading /= 10;
    digitalWrite(ledPin, LOW);
+
 
    delay(fsrReading);
+
        // Plus vous pressez le senseur et plus la LED clignote vite!
 +
        digitalWrite(ledPin, HIGH);
 +
        delay(fsrReading);
 +
        digitalWrite(ledPin, LOW);
 +
        delay(fsrReading);
 +
      }
 +
      delay(100);
 
     }
 
     }
     delay(100);
+
      
     }
+
     // Utiliser une broche digitale pour mesurer la résistance (comme un senseur FSR ou
     // Uses a digital pin to measure a resistor (like an FSR or photocell!)
+
     //   un photo-résistance!)
     // We do this by having the resistor feed current into a capacitor and
+
     // Nous y arrivons grâce à la résistance du FSR qui permet à la capacité de se charger
     // counting how long it takes to get to Vcc/2 (for most arduinos, thats 2.5V)
+
     // plus ou moins vite. C'est en comptant le temps qu'il faudra pour arriver à VCC/2
 +
    // (tension d'activation de l'entrée digitale des Arduino, soit 2.5V) que l'on détermine
 +
    // la valeur de la résistance du FSR
 +
    //
 
     int RCtime(int RCpin) {
 
     int RCtime(int RCpin) {
    int reading = 0; // start with 0
+
      int reading = 0; // démarre à 0
    // set the pin to an output and pull to LOW (ground)
+
      // declaré la PIN comme sortie et la mettre au niveau bas... à la masse (LOW)
    pinMode(RCpin, OUTPUT);
+
      pinMode(RCpin, OUTPUT);
    digitalWrite(RCpin, LOW);
+
      digitalWrite(RCpin, LOW);
    // Now set the pin to an input and...
+
      // Maintenant, mette la pin en entrée et...
    pinMode(RCpin, INPUT);
+
      pinMode(RCpin, INPUT);
    while (digitalRead(RCpin) == LOW) { // count how long it takes to rise up to HIGH
+
      // compter le temps qu'il faudra pour qu'elle arrive à HIGH
    reading++; // increment to keep track of time
+
      while (digitalRead(RCpin) == LOW) {
    if (reading == 30000) {
+
        reading++; // incrémenter pour 'compter' le temps qui passe.
    // if we got this far, the resistance is so high
+
        if (reading == 30000) {
    // its likely that nothing is connected!
+
          // Si nous arrivons si loin, c'est que la résistance est tellement grande
    break; // leave the loop
+
          // que le temps de chargement tend vers l'infini (ou qu'il n'y a rien de
    }
+
          // connecté!)
    }
+
         
    // OK either we maxed out at 30000 or hopefully got a reading, return the count
+
          break; // quitter la boucle
 +
        }
 +
      }
 +
      // OK soit nous avons la valeur MAX, soit nous avons une lecture correcte.
 +
      //  either we maxed out at 30000 or hopefully got a reading, return the count
 
     return reading;
 
     return reading;
 
     }
 
     }
29 917

modifications

Menu de navigation