Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <Wire.h> // Wire Bibliothek einbinden
- #include <LiquidCrystal_I2C.h> // Vorher hinzugefügte LiquidCrystal_I2C Bibliothek einbinden
- LiquidCrystal_I2C lcd(0x3F, 16, 2); //Hier wird festgelegt um was für einen Display es sich handelt. In diesem Fall eines mit 16 Zeichen in 2 Zeilen und der HEX-Adresse 0x27. Für ein vierzeiliges I2C-LCD verwendet man den Code "LiquidCrystal_I2C lcd(0x27, 20, 4)"
- int TMP36 = A0;
- int sensorwert;
- int temperatur = 0;
- int t = 10000;
- int counter = 0;
- int highest = 0;
- int lowest = 0;
- int latest= 0;
- void setup()
- {
- lcd.init(); //Im Setup wird der LCD gestartet
- lcd.backlight(); //Hintergrundbeleuchtung einschalten (lcd.noBacklight(); schaltet die Beleuchtung aus).
- }
- void loop()
- {
- sensorwert = analogRead(TMP36);
- temperatur = map(sensorwert, 0, 410, -50, 150);
- if(counter == 0) {
- lcd.setCursor(0,0);
- lcd.print("Initialize");
- lcd.setCursor(0,1);
- for(int i = 0; i < 16; i++) {
- lcd.print("#");
- delay(300);
- }
- highest = temperatur;
- lowest = temperatur;
- }
- lcd.clear();
- counter++;
- lcd.setCursor(0,0);
- lcd.print(temperatur);
- lcd.print(" Grad Celcius");
- lcd.setCursor(0,1);
- lcd.print(counter);
- lcd.print(".MS");
- if(temperatur > highest) {
- highest = temperatur;
- }
- if(temperatur < lowest) {
- lowest = temperatur;
- }
- lcd.print(" H:");
- lcd.print(highest);
- lcd.print(" L:");
- lcd.print(lowest);
- delay(t);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement