lcd-display-parallel — Arduino Uno simulation

An interactive Arduino Uno circuit simulation you can run free in your browser on Velxio, by gfn.

Components

Sketch code

// Arduino lcd display (parallel)
#include <LiquidCrystal.h>
#include <DHT.h>


// LCD-Pins: RS = 12, E = 11, D4 = 5, D5 = 4, D6 = 3, D7 = 2

LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
DHT sensor(7, DHT22);
int ledPinRed = 13;
int ledPinGreen = 10;
int buzzerPin = 8;


void setup() {
    lcd.begin(16, 2);
    sensor.begin();
    pinMode(ledPinRed, OUTPUT);
    pinMode(ledPinGreen, OUTPUT);
    pinMode(buzzerPin, OUTPUT);
    lcd.setCursor(0,0);
    lcd.print("Starte ...");
    delay(1000);
}

void loop() {
    float temp = sensor.readTemperature();
    float feuchte = sensor.readHumidity();
    float fahrenheit = temp * 1.8 + 32;

    lcd.clear();
    lcd.setCursor(0, 0);
    lcd.print("T: ");
    lcd.print(temp, 1);
    lcd.print("C (");
    lcd.print(fahrenheit,1);
    lcd.print("F)");

    lcd.setCursor(12, 1);
    if (temp > 30.0){
        lcd.print("ALM");
        digitalWrite(ledPinRed, HIGH);
        digitalWrite(ledPinGreen, LOW);
        tone(buzzerPin, 300);
    } else if (temp > 25.0){
        lcd.print("WARN");
        digitalWrite(ledPinRed, HIGH);
        digitalWrite(ledPinGreen, LOW);
        noTone(buzzerPin);
    } else {
        lcd.print("OK");
        digitalWrite(ledPinRed, LOW);
        digitalWrite(ledPinGreen, HIGH);
        noTone(buzzerPin);
    }


    lcd.setCursor(0, 1);
    lcd.print("H: ");
    lcd.print(feuchte, 0);
    lcd.print(" %");
    
    delay(2000);
}

More projects by gfn