Modifications

Sauter à la navigation Sauter à la recherche
533 octets ajoutés ,  16 juillet 2012 à 11:20
Ligne 105 : Ligne 105 :     
=== Exemple simple ===
 
=== Exemple simple ===
Wire the FSR as same as the above example, but this time lets add an LED to pin 11.
+
Raccordez le senseur FSR comme présenté dans l'exemple précédent. Ajoutons également une LED (et sa résistance) sur la Pin 11.
    
[[Fichier:FSR-SAMLE1.jpg]]
 
[[Fichier:FSR-SAMLE1.jpg]]
Ligne 111 : Ligne 111 :  
[[Fichier:FSR-SAMLE2.jpg]]
 
[[Fichier:FSR-SAMLE2.jpg]]
   −
This sketch will take the analog voltage reading and use that to determine how bright the red LED is. The harder you press on the FSR, the brighter the LED will be! Remember that the LED has to be connected to a PWM pin for this to work, I use pin 11 in this example.
+
Ce sketch va lire la tension sur l'entrée analogique et utilise cette valeur pour déterminer la luminosité de la LED.
   −
These examples assume you know some basic Arduino programming.
+
Plus vous pressez le senseur FSR et plus la LED sera lumineuse! Souvenez-vous que la LED doit être branchée sur une sortie PWM pour contrôler sa lunimosité, nous utilisons la pin 11 dans cet exemple.
 +
 
 +
Cet exemple par du principe que vous disposé déjà des notions de base de programmation avec Arduino.
    
  <nowiki>
 
  <nowiki>
   /* FSR testing sketch.
+
   /* sketch de test pour senseur FSR .
     Connect one end of FSR to 5V, the other end to Analog 0.
+
     Connectez une borne du FSR à +5V, l'autre sur la pin Analog 0.
     Then connect one end of a 10K resistor from Analog 0 to ground
+
     Connectez ensuite une résistance de 10 Ko entre la pin Analog 0 et la masse/GND.
     Connect LED from pin 11 through a resistor to ground
+
     Connectez une LED de la pin 11 à la massge/GND VIA une résistance.
     For more information see www.ladyada.net/learn/sensors/fsr.html */
+
 
 +
     Pour plus d'information, voir le wiki de MC Hobby (en Français)
 +
        http://mchobby.be/wiki/index.php?title=Senseur_FSR
 +
    Ou le site de Lady Ada (AdaFruit, en anglais)
 +
        http://www.ladyada.net/learn/sensors/fsr.html  
 +
  */
   −
   int fsrAnalogPin = 0; // FSR is connected to analog 0
+
   int fsrAnalogPin = 0; // FSR branché sur pin Analog 0
   int LEDpin = 11; // connect Red LED to pin 11 (PWM pin)
+
   int LEDpin = 11; // connecter LED rouge sur pin 11 (pin PWM)
   int fsrReading; // the analog reading from the FSR resistor divider
+
   int fsrReading; // Lecture analogique de la tension du pont
 +
                  //   diviseur FSR + Resistance Pull-Down
 
   int LEDbrightness;
 
   int LEDbrightness;
    
   void setup(void) {
 
   void setup(void) {
     Serial.begin(9600); // We'll send debugging information via the Serial monitor
+
     Serial.begin(9600); // Envoi de message de déboggage sur connexion série
 +
                        // Visible dans le Moniteur Série d'Arduino IDE
 
     pinMode(LEDpin, OUTPUT);
 
     pinMode(LEDpin, OUTPUT);
 
   }
 
   }
Ligne 136 : Ligne 145 :  
     Serial.print("Analog reading = ");
 
     Serial.print("Analog reading = ");
 
     Serial.println(fsrReading);
 
     Serial.println(fsrReading);
     // we'll need to change the range from the analog reading (0-1023) down to the range
+
     // Nous devons convertir la valeur analogique lue (0-1023)  
     // used by analogWrite (0-255) with map!
+
     // en une valeur utilisable par analogWrite (0-255).
 +
    // C'est ce que fait l'instruction map!
 
     LEDbrightness = map(fsrReading, 0, 1023, 0, 255);
 
     LEDbrightness = map(fsrReading, 0, 1023, 0, 255);
 
     // LED gets brighter the harder you press
 
     // LED gets brighter the harder you press
29 917

modifications

Menu de navigation