Tmp36GZ με LCD οθόνη
// Define to which pin of the Arduino the output of the TMP36 is connected:
#include <LiquidCrystal_I2C.h>
// Look for LiquidCrystal I2C library by Marco Schwartz
LiquidCrystal_I2C lcd(0x27,16,2); // set the LCD address to 0x3F for a 16 chars and 2 line display
#define sensorPin A0
void setup() {
// Begin serial communication at a baud rate of 9600:
Serial.begin(9600);
lcd.init();
lcd.clear();
lcd.backlight(); // Make sure backlight is on
// Print a message on both lines of the LCD.
lcd.setCursor(2,0); //Set cursor to character 2 on line 0
lcd.print("Hello world!");
lcd.setCursor(2,1); //Move cursor to character 2 on line 1
lcd.print("LCD Tutorial");
}
void loop() {
// Get a reading from the temperature sensor:
int reading = analogRead(sensorPin);
// Convert the reading into voltage:
float voltage = reading * (5000 / 1024.0);
// Convert the voltage into the temperature in Celsius:
float temperature = (voltage - 500) / 10;
// Print the temperature in the Serial Monitor:
Serial.print(temperature);
Serial.print(" \xC2\xB0"); // shows degree symbol
Serial.println("C");
// Print the temperature in the LCD:
lcd.clear();
lcd.setCursor(2,0); //Set cursor to character 2 on line 0
lcd.print(temperature);
lcd.print((char)223);
lcd.print("C");
delay(1000); // wait a second between readings
}
Σχόλια
Δημοσίευση σχολίου