Translate

Membuat Alat Kendali Relay dengan Timer Countdown (ON OFF Relay berdasarkan waktu yang diset)

Membuat Alat Kendali Relay dengan Timer Countdown (ON OFF Relay berdasarkan waktu yang diset)


        Pada kesempatan kali ini saya akan menjelaskan mengenai bagaimana cara membuat sebuah alat yang dapat mengendalikan relay berdasarkan input waktu yang kita tentukan sendiri atau setting time, jadi alat ini hanya ON / OFF relay seperti biasa namun relay akan ON sesuai dengan input waktu yang kita inginkan dalam satuan detik, jadi setelah waktu ON relay melebihi dari setting time yang kita tentukan maka relay akan OFF secara otomatis. untuk lebih jelasnya berikut adalah skema dan programnya. 




a. Arduino Uno




b. Relay 5v




c. LCD 20x4 + I2C






d. Program Arduino IDE

#include <Wire.h>
#include <LiquidCrystal_I2C.h>  //i2C LCD Library
LiquidCrystal_I2C lcd(0x3F, 20, 4); //library i2c lcd

int btok = 8;
int btup = 10;
int btdown = 9;
int btset = 13;

int mode = 1;
int passwd;
int btokx = 0;
int btupx = 0;
int btdownx = 0;
int btsetx = 0;

int relay1 = 3;
int relay2 = 4;
int relay3 = 5;
int relay4 = 6;
int relay5 = 7;
int relay6 = 2;

int x1;
int x2;
int x3;
int x4;
int x5;
int x6;
int x7;
int x8;
int x9;
int x10;
int x11;
int x12;
int x13;
int x14;
int x15;
int x16;
int x17;
int x18;
int x19;
int x20;
int x21;
int x22;
int x23;
int x24;

int relay1p = 1;
int relay2p = 0;
int relay3p = A3;
int relay4p = A2;
int relay5p = A1;
int relay6p = A0;

int relay1px = 0;
int relay2px = 0;
int relay3px = 0;
int relay4px = 0;
int relay5px = 0;
int relay6px = 0;

int timer1;
int timer2;
int timer3;
int timer4;
int timer5;
int timer6;
int timer7;
int timer8;
int timer9;
int timer10;
int timer11;
int timer12;
int timer13;
int timer14;
int timer15;
int timer16;
int timer17;
int timer18;
int timer19;
int timer20;
int timer21;
int timer22;
int timer23;
int timer24;

int timer1x;
int timer2x;
int timer3x;
int timer4x;
int timer5x;
int timer6x;
int timer7x;
int timer8x;
int timer9x;
int timer10x;
int timer11x;
int timer12x;
int timer13x;
int timer14x;
int timer15x;
int timer16x;
int timer17x;
int timer18x;
int timer19x;
int timer20x;
int timer21x;
int timer22x;
int timer23x;
int timer24x;


void setup() {
  lcd.begin(); 
  lcd.noCursor(); 
  lcd.clear(); 

pinMode(btok,INPUT_PULLUP);
pinMode(btup,INPUT_PULLUP);
pinMode(btdown,INPUT_PULLUP);
pinMode(btset,INPUT_PULLUP);

pinMode(relay1p,INPUT_PULLUP);
pinMode(relay2p,INPUT_PULLUP);
pinMode(relay3p,INPUT_PULLUP);
pinMode(relay4p,INPUT_PULLUP);
pinMode(relay5p,INPUT_PULLUP);
pinMode(relay6p,INPUT_PULLUP);

pinMode(relay1,OUTPUT);
pinMode(relay2,OUTPUT);
pinMode(relay3,OUTPUT);
pinMode(relay4,OUTPUT);
pinMode(relay5,OUTPUT);
pinMode(relay6,OUTPUT);

}



