Pada kesempatan kali ini saya akan menjelaskan mengenai bagaimana cara membuat sebuah alat yang menggunakan Arduino untuk kendali kontaktor dan inverter 3 fasa, alat ini berfungsi untuk kendali mesin produksi yang diperuntukkan untuk membuat adonan roti, alat ini memiliki fitur timer dan juga fitur pengubah kecepatan, untuk lebih jelasnya berikut adalah skema dan programnya.
a, Arduino Uno
b. Relay 5V
c. Lcd 16x2 + I2C
d. Program Arduino IDE
#include <Wire.h>
#include <LiquidCrystal_I2C.h> //i2C LCD Library
LiquidCrystal_I2C lcd(0x3F, 16, 2); //library i2c lcd
int relay1 = 4;
int relay2 = 3;
int relay3 = 2;
int relay4 = 1;
int relay5 = 0;
int btset = A0;
int btup = A1;
int btdown = A2;
int btok = A3;
int btsetx = 0;
int btupx = 0;
int btdownx = 0;
int btokx = 0;
int mode = 1;
int tunggu;
int updown;
void setup(){
pinMode(relay1,OUTPUT);
pinMode(relay2,OUTPUT);
pinMode(relay3,OUTPUT);
pinMode(relay4,OUTPUT);
pinMode(relay5,OUTPUT);
pinMode(btset,INPUT_PULLUP);
pinMode(btup,INPUT_PULLUP);
pinMode(btdown,INPUT_PULLUP);
pinMode(btok,INPUT_PULLUP);
lcd.begin(); //set lcd i2c
lcd.noCursor(); //biar gak ada cursor di lcd
lcd.clear(); //clear lcd
}
void loop(){
digitalWrite(relay1,LOW);
digitalWrite(relay2,LOW);
digitalWrite(relay3,LOW);
digitalWrite(relay4,LOW);
digitalWrite(relay5,LOW);
lcd.setCursor(0,0);
lcd.print("1.Setting");
lcd.setCursor(0,1);
lcd.print("2.Mulai");
btsetx = digitalRead(btset);
btokx = digitalRead(btok);
if(btsetx == 0){
delay(200);
lcd.clear();
settingmode();
lcd.clear();
delay(1000);
settunggu();
lcd.clear();
delay(1000);
settimer();
btokx = 1;
lcd.clear();
delay(1000);
}
if(btokx == 0){
delay(200);
lcd.clear();
lcd.setCursor(0,0);
lcd.print("Mode: ");
lcd.print(mode);
lcd.setCursor(0,1);
lcd.print("Timer: ");
lcd.print(tunggu);
lcd.print(" / ");
lcd.print(updown);
if(mode == 1){
digitalWrite(relay1,HIGH);
digitalWrite(relay2,LOW);
digitalWrite(relay3,LOW);
}
if(mode == 2){
digitalWrite(relay1,LOW);
digitalWrite(relay2,HIGH);
digitalWrite(relay3,LOW);
}
if(mode == 3){
digitalWrite(relay1,LOW);
digitalWrite(relay2,LOW);
digitalWrite(relay3,HIGH);
}
mulai();
}
}
void settingmode(){
btsetx = digitalRead(btset);
btokx = digitalRead(btok);
btupx = digitalRead(btup);
btdownx = digitalRead(btdown);
lcd.setCursor(0,0);
lcd.print("Pilih Mode: ");
lcd.print(mode);
if(btupx == 0){
delay(200);
mode++;
}
if(btdownx == 0){
delay(200);
mode--;
}
if(mode > 3){
mode = 1;
}
if(mode < 1){
mode = 3;
}
if(btokx == 0){
delay(200);
return;
}
settingmode();
}
void settunggu(){
btsetx = digitalRead(btset);
btokx = digitalRead(btok);
btupx = digitalRead(btup);
btdownx = digitalRead(btdown);
lcd.setCursor(0,0);
lcd.print("SET TIMER DELAY ");
lcd.setCursor(0,1);
lcd.print(tunggu);
lcd.print(" ");
if(btupx == 0){
delay(200);
tunggu++;
}
if(btdownx == 0){
delay(200);
tunggu--;
}
if(tunggu > 60){
tunggu = 1;
}
if(tunggu < 0){
tunggu = 60;
}
if(btokx == 0){
delay(200);
return;
}
settunggu();
}
void settimer(){
btsetx = digitalRead(btset);
btokx = digitalRead(btok);
btupx = digitalRead(btup);
btdownx = digitalRead(btdown);
lcd.setCursor(0,0);
lcd.print("Timer UP/DOWN ");
lcd.setCursor(0,1);
lcd.print(updown);
lcd.print(" ");
if(btupx == 0){
delay(200);
updown++;
}
if(btdownx == 0){
delay(200);
updown--;
}
if(updown > 6){
updown = 1;
}
if(updown < 0){
updown = 6;
}
if(btokx == 0){
delay(200);
return;
}
settimer();
}
void mulai(){
delay(tunggu * 1000);
digitalWrite(relay4,HIGH);
delay(1000);
digitalWrite(relay4,LOW);
delay(updown * 1000);
digitalWrite(relay5,HIGH);
delay(1000);
digitalWrite(relay5,LOW);
mulai();
}
#include <LiquidCrystal_I2C.h> //i2C LCD Library
LiquidCrystal_I2C lcd(0x3F, 16, 2); //library i2c lcd
int relay1 = 4;
int relay2 = 3;
int relay3 = 2;
int relay4 = 1;
int relay5 = 0;
int btset = A0;
int btup = A1;
int btdown = A2;
int btok = A3;
int btsetx = 0;
int btupx = 0;
int btdownx = 0;
int btokx = 0;
int mode = 1;
int tunggu;
int updown;
void setup(){
pinMode(relay1,OUTPUT);
pinMode(relay2,OUTPUT);
pinMode(relay3,OUTPUT);
pinMode(relay4,OUTPUT);
pinMode(relay5,OUTPUT);
pinMode(btset,INPUT_PULLUP);
pinMode(btup,INPUT_PULLUP);
pinMode(btdown,INPUT_PULLUP);
pinMode(btok,INPUT_PULLUP);
lcd.begin(); //set lcd i2c
lcd.noCursor(); //biar gak ada cursor di lcd
lcd.clear(); //clear lcd
}
void loop(){
digitalWrite(relay1,LOW);
digitalWrite(relay2,LOW);
digitalWrite(relay3,LOW);
digitalWrite(relay4,LOW);
digitalWrite(relay5,LOW);
lcd.setCursor(0,0);
lcd.print("1.Setting");
lcd.setCursor(0,1);
lcd.print("2.Mulai");
btsetx = digitalRead(btset);
btokx = digitalRead(btok);
if(btsetx == 0){
delay(200);
lcd.clear();
settingmode();
lcd.clear();
delay(1000);
settunggu();
lcd.clear();
delay(1000);
settimer();
btokx = 1;
lcd.clear();
delay(1000);
}
if(btokx == 0){
delay(200);
lcd.clear();
lcd.setCursor(0,0);
lcd.print("Mode: ");
lcd.print(mode);
lcd.setCursor(0,1);
lcd.print("Timer: ");
lcd.print(tunggu);
lcd.print(" / ");
lcd.print(updown);
if(mode == 1){
digitalWrite(relay1,HIGH);
digitalWrite(relay2,LOW);
digitalWrite(relay3,LOW);
}
if(mode == 2){
digitalWrite(relay1,LOW);
digitalWrite(relay2,HIGH);
digitalWrite(relay3,LOW);
}
if(mode == 3){
digitalWrite(relay1,LOW);
digitalWrite(relay2,LOW);
digitalWrite(relay3,HIGH);
}
mulai();
}
}
void settingmode(){
btsetx = digitalRead(btset);
btokx = digitalRead(btok);
btupx = digitalRead(btup);
btdownx = digitalRead(btdown);
lcd.setCursor(0,0);
lcd.print("Pilih Mode: ");
lcd.print(mode);
if(btupx == 0){
delay(200);
mode++;
}
if(btdownx == 0){
delay(200);
mode--;
}
if(mode > 3){
mode = 1;
}
if(mode < 1){
mode = 3;
}
if(btokx == 0){
delay(200);
return;
}
settingmode();
}
void settunggu(){
btsetx = digitalRead(btset);
btokx = digitalRead(btok);
btupx = digitalRead(btup);
btdownx = digitalRead(btdown);
lcd.setCursor(0,0);
lcd.print("SET TIMER DELAY ");
lcd.setCursor(0,1);
lcd.print(tunggu);
lcd.print(" ");
if(btupx == 0){
delay(200);
tunggu++;
}
if(btdownx == 0){
delay(200);
tunggu--;
}
if(tunggu > 60){
tunggu = 1;
}
if(tunggu < 0){
tunggu = 60;
}
if(btokx == 0){
delay(200);
return;
}
settunggu();
}
void settimer(){
btsetx = digitalRead(btset);
btokx = digitalRead(btok);
btupx = digitalRead(btup);
btdownx = digitalRead(btdown);
lcd.setCursor(0,0);
lcd.print("Timer UP/DOWN ");
lcd.setCursor(0,1);
lcd.print(updown);
lcd.print(" ");
if(btupx == 0){
delay(200);
updown++;
}
if(btdownx == 0){
delay(200);
updown--;
}
if(updown > 6){
updown = 1;
}
if(updown < 0){
updown = 6;
}
if(btokx == 0){
delay(200);
return;
}
settimer();
}
void mulai(){
delay(tunggu * 1000);
digitalWrite(relay4,HIGH);
delay(1000);
digitalWrite(relay4,LOW);
delay(updown * 1000);
digitalWrite(relay5,HIGH);
delay(1000);
digitalWrite(relay5,LOW);
mulai();
}
e, VIDEO HASILNYA