
Note : Intel Gallileo dapat diganti dengan mikrokontroller seperti Arduino Uno, Genuino 101, Arduino Mega, dll
Listing Program ::
#include <LiquidCrystal.h>
LiquidCrystal lcd(1,2,4,5,6,7);
int p=13;
int u=12;
int d=11;
const int relay=8;
int a,b,c,e;
float suhuOn=30;
float suhuOff=29;
float vin =0;
float temp=0;
int pilih=0, up=0, down=0;
void setup() {
lcd.begin(16,2);
pinMode(relay, OUTPUT);
pinMode(pilih, INPUT);
pinMode(up, INPUT);
pinMode(down, INPUT);
}
void loop() {
up=digitalRead(u);
down=digitalRead(d);
pilih=digitalRead(p);
if(pilih==HIGH && a==0){
//suhu ON
a=1;
delay(10);
}
else if(pilih==HIGH && a==1){
//suhu OFF
a=0;
delay(10);
}
if(a==0){
if(up==HIGH){
suhuOn++;
}
else if(down==HIGH){
suhuOn--;
}
lcd.setCursor(0,1);
lcd.print("set Suhu On : ");
lcd.print(suhuOn);
}
else if(a==1){
if(up==HIGH){
suhuOff++;
}
else if(down==HIGH){
suhuOff--;
}
lcd.setCursor(0,1);
lcd.print("set Suhu Off :");
lcd.print(suhuOff);
}
vin=analogRead(A0);
temp=(500*vin)/1023;
lcd.setCursor(0,0);
lcd.print("Temp: ");
lcd.print(temp);
if(temp>=suhuOn){
lcd.setCursor(12,0);
lcd.print(" ON ");
digitalWrite(relay,HIGH);
delay(400);
}
else if(temp<=suhuOff){
lcd.setCursor(12,0);
lcd.print(" OFF");
digitalWrite(relay,LOW);
delay(400);
}
}
kak, apa ada scematic alatnya?
BalasHapus