Anda di halaman 1dari 8

#define

#define
#define
#define

microswitch
tombol_peras
sensor_spin
buzzer

0
1
3
4

#define
#define
#define
#define
#define
#define

level_1
level_2
level_3
sensor_air_pdam
air_sumur
sensor_air

10
11
12
13
14
15

#define valve_pdam
#define valve_sumur
#define valve_air_masuk
OR SANYO
#define valve_pewangi
#define valve_rinso_cair
#define motor_spin
#define motor_cuci2
#define motor_cuci1
#define valve_air_spin
#define valve_air_bak
#define valve_buang

16
17
18
19
20
21
22
23
29
30
31

//microswitch tutup tombol_peras


// sensor elektroda air bak tombol_peras

// sensor elektroda air bak cuci

//air masuk ke bodi mesin cuci //KOPLE DANGAN MOT

// MOTOR MESIN CUCI


// MOTOR MESIN CUCI

char serial_input;
char serial[20], buffer[64];
int i, j, berat, kotor, timer, nilai, tunda, putaran;
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
PORTA = 0x00; DDRA = 0xFF;
pinMode(buzzer, OUTPUT); digitalWrite(buzzer, LOW);
//pin 4
pinMode(level_1, INPUT); digitalWrite(level_1, HIGH);
//pin 10
pinMode(level_2, INPUT); digitalWrite(level_2, HIGH);
//pin 11
pinMode(level_3, INPUT); digitalWrite(level_3, HIGH);
//pin 12
pinMode(sensor_air_pdam, INPUT); digitalWrite(sensor_air_pdam, HIGH);
//pin 13
pinMode(air_sumur, INPUT); digitalWrite(air_sumur, HIGH);
//pin 14
pinMode(sensor_air, INPUT); digitalWrite(sensor_air, HIGH);
//pin 15
pinMode(sensor_spin, INPUT); digitalWrite(sensor_spin, HIGH);
pinMode(tombol_peras, INPUT); digitalWrite(tombol_peras, HIGH);
pinMode(microswitch, INPUT); digitalWrite(microswitch, HIGH);
pinMode(motor_cuci1, OUTPUT); digitalWrite(motor_cuci1, LOW);
pinMode(motor_cuci2, OUTPUT); digitalWrite(motor_cuci2, LOW);
pinMode(motor_spin, OUTPUT); digitalWrite(motor_spin, LOW);
pinMode(valve_rinso_cair, OUTPUT); digitalWrite(valve_rinso_cair, LOW);
pinMode(valve_pewangi, OUTPUT); digitalWrite(valve_pewangi, LOW);
pinMode(valve_air_masuk, OUTPUT); digitalWrite(valve_air_masuk, LOW);
//KOP
LE DANGAN MOTOR SANYO
pinMode(valve_sumur, OUTPUT); digitalWrite(valve_sumur, LOW);
pinMode(valve_pdam, OUTPUT); digitalWrite(valve_pdam, LOW);

pinMode(valve_buang, OUTPUT); digitalWrite(valve_buang, LOW);