void loop() {
lcd.setCursor(0,0); 
lcd.print("MENU PILIHAN");
lcd.setCursor(0,1); 
lcd.print("1.START");
lcd.setCursor(0,2); 
lcd.print("2.SETTING");

btsetx = digitalRead(btset);
btokx = digitalRead(btok);

x1 = 0;
x2 = 0;
x3 = 0;
x4 = 0;
x5 = 0;
x6 = 0;
x7 = 0;
x8 = 0;
x9 = 0;
x10 = 0;
x11 = 0;
x12 = 0;
x13 = 0;
x14 = 0;
x15 = 0;
x16 = 0;
x17 = 0;
x18 = 0;
x19 = 0;
x20 = 0;
x21 = 0;
x22 = 0;
x23 = 0;
x24 = 0;

timer1 = timer1x;
timer2 = timer2x;
timer3 = timer3x;
timer4 = timer4x;
timer5 = timer5x;
timer6 = timer6x;
timer7 = timer7x;
timer8 = timer8x;
timer9 = timer9x;
timer10 = timer10x;
timer11 = timer11x;
timer12 = timer12x;
timer13 = timer13x;
timer14 = timer14x;
timer15 = timer15x;
timer16 = timer16x;
timer17 = timer17x;
timer18 = timer18x;
timer19 = timer19x;
timer20 = timer20x;
timer21 = timer21x;
timer22 = timer22x;
timer23 = timer23x;
timer24 = timer24x;

if(btokx == 0){
lcd.clear();
delay(1000);
mulai();
counter();
btsetx = 1;
}

if(btsetx == 0){
delay(200);
lcd.clear();
passwd = 0;
password();
lcd.clear();
delay(1000);
satu();
lcd.clear();
delay(1000);
dua();
lcd.clear();
delay(1000);
tiga();
lcd.clear();
delay(1000);
empat();
lcd.clear();
delay(1000);
lima();
lcd.clear();
delay(1000);
enam();
lcd.clear();
delay(1000);
tujuh();
lcd.clear();
delay(1000);
delapan();
lcd.clear();
delay(1000);
sembilan();
lcd.clear();
delay(1000);
sepuluh();
lcd.clear();
delay(1000);
sebelas();
lcd.clear();
delay(1000);
duabelas();
lcd.clear();
delay(1000);
tigabelas();
lcd.clear();
delay(1000);
empatbelas();
lcd.clear();
delay(1000);
limabelas();
lcd.clear();
delay(1000);
enambelas();
lcd.clear();
delay(1000);
tujuhbelas();
lcd.clear();
delay(1000);
delapanbelas();
lcd.clear();
delay(1000);
sembilanbelas();
lcd.clear();
delay(1000);
duapuluh();
lcd.clear();
delay(1000);
duapuluhsatu();
lcd.clear();
delay(1000);
duapuluhdua();
lcd.clear();
delay(1000);
duapuluhtiga();
lcd.clear();
delay(1000);
duapuluhempat();
lcd.clear();
}

}




