Aplikasi Kontrol Kandang
1. Tujuan [kembali]
- Dapat mengaplikasikan mikrokontroler arduino pada rangkaian sensor
- Dapat menciptakan kandang dengan kontrol arduino
2. Komponen [kembali]
- Relay
- Potensiometer
- Baterai
- Motor DC
- Lampu
- Buzzer
- LCD 16x2
- Sensor Ultrasonic
- Sensor DHT22
- LDR
3. Dasar Teori [kembali]
- Potensiometer
- Resistor
- Relay
- LCD 16x2
- Sensor Ultrasonic
- Sensor DHT22
- LDR
4. Percobaan [kembali]
Prinsip Kerja
Listing Program
#include<LiquidCrystal.h>
#define sensorLDR A0
#include "DHT.h"
#include <HCSR04.h>
#define DHTPIN 13
#define DHTTYPE DHT11
int nilaiLDR, nilaiSuhu, nilaiKelembaban, nilaiAir;
int lampu = A1;
int heater = A2;
int enPompa = A3;
int enPakan = 10;
int pompa1 = 1;
int pompa2 = 8;
int pakan1 = 12;
int pakan2 = 11;
LiquidCrystal lcd (2,3,4,5,6,7);
UltraSonicDistanceSensor distanceSensor(0,9);
DHT dht(DHTPIN, DHT11);
void setup() {
pinMode (lampu, OUTPUT);
pinMode (sensorLDR, INPUT);
pinMode (DHTPIN, INPUT);
pinMode (lampu, OUTPUT);
pinMode (heater, OUTPUT);
pinMode (enPakan, OUTPUT);
pinMode (enPompa, OUTPUT);
pinMode (pakan1, OUTPUT);
pinMode (pakan2, OUTPUT);
pinMode (pompa1, OUTPUT);
pinMode (pompa2, OUTPUT);
dht.begin();
lcd.begin(16,2);
Serial.begin(9600);
}
void loop() {
nilaiLDR = analogRead(sensorLDR);
nilaiSuhu = dht.readTemperature();
nilaiKelembaban = dht.readHumidity();
nilaiAir = distanceSensor.measureDistanceCm();
lcd.clear();
lcd.setCursor(0,0);
lcd.print(nilaiSuhu);
lcd.setCursor(7,0);
lcd.print(nilaiKelembaban);
if(nilaiLDR<=20){
analogWrite(lampu, 255);
}
else{
analogWrite(lampu, 0);
}
if(nilaiSuhu<=34){
analogWrite(heater, 255);
}
else{
analogWrite(heater, 0);
}
if (nilaiKelembaban<=65){
analogWrite(enPompa, 255);
digitalWrite(pompa1, HIGH);
digitalWrite(pompa2, LOW);
}
else {
analogWrite(enPompa, 0);
digitalWrite(pompa1, LOW);
digitalWrite(pompa2, LOW);
}
if (nilaiAir>=50){
digitalWrite(enPakan, HIGH);
digitalWrite(pakan1, HIGH);
digitalWrite(pakan2, LOW);
}
else{
digitalWrite(enPakan, LOW);
digitalWrite(pakan1, LOW);
digitalWrite(pakan2, LOW);
}
delay(100);
}
Gambar Rangkaian
5. Video [kembali]
6. File Download [kembali]
Tidak ada komentar:
Posting Komentar