Project Untuk Kelompok 3
Komponen yang dibutuhkan :
- Arduino (Versi apapun) >> 1 Buah.
- Fan (Kipas) seperti pada gambar diatas >> 1 Buah.
- DHT-11 Sensor Temperature & Humadity >> 1 Buah.
- Kabel >> Seperlunya.
/*
* Generated Code by Kang Kamal
* kangkamal.blogspot.com
*/
#include "DHT.h"
#define DHTPIN 2 // what pin we're connected to
#define DHTTYPE DHT11 // DHT 11
int fanPin = 13;
float suhu = 0;
DHT dht(DHTPIN, DHTTYPE);
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
Serial.println("DHT11 test!");
pinMode(fanPin, OUTPUT);
digitalWrite(fanPin, LOW); //Set default kipas mati saat program startup
}
void loop() {
// put your main code here, to run repeatedly:
suhu = dht.readTemperature();
Serial.print("Suhu Ruangan : ");
Serial.println(suhu);
if (suhu > 30){
digitalWrite(fanPin, HIGH); //Kipas nyala saat suhu diatas 30
}
else{
digitalWrite(fanPin, LOW); //Kipas mati saat suhu dibawah 30
}
}
0 comments:
Post a Comment