Embedded
Embedded
Embedded
h>
#define dht_pin 7
dht Dht;
void setup(){
Serial.begin(9600);
delay(500);
pinMode(6, OUTPUT); // kipas
pinMode(4,OUTPUT); // spray
Serial.println("DHT11 Sensor");
delay(1000);
}
void loop(){
//dht11
Dht.read11(dht_pin);
int suhu = Dht.temperature;
int kelembaban = Dht.humidity;
if (suhu>35.00)
{
Serial.println("suhu tinggi Kipas menyala, spray menyala");
digitalWrite(6, HIGH); //kipas on
digitalWrite(4, HIGH);//spray on
}
if (suhu < 35.00 && kelembaban > 65)
{
Serial.println("kelembapan tinggi, kipas menyala");
digitalWrite(6, HIGH); // kipas on
digitalWrite(4, LOW); // spray off
}
if (suhu < 35.00 && kelembaban < 65.00){
Serial.println("suhu standart");
Serial.println("kipas dan spray mati");
digitalWrite(6, LOW);
digitalWrite(4, LOW);
// digitalWrite(13, LOW);
}
//display
Serial.print("humidity = "); Serial.print(Dht.humidity);Serial.println(" %");
Serial.print("suhu = "); Serial.print(Dht.temperature);Serial.println("C");
delay(500);
}
#include <LiquidCrystal_I2C.h>
//(address, kolom, baris)
LiquidCrystal_I2C lcd(0x27, 16, 2);
void setup() {
void loop() {
}
#include <Servo.h>
Servo myServo;
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
pinMode(2, OUTPUT);
pinMode(4, OUTPUT);
//servo
myServo.attach(9);
}
void loop() {
int adc = analogRead(A0);
float pwm = map(adc, 0, 1023, 0,255);
Serial.print("Adc = ");
Serial.print(adc);
Serial.print(", pwm = ");
Serial.print(pwm);
Serial.print(" , pwm2 = ");
Serial.println(pwm2);
digitalWrite(2, HIGH);
digitalWrite(4, LOW);
analogWrite(3, pwm);
delay(1000);
//PWM --> Sudut putar
myServo.write(pwm2);
delay(1000);
}