Minggu, 26 Mei 2013

Upgrade Program II

UPGRADE PROGRAM II

//proses = status tombol
int proses = 0 ;

//inisialisasi kaki kaki
int sensor1=A1;
int sensor2=A2;
int tombol=2;
int heater1=3;
int heater2=4;
#include <LiquidCrystal.h>

//inisialisasi kaki kaki LCD
LiquidCrystal lcd(12, 11, 8, 7, 6, 5);

void setup() {
//Serial.begin(9600);
pinMode(13,OUTPUT);
pinMode(2,INPUT);
pinMode(3,OUTPUT);
pinMode(4,OUTPUT);

//tampilan awal
lcd.begin(16,2);
lcd.print("Smart RiceCooker");
lcd.setCursor(1,1);
lcd.print("  PMSD_IM'11");
delay(5000);

}

void loop() {
//  display menggunakan serial monitor
//Serial.print("proses ");
//Serial.print(proses);
//Serial.print(" sensor1 ");
//Serial.print(sensor1);
//Serial.print(" sensor2 ");
//Serial.println(sensor2);

//menampilkan mode
if (proses==0){
  lcd.setCursor(1,1);
lcd.print("  Mode WARM   ");
}
else {
  lcd.setCursor(1,1);
lcd.print("  Mode COOK   ");
}

//menampilkan suhu
lcd.setCursor(0,0);
lcd.print(" S1=   C");
lcd.setCursor(4,0);
lcd.print(sensor1);
lcd.setCursor(8,0);
lcd.print(";S2=   C" );
lcd.setCursor(12,0);
lcd.print(sensor2);

//inisialisasi tombol
if (digitalRead(2)==HIGH){
proses = 1;
delay(200);
}

//program utama warm
if (proses == 0 ){
sensor2=analogRead(2)*0.49;
sensor1=analogRead(1)*0.49;

if (sensor2 <70){
digitalWrite(13,HIGH);
digitalWrite(heater2,HIGH);
}
else if (sensor2>73){
digitalWrite(13,LOW);
digitalWrite(heater2,LOW);
}
}

//program utama cook
if(proses == 1){
sensor1=analogRead(1)*0.49;
sensor2=analogRead(2)*0.49;

if (sensor1 <120){
digitalWrite(13,HIGH);
digitalWrite(heater1,HIGH);
}
else if (sensor1 >123){
digitalWrite(13,LOW);
digitalWrite(heater1,LOW);
proses = 0;
}
}
delay(1000);
}

Tidak ada komentar:

Posting Komentar