void counter(){

lcd.setCursor(10,3); 
lcd.print("  CUCIAN="); 
lcd.print(mode); 

btdownx = digitalRead(btdown);

if(btdownx == 0){
lcd.clear();
delay(1000);
return;
}

relay1px = digitalRead(relay1p);
relay2px = digitalRead(relay2p);
relay3px = digitalRead(relay3p);
relay4px = digitalRead(relay4p);
relay5px = digitalRead(relay5p);
relay6px = digitalRead(relay6p);


if((relay1px == 0)&&(mode == 1)&&(timer1 > 0)&&(x1 == 0)){
 x1 = 1;
digitalWrite(relay1,HIGH);
}
if(x1 == 1){
lcd.setCursor(0,0); 
lcd.print(timer1); 
lcd.print("          "); 
timer1--;
if(timer1 <= 0){
timer1 = 0;
digitalWrite(relay1,LOW);
}
}

if((relay2px == 0)&&(mode == 1)&&(timer2 > 0)&&(x2 == 0)){
x2 = 1;
digitalWrite(relay2,HIGH);
}
if(x2 == 1){
lcd.setCursor(0,1); 
lcd.print(timer2); 
lcd.print("          "); 
timer2--;
if(timer2 <= 0){
timer2 = 0;
digitalWrite(relay2,LOW);
}
}


if((relay3px == 0)&&(mode == 1)&&(timer3 > 0)&&(x3 == 0)){
x3 = 1;
digitalWrite(relay3,HIGH);
}
if(x3 == 1){
lcd.setCursor(0,2); 
lcd.print(timer3); 
lcd.print("          ");
timer3--;
if(timer3 <= 0){
timer3 = 0;
digitalWrite(relay3,LOW);
}
}



if((relay4px == 0)&&(mode == 1)&&(timer4 > 0)&&(x4 == 0)){
x4 = 1;
digitalWrite(relay4,HIGH);
}
if(x4 == 1){
lcd.setCursor(0,3); 
lcd.print(timer4); 
lcd.print("          ");
timer4--;
if(timer4 <= 0){
timer4 = 0;
digitalWrite(relay4,LOW);
}
}



if((relay5px == 0)&&(mode == 1)&&(timer5 > 0)&&(x5 == 0)){
x5 = 1;
digitalWrite(relay5,HIGH);
}
if(x5 == 1){
lcd.setCursor(10,0); 
lcd.print(timer5); 
lcd.print("          ");
timer5--;
if(timer5 <= 0){
timer5 = 0;
digitalWrite(relay5,LOW);
}
}





if((relay6px == 0)&&(mode == 1)&&(timer6 > 0)&&(x6 == 0)){
x6 = 1;
digitalWrite(relay6,HIGH);
}
if(x6 == 1){
lcd.setCursor(10,1); 
lcd.print(timer6); 
lcd.print("          ");
timer6--;
if(timer6 <= 0){
timer6 = 0;
digitalWrite(relay6,LOW);
}
}
//============================================================

if((relay1px == 0)&&(mode == 2)&&(timer7 > 0)&&(x7 == 0 )){
x7 = 1;
digitalWrite(relay1,HIGH);
}
if(x7 == 1){
lcd.setCursor(0,0); 
lcd.print(timer7); 
lcd.print("          ");
timer7--;
if(timer7 <= 0){
timer7 = 0;
digitalWrite(relay1,LOW);
}
}



if((relay2px == 0)&&(mode == 2)&&(timer8 > 0)&&(x8 == 0)){
x8 = 1;
digitalWrite(relay2,HIGH);
}
if(x8 == 1){
lcd.setCursor(0,1); 
lcd.print(timer8); 
lcd.print("          ");
timer8--;
if(timer8 <= 0){
timer8 = 0;
digitalWrite(relay2,LOW);
}
}




if((relay3px == 0)&&(mode == 2)&&(timer9 > 0)&&(x9 == 0)){
x9 = 1;
digitalWrite(relay3,HIGH);
}
if(x9 == 1){
lcd.setCursor(0,2); 
lcd.print(timer9); 
lcd.print("          ");
timer9--;
if(timer9 <= 0){
timer9 = 0;
digitalWrite(relay3,LOW);
}
}


if((relay4px == 0)&&(mode == 2)&&(timer10 > 0)&&(x10 == 0)){
x10 = 1;
digitalWrite(relay4,HIGH);
}
if(x10 == 1){
lcd.setCursor(0,3); 
lcd.print(timer10); 
lcd.print("          ");
timer10--;
if(timer10 <= 0){
timer10 = 0;
digitalWrite(relay4,LOW);
}
}


if((relay5px == 0)&&(mode == 2)&&(timer11 > 0)&&(x11 == 0)){
x11 = 1;
digitalWrite(relay5,HIGH);
}
if(x11 == 1){
lcd.setCursor(10,0); 
lcd.print(timer11); 
lcd.print("          ");
timer11--;
if(timer11 <= 0){
timer11 = 0;
digitalWrite(relay5,LOW);
}
}


if((relay6px == 0)&&(mode == 2)&&(timer12 > 0)&&(x12 == 0)){
x12 = 1;
digitalWrite(relay6,HIGH);
}
if(x12 == 1){
lcd.setCursor(10,1); 
lcd.print(timer12); 
lcd.print("          ");
timer12--;
if(timer12 <= 0){
timer12 = 0;
digitalWrite(relay6,LOW);
}
}

//====================================================================
if((relay1px == 0)&&(mode == 3)&&(timer13 > 0)&&(x13 == 0)){
x13 = 1;
digitalWrite(relay1,HIGH);
}
if(x13 == 1){
lcd.setCursor(0,0); 
lcd.print(timer13); 
lcd.print("          ");  
timer13--;
if(timer13 <= 0){
timer13 = 0;
digitalWrite(relay1,LOW);
}
}



if((relay2px == 0)&&(mode == 3)&&(timer14 > 0)&&(x14 == 0)){
x14 = 1;
digitalWrite(relay2,HIGH);
}
if(x14 == 1){
lcd.setCursor(0,1); 
lcd.print(timer14); 
lcd.print("          "); 
timer14--;
if(timer14 <= 0){
timer14 = 0;
digitalWrite(relay2,LOW);
}
}


if((relay3px == 0)&&(mode == 3)&&(timer15 > 0)&&(x15 == 0)){
x15 = 1;
digitalWrite(relay3,HIGH);
}
if(x15 == 1){
lcd.setCursor(0,2); 
lcd.print(timer15); 
lcd.print("          ");
timer15--;
if(timer15 <= 0){
timer15 = 0;
digitalWrite(relay3,LOW);
}
}




if((relay4px == 0)&&(mode == 3)&&(timer16 > 0)&&(x16 == 0)){
x16 = 1;
digitalWrite(relay4,HIGH);
}
if(x16 == 1){
lcd.setCursor(0,3); 
lcd.print(timer16); 
lcd.print("          ");
timer16--;
if(timer16 <= 0){
timer16 = 0;
digitalWrite(relay4,LOW);
}
}


if((relay5px == 0)&&(mode == 3)&&(timer17 > 0)&&(x17 == 0)){
x17 = 1;
digitalWrite(relay5,HIGH);
}
if(x17 == 1){
lcd.setCursor(10,0); 
lcd.print(timer17); 
lcd.print("          ");
timer17--;
if(timer17 <= 0){
timer17 = 0;
digitalWrite(relay5,LOW);
}
}

if((relay6px == 0)&&(mode == 3)&&(timer18 > 0)&&(x18 == 0)){
x18 = 1;
digitalWrite(relay6,HIGH);
}
if(x18 == 1){
lcd.setCursor(10,1); 
lcd.print(timer18); 
lcd.print("          ");
timer18--;
if(timer18 <= 0){
timer18 = 0;
digitalWrite(relay6,LOW);
}
}
//==================================================================
if((relay1px == 0)&&(mode == 4)&&(timer19 > 0)&&(x19 == 0)){
x19 = 1; 
digitalWrite(relay1,HIGH);
}
if(x19 == 1){
lcd.setCursor(0,0); 
lcd.print(timer19); 
lcd.print("          ");
timer19--;
if(timer19 <= 0){
timer19 = 0;
digitalWrite(relay1,LOW);
}
}



if((relay2px == 0)&&(mode == 4)&&(timer20 > 0)&&(x20 == 0)){
x20 = 1;
digitalWrite(relay2,HIGH);
}
if(x20 == 1){
lcd.setCursor(0,1); 
lcd.print(timer20); 
lcd.print("          ");
timer20--;
if(timer20 <= 0){
timer20 = 0;
digitalWrite(relay2,LOW);
}
}


if((relay3px == 0)&&(mode == 4)&&(timer21 > 0)&&(x21 == 0)){
x21 = 1;
digitalWrite(relay3,HIGH);
}
if(x21 == 1){
lcd.setCursor(0,2); 
lcd.print(timer21); 
lcd.print("          ");
timer21--;
if(timer21 <= 0){
timer21 = 0;
digitalWrite(relay3,LOW);
}
}


if((relay4px == 0)&&(mode == 4)&&(timer22 > 0)&&(x22 == 0)){
x22 = 1;
digitalWrite(relay4,HIGH);
}
if(x22 == 1){
lcd.setCursor(0,3); 
lcd.print(timer22); 
lcd.print("          ");
timer22--;
if(timer22 <= 0){
timer22 = 0;
digitalWrite(relay4,LOW);
}
}


if((relay5px == 0)&&(mode == 4)&&(timer23 > 0)&&(x23 == 0)){
x23 = 1;
digitalWrite(relay5,HIGH);
}
if(x23 == 1){
lcd.setCursor(10,0); 
lcd.print(timer23); 
lcd.print("          ");
timer23--;
if(timer23 <= 0){
timer23 = 0;
digitalWrite(relay5,LOW);
}
}

if((relay6px == 0)&&(mode == 4)&&(timer24 > 0)&&(x24 == 0)){
x24 = 1;
digitalWrite(relay6,HIGH);
}
if(x24 == 1){
lcd.setCursor(10,1); 
lcd.print(timer24); 
lcd.print("          ");
timer24--;
if(timer24 <= 0){
timer24 = 0;
digitalWrite(relay6,LOW);
}
}


delay(1000);  
counter();
}










