Monitor Gas MQ2 dan MQ135 serta suhu DHT22
a. Komponen Penyusun
b. Program Arduino IDE
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include "DHT.h"
#define DHTPIN 8
LiquidCrystal_I2C lcd(0x27, 16, 2);
#define DHTTYPE DHT22
float t;
int mq135;
int mq2;
int v;
DHT dht(DHTPIN, DHTTYPE);
void setup()
{
Serial.begin(9600);
lcd.begin();
lcd.clear();
lcd.noCursor();
dht.begin();
}
void loop()
{
t = dht.readTemperature();
mq135 = analogRead(A0);
mq2 = analogRead(A1);
lcd.setCursor(0,0);
lcd.print("Suhu= ");
lcd.print(t);
lcd.print(" ");
lcd.setCursor(0,1);
lcd.print("G1/G2= ");
lcd.print(mq135);
lcd.print("/");
lcd.print(mq2);
lcd.print(" ");
delay(200);
}
c. VIDEO HASILNYA
No comments:
Post a Comment