Modifications

Sauter à la navigation Sauter à la recherche
161 octets ajoutés ,  8 janvier 2013 à 20:11
Ligne 121 : Ligne 121 :     
=== Un thermomètre simple ===
 
=== Un thermomètre simple ===
This example code for Arduino shows a quick way to create a temperature sensor, it simply prints to the serial port what the current temperature is in both Celsius and Fahrenheit.
+
Cet exemple de code pour Arduino montre comment créer rapidement un senseur de température, il affiche simplement la température it simply prints to the serial port what the current temperature is in both Celsius and Fahrenheit.
  <nowiki>   //TMP36 Pin Variables
+
  <nowiki>//Variable de la broche pour le TMP36
    int sensorPin = 0; //the analog pin the TMP36's Vout (sense) pin is connected to
+
int sensorPin = 0; //la broche analogique sur laquelle le sortie VOut du TMP36 est raccordé
    //the resolution is 10 mV / degree centigrade with a
+
// Résolution est de 10 mV / degrée centigrade avec une offset de 500 mV
    //500 mV offset to allow for negative temperatures
+
// pour permettre la lecture de température négative
    /*
+
 
    * setup() - this function runs once when you turn your Arduino on
+
/*
    * We initialize the serial connection with the computer
+
* setup() - cette fonction est exécutée un fois au démarrage d'Arduino.
    */
+
* Nous initialisons la connexion série avec l'ordinateur.
    void setup()
+
*/
    {
+
void setup()
     Serial.begin(9600); //Start the serial connection with the computer
+
{
     //to view the result open the serial monitor
+
     Serial.begin(9600); //Démarrer la connexion série avec l'ordinateur
    }
+
     // Pour voir le résultat, ouvrez le moniteur série d'Arduino IDE
    void loop() // run over and over again
+
}
    {
+
 
     //getting the voltage reading from the temperature sensor
+
void loop() // Constamment exécute et ré-exécuté
 +
{
 +
     // acquisition de la tension lue sur le senseur de température
 
     int reading = analogRead(sensorPin);
 
     int reading = analogRead(sensorPin);
     // converting that reading to voltage, for 3.3v arduino use 3.3
+
     // convertir cette lecture en tension, utilisez 3.3 pour un Arduino 3.3v
 
     float voltage = reading * 5.0;
 
     float voltage = reading * 5.0;
 
     voltage /= 1024.0;
 
     voltage /= 1024.0;
     // print out the voltage
+
     // Afficher la tension
 
     Serial.print(voltage); Serial.println(" volts");
 
     Serial.print(voltage); Serial.println(" volts");
     // now print out the temperature
+
     // Maintenant, afficher la température
     float temperatureC = (voltage - 0.5) * 100 ; //converting from 10 mv per degree wit 500 mV offset
+
     float temperatureC = (voltage - 0.5) * 100 ; //convertie de 10mv par degrés avec un décalage (offset) de 500 mV
     //to degrees ((volatge - 500mV) times 100)
+
     //En degrés ((volatge - 500mV) fois 100)
     Serial.print(temperatureC); Serial.println(" degrees C");
+
     Serial.print(temperatureC); Serial.println(" degres C");
     // now convert to Fahrenheight
+
     // Maintenant, convertir en degrés Fahrenheight
 
     float temperatureF = (temperatureC * 9.0 / 5.0) + 32.0;
 
     float temperatureF = (temperatureC * 9.0 / 5.0) + 32.0;
     Serial.print(temperatureF); Serial.println(" degrees F");
+
     Serial.print(temperatureF); Serial.println(" degres F");
     delay(1000); //waiting a second
+
     delay(1000); //attendre une seconde
    }</nowiki>
+
}</nowiki>
    
=== Obtenir une meilleure précision ===
 
=== Obtenir une meilleure précision ===
29 910

modifications

Menu de navigation