[TUTORIAL] Proyek Arduino ke 2 Kunci Elektrik dengan Password
Proyek arduino ke 2 kunci elektrik dengan password:
Schematics
Kebutuhan Hardware pada Proyek arduino :
-Keypad 4x4
- Modul LCD 2x16
- Modul Relay 5Vdc
- Solenoid
- Buzzer
- Modul Arduino UNO
- Power supply +9Volt
Source Code Kunci Elektrik dengan Password:
#include <Keypad.h>
#include <LiquidCrystal.h>
#include <EEPROM.h>
unsigned char key,menu,urut;
unsigned char pw1,pw2,pw3,pw4,pw5,pw6,i;
unsigned char pw_kpd1,pw_kpd2,pw_kpd3,pw_kpd4,pw_kpd5,pw_kpd6;
unsigned char cek,cnt;
unsigned char fkpd;
char pw[7],pw_kpd[7];
char s,t;
#include <LiquidCrystal.h>
#include <EEPROM.h>
unsigned char key,menu,urut;
unsigned char pw1,pw2,pw3,pw4,pw5,pw6,i;
unsigned char pw_kpd1,pw_kpd2,pw_kpd3,pw_kpd4,pw_kpd5,pw_kpd6;
unsigned char cek,cnt;
unsigned char fkpd;
char pw[7],pw_kpd[7];
char s,t;
//----------------------------INISIALISASI KONEKSI LCD 2X16
LiquidCrystal lcd(2, 3, 4, 5, 6, 7);
//----------------------------INISIALISASI KONEKSI KEYPAD 4X4
const byte ROWS=4;
const byte COLS=4;
char keys[ROWS][COLS]={
{'1','2','3','A'},
{'4','5','6','B'},
{'7','8','9','C'},
{'*','0','#','D'}
};
byte rowPins[ROWS]={A0,A1,A2,A3};
byte colPins[COLS]={10,11,12,13};
Keypad keypad = Keypad(makeKeymap(keys),rowPins, colPins, ROWS, COLS);
void setup()
{
pinMode(8,OUTPUT);
pinMode(9,OUTPUT);
digitalWrite(8,0);
digitalWrite(9,0);
LiquidCrystal lcd(2, 3, 4, 5, 6, 7);
//----------------------------INISIALISASI KONEKSI KEYPAD 4X4
const byte ROWS=4;
const byte COLS=4;
char keys[ROWS][COLS]={
{'1','2','3','A'},
{'4','5','6','B'},
{'7','8','9','C'},
{'*','0','#','D'}
};
byte rowPins[ROWS]={A0,A1,A2,A3};
byte colPins[COLS]={10,11,12,13};
Keypad keypad = Keypad(makeKeymap(keys),rowPins, colPins, ROWS, COLS);
void setup()
{
pinMode(8,OUTPUT);
pinMode(9,OUTPUT);
digitalWrite(8,0);
digitalWrite(9,0);
lcd.begin(16, 2);
lcd.print(" Kunci Elektrik");
lcd.setCursor(0,1);
lcd.print("Dengan Password");
delay(2000);
//---------------------cek alamat 0
cek=EEPROM.read(0);
if(cek==0xFF){
cek=1;
EEPROM.write(0,'1');
pw1='1'; EEPROM.write(1,'1');
pw2='1'; EEPROM.write(2,'1');
pw3='1'; EEPROM.write(3,'1');
pw4='1'; EEPROM.write(4,'1');
pw5='1'; EEPROM.write(5,'1');
pw6='1'; EEPROM.write(6,'1');
}
else{
pw1=EEPROM.read(1);
pw2=EEPROM.read(2);
pw3=EEPROM.read(3);
pw4=EEPROM.read(4);
lcd.print(" Kunci Elektrik");
lcd.setCursor(0,1);
lcd.print("Dengan Password");
delay(2000);
//---------------------cek alamat 0
cek=EEPROM.read(0);
if(cek==0xFF){
cek=1;
EEPROM.write(0,'1');
pw1='1'; EEPROM.write(1,'1');
pw2='1'; EEPROM.write(2,'1');
pw3='1'; EEPROM.write(3,'1');
pw4='1'; EEPROM.write(4,'1');
pw5='1'; EEPROM.write(5,'1');
pw6='1'; EEPROM.write(6,'1');
}
else{
pw1=EEPROM.read(1);
pw2=EEPROM.read(2);
pw3=EEPROM.read(3);
pw4=EEPROM.read(4);
Untuk lengkapnya Download pada link.
Hasil Proyek
Download
aplikasi arduino
Panduan instalasi driver Arduino UNO di WIN7
Panduan instalasi driver Arduino UNO di WIN8 dan WIN10
DRIVER ARUINO dg IC driver CH340
File Kunci Elektrik dengan Password
0 comments:
Post a Comment