Tags

    1.28.15 Computer Science

    I did it! LCD temperature sensor success! Here is the setup
    The LCD screen reads the temp. The balck half moon on the left side is the temperature sensor. The middle pin goes to A0. If you want to set up the lcd, look it up! Just remember that the third and fifth pin both go to ground. Second to 5v power.
    Here is the code:
    /*
    Adafruit Arduino - Lesson 12. Light and Temperature
    */
    #include <LiquidCrystal.h>
    int tempPin = 0;
    // BS E D4 D5 D6 D7
    LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
    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);
    delay(2000);
    }


    Comments