This project consists of using a LCD to display the temperature on the screen (LCD). We used a sensor, leds and potenciometro.
We started by adding the library which was needed to make it work, called “LiquidCrystal”. After that, we declared the ports we were going to use for the LCD (LiquidCrystal lcd(12, 11, 5, 4, 3, 2)).
We created a variable float vrif= 1.1 that represents the tension used by the sensor and a variable called “val” which reads the analogic port.
To calculate the temperature we calculated its average using: TempAverage += (95.0 * vrif * val) / 1024.0. The number 95.0 represents the constant and 1024.0 represents the number of different signals the sensor can get.
To distinguish from the different temperatures we used 3 leds with different colors. Blue is when the temperature is below 25°C, green is when the temperature is between 25°C and 27°C and the red one is when it is above 27°C.
To display it on the LCD we had to use different functions from the LiquidCrystal library. To choose the position to display the text we used lcd.setCursor(0,0); (0 column and 0 line). Then we used lcd.print(“Temperature:”); and lcd.print(TempAverage); to display it on the screen.