Pada kesempatan kali ini saya akan menjelaskan mengenai bagaimana cara membuat sebuah alat yang berfungsi untuk kendali suatu alat dengan tundaan / delay tertentu, alat ini menggunakan Relay sebagai pemutus / penyambung tegangan input, alat ini sebenarnya untuk kendali tanaman / penyiraman tanaman secara otomatis dengan waktu yang telah di-setting sebelumnya melalui program, alat ini menggunakan mikrokontroller Arduino Mega dengan jumlah relay yang dikendalikan adalah 20 buah. untuk lebih jelasnya berikut adalah skema dan programnya.
a. Arduino Mega
b. Skema Alat Keseluruhan
c Relay Omron
d. Program Arduino IDE
int relay1 = A0;
int relay2 = A1;
int relay3 = A2;
int relay4 = A3;
int relay5 = A4;
int relay6 = A5;
int relay7 = A6;
int relay8 = A7;
int relay9 = A8;
int relay10 = A9;
int relay11 = A10;
int relay12 = A11;
int relay13 = A12;
int relay14 = A13;
int relay15 = A14;
int relay16 = A15;
int relay17 = 53;
int relay18 = 49;
int relay19 = 47;
int relay20 = 45;
void setup(){
pinMode(relay1,OUTPUT);
pinMode(relay2,OUTPUT);
pinMode(relay3,OUTPUT);
pinMode(relay4,OUTPUT);
pinMode(relay5,OUTPUT);
pinMode(relay6,OUTPUT);
pinMode(relay7,OUTPUT);
pinMode(relay8,OUTPUT);
pinMode(relay9,OUTPUT);
pinMode(relay10,OUTPUT);
pinMode(relay11,OUTPUT);
pinMode(relay12,OUTPUT);
pinMode(relay13,OUTPUT);
pinMode(relay14,OUTPUT);
pinMode(relay15,OUTPUT);
pinMode(relay16,OUTPUT);
pinMode(relay17,OUTPUT);
pinMode(relay18,OUTPUT);
pinMode(relay19,OUTPUT);
pinMode(relay20,OUTPUT);
}
void loop(){
digitalWrite(relay1,HIGH);
delay(1000);
digitalWrite(relay1,LOW);
delay(200);
digitalWrite(relay2,HIGH);
delay(1000);
digitalWrite(relay2,LOW);
delay(200);
digitalWrite(relay3,HIGH);
delay(1000);
digitalWrite(relay3,LOW);
delay(200);
digitalWrite(relay4,HIGH);
delay(1000);
digitalWrite(relay4,LOW);
delay(200);
digitalWrite(relay5,HIGH);
delay(1000);
digitalWrite(relay5,LOW);
delay(200);
digitalWrite(relay6,HIGH);
delay(1000);
digitalWrite(relay6,LOW);
delay(200);
digitalWrite(relay7,HIGH);
delay(1000);
digitalWrite(relay7,LOW);
delay(200);
digitalWrite(relay8,HIGH);
delay(1000);
digitalWrite(relay8,LOW);
delay(200);
digitalWrite(relay9,HIGH);
delay(1000);
digitalWrite(relay9,LOW);
delay(200);
digitalWrite(relay10,HIGH);
delay(1000);
digitalWrite(relay10,LOW);
delay(200);
digitalWrite(relay11,HIGH);
delay(1000);
digitalWrite(relay11,LOW);
delay(200);
digitalWrite(relay12,HIGH);
delay(1000);
digitalWrite(relay12,LOW);
delay(200);
digitalWrite(relay13,HIGH);
delay(1000);
digitalWrite(relay13,LOW);
delay(200);
digitalWrite(relay14,HIGH);
delay(1000);
digitalWrite(relay14,LOW);
delay(200);
digitalWrite(relay15,HIGH);
delay(1000);
digitalWrite(relay15,LOW);
delay(200);
digitalWrite(relay16,HIGH);
delay(1000);
digitalWrite(relay16,LOW);
delay(200);
digitalWrite(relay17,HIGH);
delay(1000);
digitalWrite(relay17,LOW);
delay(200);
digitalWrite(relay18,HIGH);
delay(1000);
digitalWrite(relay18,LOW);
delay(200);
digitalWrite(relay19,HIGH);
delay(1000);
digitalWrite(relay19,LOW);
delay(200);
digitalWrite(relay20,HIGH);
delay(1000);
digitalWrite(relay20,LOW);
delay(200);
}
int relay2 = A1;
int relay3 = A2;
int relay4 = A3;
int relay5 = A4;
int relay6 = A5;
int relay7 = A6;
int relay8 = A7;
int relay9 = A8;
int relay10 = A9;
int relay11 = A10;
int relay12 = A11;
int relay13 = A12;
int relay14 = A13;
int relay15 = A14;
int relay16 = A15;
int relay17 = 53;
int relay18 = 49;
int relay19 = 47;
int relay20 = 45;
void setup(){
pinMode(relay1,OUTPUT);
pinMode(relay2,OUTPUT);
pinMode(relay3,OUTPUT);
pinMode(relay4,OUTPUT);
pinMode(relay5,OUTPUT);
pinMode(relay6,OUTPUT);
pinMode(relay7,OUTPUT);
pinMode(relay8,OUTPUT);
pinMode(relay9,OUTPUT);
pinMode(relay10,OUTPUT);
pinMode(relay11,OUTPUT);
pinMode(relay12,OUTPUT);
pinMode(relay13,OUTPUT);
pinMode(relay14,OUTPUT);
pinMode(relay15,OUTPUT);
pinMode(relay16,OUTPUT);
pinMode(relay17,OUTPUT);
pinMode(relay18,OUTPUT);
pinMode(relay19,OUTPUT);
pinMode(relay20,OUTPUT);
}
void loop(){
digitalWrite(relay1,HIGH);
delay(1000);
digitalWrite(relay1,LOW);
delay(200);
digitalWrite(relay2,HIGH);
delay(1000);
digitalWrite(relay2,LOW);
delay(200);
digitalWrite(relay3,HIGH);
delay(1000);
digitalWrite(relay3,LOW);
delay(200);
digitalWrite(relay4,HIGH);
delay(1000);
digitalWrite(relay4,LOW);
delay(200);
digitalWrite(relay5,HIGH);
delay(1000);
digitalWrite(relay5,LOW);
delay(200);
digitalWrite(relay6,HIGH);
delay(1000);
digitalWrite(relay6,LOW);
delay(200);
digitalWrite(relay7,HIGH);
delay(1000);
digitalWrite(relay7,LOW);
delay(200);
digitalWrite(relay8,HIGH);
delay(1000);
digitalWrite(relay8,LOW);
delay(200);
digitalWrite(relay9,HIGH);
delay(1000);
digitalWrite(relay9,LOW);
delay(200);
digitalWrite(relay10,HIGH);
delay(1000);
digitalWrite(relay10,LOW);
delay(200);
digitalWrite(relay11,HIGH);
delay(1000);
digitalWrite(relay11,LOW);
delay(200);
digitalWrite(relay12,HIGH);
delay(1000);
digitalWrite(relay12,LOW);
delay(200);
digitalWrite(relay13,HIGH);
delay(1000);
digitalWrite(relay13,LOW);
delay(200);
digitalWrite(relay14,HIGH);
delay(1000);
digitalWrite(relay14,LOW);
delay(200);
digitalWrite(relay15,HIGH);
delay(1000);
digitalWrite(relay15,LOW);
delay(200);
digitalWrite(relay16,HIGH);
delay(1000);
digitalWrite(relay16,LOW);
delay(200);
digitalWrite(relay17,HIGH);
delay(1000);
digitalWrite(relay17,LOW);
delay(200);
digitalWrite(relay18,HIGH);
delay(1000);
digitalWrite(relay18,LOW);
delay(200);
digitalWrite(relay19,HIGH);
delay(1000);
digitalWrite(relay19,LOW);
delay(200);
digitalWrite(relay20,HIGH);
delay(1000);
digitalWrite(relay20,LOW);
delay(200);
}
e. VIDEO HASILNYA
No comments:
Post a Comment