#include <Keypad.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 16, 2);
#include<Servo.h>
#define role 9 //role
Servo servo;
#define yled 7 //sarı led
#define kled 6 // kırmızı led
#define buzzer 8
const byte satir = 4; //rows
const byte sutun = 4; //columbs
char sifre[4] = {'1', '2', '3', '4'};
char sifre1[4];
char key;
int i = 0;
char keys[4][4] = {
{'1', '2', '3', 'A'},
{'4', '5', '6', 'B'},
{'7', '8', '9', 'C'},
{'*', '0', '#', 'D'}
};
byte satir_pins[4] = {5, 4, 3, 2};
byte sutun_pins[4] = {A3, A2, A1, A0};
Keypad keypad = Keypad(makeKeymap(keys), satir_pins, sutun_pins, 4, 4);
byte customChar9[8] = {
0b11111,
0b11111,
0b11111,
0b11111,
0b11111,
0b11111,
0b11111,
0b11111
};
byte customChar8[8] = {
0b11110,
0b11110,
0b11110,
0b11110,
0b11110,
0b11110,
0b11110,
0b11110
};
byte customChar7[8] = {
0b11100,
0b11100,
0b11100,
0b11100,
0b11100,
0b11100,
0b11100,
0b11100
};
byte customChar6[8] = {
0b11000,
0b11000,
0b11000,
0b11000,
0b11000,
0b11000,
0b11000,
0b11000
};
byte customChar5[8] = {
0b10000,
0b10000,
0b10000,
0b10000,
0b10000,
0b10000,
0b10000,
0b10000
};
byte customChar4[8] = {
0b00001,
0b00011,
0b00011,
0b00111,
0b00111,
0b01111,
0b01111,
0b11111
};
byte customChar3[8] = {
0b00000,
0b00010,
0b00010,
0b00110,
0b00110,
0b01110,
0b01110,
0b11110
};
byte customChar2[8] = {
0b00000,
0b00000,
0b00000,
0b00100,
0b00100,
0b01100,
0b01100,
0b11100
};
byte customChar1[8] = {
0b00000,
0b00000,
0b00000,
0b00000,
0b00000,
0b01000,
0b01000,
0b11000
};
byte customChar0[8] = {
0b00000,
0b00000,
0b00000,
0b00000,
0b00000,
0b00000,
0b00000,
0b10000
};
void setup() {
pinMode(role, OUTPUT);
servo.attach(13);
pinMode(yled, OUTPUT);
pinMode(buzzer, OUTPUT);
pinMode(kled, OUTPUT);
lcd.createChar(0, customChar0);
lcd.createChar(1, customChar1);
lcd.createChar(2, customChar2);
lcd.createChar(3, customChar3);
lcd.createChar(4, customChar4);
lcd.createChar(5, customChar5);
lcd.createChar(6, customChar6);
lcd.createChar(7, customChar7);
lcd.createChar(8, customChar8);
lcd.createChar(9, customChar9);
lcd.begin(16, 2);
lcd.backlight();
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("GOKTEK OTOMASYON");
for (int i = 1; i <= 13; i++)
{
for (int k = 6; k <= 9; k++)
{
lcd.setCursor(i, 1); lcd.write((uint8_t)k);
delay(100);
}
}
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("MACROHILL");
lcd.setCursor(0, 1);
lcd.print("SIFRELI KAPI");
delay(2000);
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("SIFREYI GIRINIZ:");
Serial.begin(9600);
}
void loop() {
servo.write(0);
digitalWrite(kled,LOW);
digitalWrite(yled,LOW);
char key = keypad.getKey();
if (key)
{
sifre1[i++] = key;
lcd.setCursor(i, 1);
lcd.print("*");
digitalWrite(buzzer,HIGH);
delay(100);
digitalWrite(buzzer,LOW);//
delay(100);
digitalWrite(buzzer,HIGH);
delay(100);
digitalWrite(buzzer,LOW);//
}
if (i == 4)
{ delay(200);
char sifre[4] = {'1', '2', '3', '4'};
if ((strncmp(sifre1, sifre, 4) == 0))
{
lcd.clear();
lcd.setCursor(0, 0);
servo.write(180);
lcd.print("SIFRE DOGRU!");
digitalWrite(yled, HIGH);
digitalWrite(role,HIGH); // //röle pinine high veriyoruz böylece no com ucuna bağladığınız hattan akım geçmez, ama nc com ile bağlantı yaparsanız bu durumda akım geçer.
delay(1000); // 2 Saniye Bekle
digitalWrite(role, LOW); // röle pinine low veriyoruz böylece no com ucuna bağladığınız hattan akım geçer, ama nc com ile bağlantı yaparsanız bu durumda akım geçmez.
delay(1000);
digitalWrite(kled, LOW);
digitalWrite(buzzer, HIGH);
delay(100);
digitalWrite(buzzer, LOW);
delay(100);
digitalWrite(buzzer, HIGH);
delay(100);
digitalWrite(buzzer, LOW);
delay(1000);
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("SIFREYI GIRINIZ");
i = 0;
}
else
{
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("SIFRE YANLIS!!!");
digitalWrite(yled, LOW);
digitalWrite(kled, HIGH);
digitalWrite(buzzer, HIGH);
delay(1000);
digitalWrite(buzzer, LOW);
delay(1000);
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("SIFREYI GIRINIZ");
i = 0;
}
}
}