Buatin pseudocode tentang ini dong … Khusus mahasiswa di bidangnya ya ,
#include "Wire.h"
#include <LiquidCrystal.h>
#include "DHT.h"
#define DHTPIN 12
#define DHTTYPE DHT11
LiquidCrystal lcd(9, 8, 7, 6, 5, 4);
DHT dht(DHTPIN, DHTTYPE);
int mark = 0;
void setup() {
lcd.begin(16, 2);
lcd.clear();
lcd.noCursor();
pinMode(10,OUTPUT);
pinMode(11,OUTPUT);
pinMode(A2,INPUT);
pinMode(A3,INPUT);
digitalWrite(A2,HIGH);
digitalWrite(A3,HIGH);
dht.begin();
}
void loop() {
float h = dht.readHumidity();
float t = dht.readTemperature();
float f = dht.readTemperature(true);
if (isnan(h) || isnan(t) || isnan(f)) {
Serial.println("Failed to read from DHT sensor!");
return;
}
float hic = dht.computeHeatIndex(t, h, false);
int cahaya = analogRead(A0);
int hujan = analogRead(A1);
lcd.setCursor(0, 0);
lcd.print("H=");
lcd.print(h,1);
lcd.setCursor(8, 0);
lcd.print("C=");
lcd.print(cahaya);
lcd.setCursor(8, 1);
lcd.print("A=");
lcd.print(hujan);
delay(1000);
if((hujan < 500)&&(mark == 0)){
delay(200);
mark = 1;
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("TEDUH");
teduh();
}
if((cahaya < 20)&&(mark == 0)){
delay(200);
mark = 1;
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("TEDUH");
teduh();
}
if((cahaya > 20)&&(hujan > 500)&&(mark == 1)){
delay(200);
mark = 0;
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("KERING");
kering();
}
}
void teduh(){
digitalWrite(10,HIGH);
digitalWrite(11,LOW);
int a = digitalRead(A2);
if(a == 0){
digitalWrite(10,LOW);
digitalWrite(11,LOW);
delay(1000);
lcd.clear();
return;
}
teduh();
}
void kering(){
digitalWrite(10,LOW);
digitalWrite(11,HIGH);
int b = digitalRead(A3);
if(b == 0){
digitalWrite(10,LOW);
digitalWrite(11,LOW);
delay(1000);
lcd.clear();
return;
}
kering();
}