void mulai(){
  
  btsetx = digitalRead(btset);
  
  if(btsetx == 0){
  lcd.clear();
  delay(1000);  
  return;
  }

btupx = digitalRead(btup);
btdownx = digitalRead(btdown);

lcd.setCursor(0,0); 
lcd.print("CUCIAN=");
lcd.print(mode);

if(btupx == 0){
  delay(200);
mode++;
}

if(btdownx == 0){
  delay(200);
mode--;
}

if(mode < 1){
mode = 1;
}

if(mode > 4){
mode = 4;
}


if(mode == 1){
lcd.setCursor(0,1); 
lcd.print(timer1);
lcd.print(" ");
lcd.print(timer2);
lcd.print(" ");
lcd.print(timer3);
lcd.print(" ");
lcd.print(timer4);
lcd.print(" ");
lcd.print(timer5);
lcd.print(" ");
lcd.print(timer6);
lcd.print("           ");
}

if(mode == 2){
lcd.setCursor(0,1); 
lcd.print(timer7);
lcd.print(" ");
lcd.print(timer8);
lcd.print(" ");
lcd.print(timer9);
lcd.print(" ");
lcd.print(timer10);
lcd.print(" ");
lcd.print(timer11);
lcd.print(" ");
lcd.print(timer12);
lcd.print("           ");
}

if(mode == 3){
lcd.setCursor(0,1); 
lcd.print(timer13);
lcd.print(" ");
lcd.print(timer14);
lcd.print(" ");
lcd.print(timer15);
lcd.print(" ");
lcd.print(timer16);
lcd.print(" ");
lcd.print(timer17);
lcd.print(" ");
lcd.print(timer18);
lcd.print("           ");
}

if(mode == 4){
lcd.setCursor(0,1); 
lcd.print(timer19);
lcd.print(" ");
lcd.print(timer20);
lcd.print(" ");
lcd.print(timer21);
lcd.print(" ");
lcd.print(timer22);
lcd.print(" ");
lcd.print(timer23);
lcd.print(" ");
lcd.print(timer24);
lcd.print("           ");


mulai();
}


void satu(){

btsetx = digitalRead(btset);
btupx = digitalRead(btup);
btdownx = digitalRead(btdown);
btokx = digitalRead(btok);

lcd.setCursor(0,0); 
lcd.print("SET TIMER RELAY 1/1");
lcd.setCursor(0,1); 
lcd.print("Detik: ");
lcd.print(timer1);
lcd.print("        ");


if(btupx == 0){
delay(200);
timer1++;
}

if(btdownx == 0){
delay(200);
timer1--;
}


if(timer1 < 0){
timer1 = 0;
}

if(btokx == 0){
delay(200);
timer1x = timer1;
return;
}

satu();
}




void dua(){

btsetx = digitalRead(btset);
btupx = digitalRead(btup);
btdownx = digitalRead(btdown);
btokx = digitalRead(btok);

lcd.setCursor(0,0); 
lcd.print("SET TIMER RELAY 2/1");
lcd.setCursor(0,1); 
lcd.print("Detik: ");
lcd.print(timer2);
lcd.print("        ");


if(btupx == 0){
delay(200);
timer2++;
}

if(btdownx == 0){
delay(200);
timer2--;
}

if(timer2 < 0){
timer2 = 0;
}

if(btokx == 0){
delay(200);
timer2x = timer2;
return;
}

dua();
}




void tiga(){

btsetx = digitalRead(btset);
btupx = digitalRead(btup);
btdownx = digitalRead(btdown);
btokx = digitalRead(btok);

lcd.setCursor(0,0); 
lcd.print("SET TIMER RELAY 3/1");
lcd.setCursor(0,1); 
lcd.print("Detik: ");
lcd.print(timer3);
lcd.print("        ");


if(btupx == 0){
delay(200);
timer3++;
}

if(btdownx == 0){
delay(200);
timer3--;
}

if(timer3 < 0){
timer3 = 0;
}

if(btokx == 0){
delay(200);
timer3x = timer3;
return;
}

tiga();
}




void empat(){

btsetx = digitalRead(btset);
btupx = digitalRead(btup);
btdownx = digitalRead(btdown);
btokx = digitalRead(btok);

lcd.setCursor(0,0); 
lcd.print("SET TIMER RELAY 4/1");
lcd.setCursor(0,1); 
lcd.print("Detik: ");
lcd.print(timer4);
lcd.print("        ");


if(btupx == 0){
delay(200);
timer4++;
}

if(btdownx == 0){
delay(200);
timer4--;
}

if(timer4 < 0){
timer4 = 0;
}

if(btokx == 0){
delay(200);
timer4x = timer4;
return;
}

empat();
}





void lima(){

btsetx = digitalRead(btset);
btupx = digitalRead(btup);
btdownx = digitalRead(btdown);
btokx = digitalRead(btok);

lcd.setCursor(0,0); 
lcd.print("SET TIMER RELAY 5/1");
lcd.setCursor(0,1); 
lcd.print("Detik: ");
lcd.print(timer5);
lcd.print("        ");


if(btupx == 0){
delay(200);
timer5++;
}

if(btdownx == 0){
delay(200);
timer5--;
}

if(timer5 < 0){
timer5 = 0;
}

if(btokx == 0){
delay(200);
timer5x = timer5;
return;
}

lima();
}





void enam(){

btsetx = digitalRead(btset);
btupx = digitalRead(btup);
btdownx = digitalRead(btdown);
btokx = digitalRead(btok);

lcd.setCursor(0,0); 
lcd.print("SET TIMER RELAY 6/1");
lcd.setCursor(0,1); 
lcd.print("Detik: ");
lcd.print(timer6);
lcd.print("        ");


if(btupx == 0){
delay(200);
timer6++;
}

if(btdownx == 0){
delay(200);
timer6--;
}

if(timer6 < 0){
timer6 = 0;
}

if(btokx == 0){
delay(200);
timer6x = timer6;
return;
}

enam();
}


//================================================================================


void tujuh(){

btsetx = digitalRead(btset);
btupx = digitalRead(btup);
btdownx = digitalRead(btdown);
btokx = digitalRead(btok);

lcd.setCursor(0,0); 
lcd.print("SET TIMER RELAY 1/2");
lcd.setCursor(0,1); 
lcd.print("Detik: ");
lcd.print(timer7);
lcd.print("        ");


if(btupx == 0){
delay(200);
timer7++;
}

if(btdownx == 0){
delay(200);
timer7--;
}

if(timer7 < 0){
timer7 = 0;
}

if(btokx == 0){
delay(200);
timer7x = timer7;
return;
}

tujuh();
}




void delapan(){

btsetx = digitalRead(btset);
btupx = digitalRead(btup);
btdownx = digitalRead(btdown);
btokx = digitalRead(btok);

lcd.setCursor(0,0); 
lcd.print("SET TIMER RELAY 2/2");
lcd.setCursor(0,1); 
lcd.print("Detik: ");
lcd.print(timer8);
lcd.print("        ");


if(btupx == 0){
delay(200);
timer8++;
}

if(btdownx == 0){
delay(200);
timer8--;
}

if(timer8 < 0){
timer8 = 0;
}

if(btokx == 0){
delay(200);
timer8x = timer8;
return;
}

delapan();
}




void sembilan(){

btsetx = digitalRead(btset);
btupx = digitalRead(btup);
btdownx = digitalRead(btdown);
btokx = digitalRead(btok);

lcd.setCursor(0,0); 
lcd.print("SET TIMER RELAY 3/2");
lcd.setCursor(0,1); 
lcd.print("Detik: ");
lcd.print(timer9);
lcd.print("        ");


if(btupx == 0){
delay(200);
timer9++;
}

if(btdownx == 0){
delay(200);
timer9--;
}

if(timer9 < 0){
timer9 = 0;
}

if(btokx == 0){
delay(200);
timer9x = timer9;
return;
}

sembilan();
}




void sepuluh(){

btsetx = digitalRead(btset);
btupx = digitalRead(btup);
btdownx = digitalRead(btdown);
btokx = digitalRead(btok);

lcd.setCursor(0,0); 
lcd.print("SET TIMER RELAY 4/2");
lcd.setCursor(0,1); 
lcd.print("Detik: ");
lcd.print(timer10);
lcd.print("        ");


if(btupx == 0){
delay(200);
timer10++;
}

if(btdownx == 0){
delay(200);
timer10--;
}

if(timer10 < 0){
timer10 = 0;
}

if(btokx == 0){
delay(200);
timer10x = timer10;
return;
}

sepuluh();
}





void sebelas(){

btsetx = digitalRead(btset);
btupx = digitalRead(btup);
btdownx = digitalRead(btdown);
btokx = digitalRead(btok);

lcd.setCursor(0,0); 
lcd.print("SET TIMER RELAY 5/2");
lcd.setCursor(0,1); 
lcd.print("Detik: ");
lcd.print(timer11);
lcd.print("        ");


if(btupx == 0){
delay(200);
timer11++;
}

if(btdownx == 0){
delay(200);
timer11--;
}

if(timer11 < 0){
timer11 = 0;
}

if(btokx == 0){
delay(200);
timer11x = timer11;
return;
}

sebelas();
}





void duabelas(){

btsetx = digitalRead(btset);
btupx = digitalRead(btup);
btdownx = digitalRead(btdown);
btokx = digitalRead(btok);

lcd.setCursor(0,0); 
lcd.print("SET TIMER RELAY 6/2");
lcd.setCursor(0,1); 
lcd.print("Detik: ");
lcd.print(timer12);
lcd.print("        ");


if(btupx == 0){
delay(200);
timer12++;
}

if(btdownx == 0){
delay(200);
timer12--;
}

if(timer12 < 0){
timer12 = 0;
}

if(btokx == 0){
delay(200);
timer12x = timer12;
return;
}

duabelas();
}

//===========================================================================



void tigabelas(){

btsetx = digitalRead(btset);
btupx = digitalRead(btup);
btdownx = digitalRead(btdown);
btokx = digitalRead(btok);

lcd.setCursor(0,0); 
lcd.print("SET TIMER RELAY 1/3");
lcd.setCursor(0,1); 
lcd.print("Detik: ");
lcd.print(timer13);
lcd.print("        ");


if(btupx == 0){
delay(200);
timer13++;
}

if(btdownx == 0){
delay(200);
timer13--;
}

if(timer13 < 0){
timer13 = 0;
}

if(btokx == 0){
delay(200);
timer13x = timer13;
return;
}

tigabelas();
}




void empatbelas(){

btsetx = digitalRead(btset);
btupx = digitalRead(btup);
btdownx = digitalRead(btdown);
btokx = digitalRead(btok);

lcd.setCursor(0,0); 
lcd.print("SET TIMER RELAY 2/3");
lcd.setCursor(0,1); 
lcd.print("Detik: ");
lcd.print(timer14);
lcd.print("        ");


if(btupx == 0){
delay(200);
timer14++;
}

if(btdownx == 0){
delay(200);
timer14--;
}

if(timer14 < 0){
timer14 = 0;
}

if(btokx == 0){
delay(200);
timer14x = timer14;
return;
}

empatbelas();
}




void limabelas(){

btsetx = digitalRead(btset);
btupx = digitalRead(btup);
btdownx = digitalRead(btdown);
btokx = digitalRead(btok);

lcd.setCursor(0,0); 
lcd.print("SET TIMER RELAY 3/3");
lcd.setCursor(0,1); 
lcd.print("Detik: ");
lcd.print(timer15);
lcd.print("        ");


if(btupx == 0){
delay(200);
timer15++;
}

if(btdownx == 0){
delay(200);
timer15--;
}

if(timer15 < 0){
timer15 = 0;
}

if(btokx == 0){
delay(200);
timer15x = timer15;
return;
}

limabelas();
}




void enambelas(){

btsetx = digitalRead(btset);
btupx = digitalRead(btup);
btdownx = digitalRead(btdown);
btokx = digitalRead(btok);

lcd.setCursor(0,0); 
lcd.print("SET TIMER RELAY 4/3");
lcd.setCursor(0,1); 
lcd.print("Detik: ");
lcd.print(timer16);
lcd.print("        ");


if(btupx == 0){
delay(200);
timer16++;
}

if(btdownx == 0){
delay(200);
timer16--;
}

if(timer16 < 0){
timer16 = 0;
}

if(btokx == 0){
delay(200);
timer16x = timer16;
return;
}

enambelas();
}





void tujuhbelas(){

btsetx = digitalRead(btset);
btupx = digitalRead(btup);
btdownx = digitalRead(btdown);
btokx = digitalRead(btok);

lcd.setCursor(0,0); 
lcd.print("SET TIMER RELAY 5/3");
lcd.setCursor(0,1); 
lcd.print("Detik: ");
lcd.print(timer17);
lcd.print("        ");

if(btupx == 0){
delay(200);
timer17++;
}

if(btdownx == 0){
delay(200);
timer17--;
}

if(timer17 < 0){
timer17 = 0;
}

if(btokx == 0){
delay(200);
timer17x = timer17;
return;
}

tujuhbelas();
}





void delapanbelas(){

btsetx = digitalRead(btset);
btupx = digitalRead(btup);
btdownx = digitalRead(btdown);
btokx = digitalRead(btok);

lcd.setCursor(0,0); 
lcd.print("SET TIMER RELAY 6/3");
lcd.setCursor(0,1); 
lcd.print("Detik: ");
lcd.print(timer18);
lcd.print("        ");


if(btupx == 0){
delay(200);
timer18++;
}

if(btdownx == 0){
delay(200);
timer18--;
}

if(timer18 < 0){
timer18 = 0;
}

if(btokx == 0){
delay(200);
timer18x = timer18;
return;
}

delapanbelas();
}

//===========================================================================




void sembilanbelas(){

btsetx = digitalRead(btset);
btupx = digitalRead(btup);
btdownx = digitalRead(btdown);
btokx = digitalRead(btok);

lcd.setCursor(0,0); 
lcd.print("SET TIMER RELAY 1/4");
lcd.setCursor(0,1); 
lcd.print("Detik: ");
lcd.print(timer19);
lcd.print("        ");


if(btupx == 0){
delay(200);
timer19++;
}

if(btdownx == 0){
delay(200);
timer19--;
}

if(timer19 < 0){
timer19 = 0;
}

if(btokx == 0){
delay(200);
timer19x = timer19;
return;
}

sembilanbelas();
}




void duapuluh(){

btsetx = digitalRead(btset);
btupx = digitalRead(btup);
btdownx = digitalRead(btdown);
btokx = digitalRead(btok);

lcd.setCursor(0,0); 
lcd.print("SET TIMER RELAY 2/4");
lcd.setCursor(0,1); 
lcd.print("Detik: ");
lcd.print(timer20);
lcd.print("        ");


if(btupx == 0){
delay(200);
timer20++;
}

if(btdownx == 0){
delay(200);
timer20--;
}

if(timer20 < 0){
timer20 = 0;
}

if(btokx == 0){
delay(200);
timer20x = timer20;
return;
}

duapuluh();
}




void duapuluhsatu(){

btsetx = digitalRead(btset);
btupx = digitalRead(btup);
btdownx = digitalRead(btdown);
btokx = digitalRead(btok);

lcd.setCursor(0,0); 
lcd.print("SET TIMER RELAY 3/4");
lcd.setCursor(0,1); 
lcd.print("Detik: ");
lcd.print(timer21);
lcd.print("        ");


if(btupx == 0){
delay(200);
timer21++;
}

if(btdownx == 0){
delay(200);
timer21--;
}

if(timer21 < 0){
timer21 = 0;
}

if(btokx == 0){
delay(200);
timer21x = timer21;
return;
}

duapuluhsatu();
}




void duapuluhdua(){

btsetx = digitalRead(btset);
btupx = digitalRead(btup);
btdownx = digitalRead(btdown);
btokx = digitalRead(btok);

lcd.setCursor(0,0); 
lcd.print("SET TIMER RELAY 4/4");
lcd.setCursor(0,1); 
lcd.print("Detik: ");
lcd.print(timer22);
lcd.print("        ");


if(btupx == 0){
delay(200);
timer22++;
}

if(btdownx == 0){
delay(200);
timer22--;
}

if(timer22 < 0){
timer22 = 0;
}

if(btokx == 0){
delay(200);
timer22x = timer22;
return;
}

duapuluhdua();
}





void duapuluhtiga(){

btsetx = digitalRead(btset);
btupx = digitalRead(btup);
btdownx = digitalRead(btdown);
btokx = digitalRead(btok);

lcd.setCursor(0,0); 
lcd.print("SET TIMER RELAY 5/4");
lcd.setCursor(0,1); 
lcd.print("Detik: ");
lcd.print(timer23);
lcd.print("        ");

if(btupx == 0){
delay(200);
timer23++;
}

if(btdownx == 0){
delay(200);
timer23--;
}

if(timer23 < 0){
timer23 = 0;
}

if(btokx == 0){
delay(200);
timer23x = timer23;
return;
}

duapuluhtiga();
}





void duapuluhempat(){

btsetx = digitalRead(btset);
btupx = digitalRead(btup);
btdownx = digitalRead(btdown);
btokx = digitalRead(btok);

lcd.setCursor(0,0); 
lcd.print("SET TIMER RELAY 6/4");
lcd.setCursor(0,1); 
lcd.print("Detik: ");
lcd.print(timer24);
lcd.print("        ");


if(btupx == 0){
delay(200);
timer24++;
}

if(btdownx == 0){
delay(200);
timer24--;
}

if(timer24 < 0){
timer24 = 0;
}

if(btokx == 0){
delay(200);
timer24x = timer24;
return;
}

duapuluhempat();
}

//===========================================================================



void password(){

btsetx = digitalRead(btset);
btupx = digitalRead(btup);
btdownx = digitalRead(btdown);
btokx = digitalRead(btok);

lcd.setCursor(0,0); 
lcd.print("PASSWORD= "); 
lcd.print(passwd);
lcd.print("        ");


if(btupx == 0){
delay(200);
passwd++;
}

if(btdownx == 0){
delay(200);
passwd--;
}

if(passwd < 0){
passwd = 0;
}

if((btokx == 0)&&(passwd == 125)){
delay(200);
return;
}

password();
}








e. VIDEO HASILNYA












No comments:

Post a Comment