Afficheur LCD-part 2-Code Arduino

De MCHobby - Wiki
Révision datée du 1 janvier 2013 à 20:54 par Admin (discussion | contributions) (Page créée avec « {{afficheur-lcd-part2-nav}} The sketch for this is based on that of lesson 11. Load it up onto your Arduino and you should find that warming the temperature sensor by puttin... »)
(diff) ← Version précédente | Voir la version actuelle (diff) | Version suivante → (diff)
Sauter à la navigation Sauter à la recherche

The sketch for this is based on that of lesson 11. Load it up onto your Arduino and you should find that warming the temperature sensor by putting your finger on it will increase the temperature reading.

Also if you wave your hand over the photocell blocking out some of the light, the reading will decrease.

    /*
    Adafruit Arduino - Lesson 12. Light and Temperature
    */
     
    #include <LiquidCrystal.h>
     
    int tempPin = 0;
    int lightPin = 1;
     
    // BS E D4 D5 D6 D7
    LiquidCrystal lcd(7, 8, 9, 10, 11, 12);
     
    void setup()
    {
    lcd.begin(16, 2);
    }
     
    void loop()
    {
    // Display Temperature in C
    int tempReading = analogRead(tempPin);
    float tempVolts = tempReading * 5.0 / 1024.0;
    float tempC = (tempVolts - 0.5) * 100.0;
    float tempF = tempC * 9.0 / 5.0 + 32.0;
    // ----------------
    lcd.print("Temp F ");
    lcd.setCursor(6, 0);
    lcd.print(tempF);
    // Display Light on second row
    int lightReading = analogRead(lightPin);
    lcd.setCursor(0, 1);
    // ----------------
    lcd.print("Light ");
    lcd.setCursor(6, 1);
    lcd.print(lightReading);
    delay(500);
    }

Créer par Simon Monk pour AdaFruit

Traduit avec l'autorisation d'AdaFruit Industries - Translated with the permission from Adafruit Industries - www.adafruit.com

Toute référence, mention ou extrait de cette traduction doit être explicitement accompagné du texte suivant : «  Traduction par MCHobby (www.MCHobby.be) - Vente de kit et composants » avec un lien vers la source (donc cette page) et ce quelque soit le média utilisé.

L'utilisation commercial de la traduction (texte) et/ou réalisation, même partielle, pourrait être soumis à redevance. Dans tous les cas de figures, vous devez également obtenir l'accord du(des) détenteur initial des droits. Celui de MC Hobby s'arrêtant au travail de traduction proprement dit.