pinMode(valve_air_bak, OUTPUT); digitalWrite(valve_air_bak, LOW);
pinMode(valve_air_spin, OUTPUT); digitalWrite(valve_air_spin, LOW);
}
void loop() {
// put your main code here, to run repeatedly:
awal:
if(Serial.available()) {
serial_input=Serial.read();
serial[i]=serial_input;
if(serial[i]=='@') {
konversi(serial[1]);
berat=nilai;
konversi(serial[3]);
kotor=nilai;
konversi(serial[5]);
timer=nilai;
//==================== PROGRAM UTAMA =====================
if
(berat == 2) tunda = 6; // dalam detik
else if (berat == 4) tunda = 4; // dalam detik
else if (berat == 6) tunda = 2; // dalam detik
if
(timer == 1) putaran = (5 * 60) / tunda;
else if (timer == 2) putaran = (10 * 60) / tunda;
else if (timer == 3) putaran = (15 * 60) / tunda;
int tahapan = berat/2;
//--------------------------------------------------------Serial.print("1"); // SENSOR MENGECEK AIR!
delay(3000);
{if (digitalRead(sensor_air_pdam) == LOW) {
digitalWrite(valve_pdam, HIGH);
// ON
digitalWrite(valve_air_bak, HIGH);
// ON
delay(2000);
digitalWrite(valve_air_masuk, HIGH); // ON

//KOPLE DANGAN MOTOR

SANYO
digitalWrite(valve_air_spin, LOW); // OFF
digitalWrite(valve_sumur, LOW);
// OFF
Serial.print("2"); // mengisi dengan PDAM
delay(2000);
}
else {
digitalWrite(valve_pdam, LOW);
// OFF
digitalWrite(valve_air_spin, LOW); // OFF
digitalWrite(valve_air_bak, HIGH);
// ON
digitalWrite(valve_sumur, HIGH);
// ON
delay(2000);
digitalWrite(valve_air_masuk, HIGH); // ON

//KOPLE DANGAN MOTOR

SANYO
Serial.print("3"); // mengisi dengan SUMUR
delay(2000);
}
Serial.print("4"); //sedang Mengisi AIR
delay(1500);
if
(berat== 2) { while (digitalRead(level_1) == 1) {} goto loncat;
}
else if (berat== 4) { while (digitalRead(level_2) == 1) {} goto loncat;
}

else if (berat== 6) { while (digitalRead(level_3) == 1) {} goto loncat;


}
loncat:
digitalWrite(valve_air_masuk, LOW); // OFF

//KOPLE DANGAN MOTOR SAN

YO
digitalWrite(valve_pdam, LOW);
// OFF
digitalWrite(valve_sumur, LOW);
// OFF
digitalWrite(valve_air_bak, LOW);
// OFF
digitalWrite(buzzer, HIGH); delay(500); digitalWrite(buzzer, LOW);
Serial.print("5"); // Selesai Mengisi air
delay(2000);
//===================================== program isi rinso ======================
=================================
{
Serial.print("6"); //mengisi rinso_cair
if
(berat==2) { digitalWrite(valve_rinso_cair, HIGH); delay(15000); }
// ON
else if(berat==4) { digitalWrite(valve_rinso_cair, HIGH); delay(26000); }
// ON
else if(berat==6) { digitalWrite(valve_rinso_cair, HIGH); delay(38000); }
// ON
digitalWrite(valve_rinso_cair, LOW);
// OFF
Serial.print("7"); // Selesai isi rinso_cair
delay(3000);
}
//====================================== program proses cuci====================
==================================
{
Serial.print("8"); // Proses Mencuci
for (j = 0; j < putaran; j++) {
digitalWrite(motor_cuci1, HIGH);
//on
digitalWrite(motor_cuci2, LOW); delay(((tunda - 1)/2) * 2000);
//off
digitalWrite(motor_cuci1, LOW);
//off
digitalWrite(motor_cuci2, LOW); delay(7000); // STOP SEBENTAR
//off
digitalWrite(motor_cuci1, LOW);
//off
digitalWrite(motor_cuci2, HIGH); delay(((tunda- 1)/2) * 2000);
//on
digitalWrite(motor_cuci1, LOW);
//off
digitalWrite(motor_cuci2, LOW); delay(7000); // STOP SEBENTAR
//off
}
Serial.print("9"); // Buang Air cucian
delay(1000);
digitalWrite(buzzer, HIGH); delay(500); digitalWrite(buzzer, LOW);
digitalWrite(valve_buang, HIGH); //ON
while (digitalRead(sensor_air) == 0) {}
digitalWrite(valve_buang, LOW); //OFF
}
for (j = 0; j < 3; j++) {
digitalWrite(buzzer, HIGH); delay(1000); digitalWrite(buzzer, LOW);delay
(500);
digitalWrite(buzzer, HIGH); delay(1000); digitalWrite(buzzer, LOW);
}

//===============================SELESAI MENCUCI PAKAIAN========================


===========================================================================
//masuk tahap pembilasan
Serial.print("a"); // TAHAP PEMBILASAN
delay(5000);
if (digitalRead(sensor_air_pdam) == LOW) {
Serial.print("b"); // SENSOR MENGECEK AIR
delay(2000);
digitalWrite(valve_pdam, HIGH);
// ON
digitalWrite(valve_air_bak, HIGH);
// ON
delay(2000);
digitalWrite(valve_air_masuk, HIGH); // ON

//KOPLE DANGAN MOTOR

SANYO
digitalWrite(valve_air_spin, LOW); // OFF
digitalWrite(valve_sumur, LOW);
// OFF
Serial.print("c"); // mengisi dengan PDAM
delay(2000);
}
else {
digitalWrite(valve_pdam, LOW);
// OFF
digitalWrite(valve_air_spin, LOW); // OFF
digitalWrite(valve_air_bak, HIGH);
// ON
digitalWrite(valve_sumur, HIGH);
// ON
delay(2000);
digitalWrite(valve_air_masuk, HIGH); // ON

//KOPLE DANGAN MOTOR

SANYO
Serial.print("d"); // mengisi dengan sumur
delay(2000);
}
Serial.print("e");
delay(1500);
if
(berat==2) {
else if(berat==4) {
else if(berat==6) {

//sedang Mengisi AIR


while(digitalRead(level_1)==1) {} goto loncat1;}
while(digitalRead(level_2)==1) {} goto loncat1;}
while(digitalRead(level_3)==1) {} goto loncat1;}

loncat1:
Serial.print("f"); //selesai isi air
delay(1500);
digitalWrite(valve_pdam, LOW);
// OFF
digitalWrite(valve_air_masuk, LOW); // OFF
digitalWrite(valve_air_bak, LOW);
// OFF
digitalWrite(valve_sumur, LOW);
// OFF
digitalWrite(valve_air_spin, LOW); // OFF
digitalWrite(buzzer, HIGH); delay(500); digitalWrite(buzzer, LOW);
delay(2000);
Serial.print("g"); //PROSES MEMBILAS tahap 2
for (j = 0; j < putaran/ 2; j++) {
digitalWrite(motor_cuci1, HIGH);
//on
digitalWrite(motor_cuci2, LOW); delay(((tunda - 1)/2) * 2000);
//off
digitalWrite(motor_cuci1, LOW);
//off
digitalWrite(motor_cuci2, LOW); delay(6000); // STOP SEBENTAR
//off
digitalWrite(motor_cuci1, LOW);
//off
digitalWrite(motor_cuci2, HIGH); delay(((tunda- 1)/2) * 2000);
//on
digitalWrite(motor_cuci1, LOW);

//off
digitalWrite(motor_cuci2, LOW); delay(6000); // STOP SEBENTAR
//off
}
{
Serial.print("h"); // membuang air bilasan
delay(3000);
digitalWrite(buzzer, HIGH); delay(500); digitalWrite(buzzer, LOW);
digitalWrite(valve_buang, HIGH); //ON
while (digitalRead(sensor_air) == 0) {}
digitalWrite(valve_buang, LOW); //OFF
}
for (j = 0; j < 6; j++) {
digitalWrite(buzzer, HIGH); delay(1000); digitalWrite(buzzer, LOW);del
ay(500);
digitalWrite(buzzer, HIGH); delay(1000); digitalWrite(buzzer, LOW);
}
//======================================TAHAP 3 PEMBILASAN
Serial.print("k"); // SENSOR MENGECEK AIR
delay(2000);
if (digitalRead(sensor_air_pdam) == LOW) {
digitalWrite(valve_pdam, HIGH);
// ON
digitalWrite(valve_air_bak, HIGH);
// ON
delay(2000);
digitalWrite(valve_air_masuk, HIGH); // ON

//KOPLE DANGAN MOTOR

SANYO
digitalWrite(valve_air_spin, LOW); // OFF
digitalWrite(valve_sumur, LOW);
// OFF
Serial.print("l"); // mengisi dengan PDAM
delay(2000);
}
else{
digitalWrite(valve_pdam, LOW);
// OFF
digitalWrite(valve_air_spin, LOW); // OFF
digitalWrite(valve_air_bak, HIGH);
// ON
digitalWrite(valve_sumur, HIGH);
// ON
delay(2000);
digitalWrite(valve_air_masuk, HIGH); // ON

//KOPLE DANGAN MOTOR

SANYO
Serial.print("m");
delay(2000);
}

// mengisi dengan SUMUR

{
Serial.print("n");
//sedang Mengisi AIR
delay(1500);
if
(berat == 2) { while (digitalRead(level_1) == 1) {} goto loncat2
; }
else if (berat == 4) { while (digitalRead(level_2) == 1) {} goto loncat2
; }
else if (berat == 6) { while (digitalRead(level_3) == 1) {} goto loncat2
; }
loncat2:
digitalWrite(valve_pdam, LOW);
// OFF
digitalWrite(valve_air_masuk, LOW); // OFF
digitalWrite(valve_air_bak, LOW);
// OFF
digitalWrite(valve_sumur, LOW);
// OFF
digitalWrite(valve_air_spin, LOW); // OFF
digitalWrite(buzzer, HIGH); delay(500); digitalWrite(buzzer, LOW);

delay(1000);
Serial.print("o");
//selesai isi air
delay(2000);
Serial.print("p");
//mengisi pewangi untuk bilas
delay(3000);
if
(berat == 2) {digitalWrite(valve_pewangi, HIGH); delay(10000);}
else if (berat == 4) {digitalWrite(valve_pewangi, HIGH); delay(14000);}
else if (berat == 6) {digitalWrite(valve_pewangi, HIGH); delay(19000);}
digitalWrite(valve_pewangi, LOW); delay(1000);
// OFF
Serial.print("q"); // Selesai isi pewangi
delay(3000);
Serial.print("r");
//PROSES MEMBILAS tahap 3
for (j = 0; j < putaran/ 2; j++) {
digitalWrite(motor_cuci1,
digitalWrite(motor_cuci2,
digitalWrite(motor_cuci1,
digitalWrite(motor_cuci2,
digitalWrite(motor_cuci1,
digitalWrite(motor_cuci2,
digitalWrite(motor_cuci1,
digitalWrite(motor_cuci2,

LOW);
HIGH); delay(((tunda - 1)/2) * 1500);
HIGH);
HIGH); delay(6000); // STOP SEBENTAR
HIGH);
LOW); delay(((tunda- 1)/2) * 1500);
HIGH);
HIGH); delay(6000); // STOP SEBENTAR

}
{
Serial.print("s");
// membuang air bilasan
delay(1000);
digitalWrite(buzzer, HIGH); delay(500); digitalWrite(buzzer, LOW);
digitalWrite(valve_buang, LOW); //ON
while (digitalRead(sensor_air) == 0) {}
digitalWrite(valve_buang, HIGH); //OFF
Serial.print("t");
// selesai Pembilasan K
E 3
}
Serial.print("z");

//PINDAHKAN KE T.tombol_pe

ras
for (j = 0; j < 4; j++) {
digitalWrite(buzzer, HIGH); delay(1000); digitalWrite(buzzer, LOW); de
lay(1000);
}
}
}
//==== SELESAI BILAS ===========================================================
=====================
while(1){
Serial.print("A"); // TUTUP TABUNG tombol_peras! // microswitch pengam
an harus terhubung bila ditutup //aktif LOW
delay(3000);
Serial.print("B");
// TEKAN SPIN UTK MULAi
delay(4000);
if(digitalRead(tombol_peras) == LOW); {
digitalWrite(motor_spin, HIGH);
//ON
Serial.print("C");
// SENSOR MENGECEK AIR
delay(3000);
if (digitalRead(sensor_air_pdam) == LOW) {
digitalWrite(valve_pdam, HIGH);
// ON
digitalWrite(valve_air_spin, HIGH);
// ON
delay(2000);
digitalWrite(valve_air_masuk, HIGH);
// ON
//KOPLE DANGAN
MOTOR SANYO

digitalWrite(valve_air_bak, LOW);
digitalWrite(valve_sumur, LOW);
Serial.print("D");
delay(2000);
}
else{
digitalWrite(valve_pdam, LOW);
digitalWrite(valve_air_bak, LOW);
digitalWrite(valve_air_spin, HIGH);
digitalWrite(valve_sumur, HIGH);
delay(2000);
Serial.print("E");
delay(3000);
Serial.print("F");

// OFF
// OFF
// membersihkan busa dengan PDAM

// OFF
// OFF
// ON
// ON
// membersihkan busa dengan sumur
//sedang menghilangkan

busa
digitalWrite(valve_air_masuk, HIGH); // ON

//KOPLE DANGAN MOTOR SA

NYO
delay(180000);

//delay waktu bersihin bus

a
digitalWrite(valve_air_masuk, LOW); // OFF

//KOPLE DANGAN MOTOR SA

NYO
digitalWrite(valve_sumur, LOW);
// OFF
digitalWrite(valve_air_spin, LOW); // OFF
delay(3000);
digitalWrite(motor_spin, HIGH);
//jik
a waktu delay habis maka air masuk mati
Serial.print("G");
// TUNGGU PROSES PENGERINGAN
delay(3000);
}
Serial.print("H");
//SENSOR MENGANALISIS KEKERINGAN
while(digitalRead(sensor_spin)== 0){}
delay(20000); {
//sensor real t
ime deteksi air tombol_peras
if(digitalRead(microswitch) == LOW) digitalWrite(motor_spin, HIGH);
//bila keadaan tabung tombol_peras tidak seimbang, dan tutup dibuka ma
ka motor mati
else digitalWrite(motor_spin, LOW);
//OFF
}
digitalWrite(motor_spin,LOW);
//OFF
Serial.print("I");
//Pakaian sudah Kering
delay (1000);
for (j = 0; j < 8; j++) {
digitalWrite(buzzer, HIGH); delay(1000); digitalWrite(buzzer, LOW);delay
(500);
digitalWrite(buzzer, HIGH); delay(1000); digitalWrite(buzzer, LOW);
Serial.print("J");
//AMBIL PAKAIAN ANDA
}
goto awal;
}
}
//======================END==================================
i = 0;
goto awal;
}
else i++;
}
}
void konversi(char data)

nilai = 0;
switch(data) {
case '0' : nilai
case '1' : nilai
case '2' : nilai
case '3' : nilai
case '4' : nilai
case '5' : nilai
case '6' : nilai
case '7' : nilai
case '8' : nilai
case '9' : nilai
return;

=
=
=
=
=
=
=
=
=
=

0;
1;
2;
3;
4;
5;
6;
7;
8;
9;

break;
break;
break;
break;
break;
break;
break;
break;
break;
break;}