#include <Keypad.h>
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include <DHT.h>
const byte ROWS = 4;
const byte COLS = 4;
char hexaKeys[ROWS][COLS] = {
{'1', '2', '3', 'A'},
{'4', '5', '6', 'B'},
{'7', '8', '9', 'C'},
{'*', '0', '#', 'D'}
};
byte rowPins[ROWS] = {9, 8, 7, 6};
byte colPins[COLS] = {5, 4, 3, 2};
#define DHTPIN 13
#define DHTTYPE DHT22
Keypad customKeypad = Keypad(makeKeymap(hexaKeys), rowPins, colPins, ROWS, COLS);
LiquidCrystal_I2C lcd(0x27, 16, 2);
DHT dht(DHTPIN, DHTTYPE);
int steps = 200;
byte directionPin = 11;
byte stepPin = 12;
int joy = A0;
String password = "3462";
String chpass = "";
bool passed = false;
bool Made = false;
int IDT = 23;
String M = "S";
String IDTM = "MAN";
int MS = 10;
char currentMode;
void setup(){
lcd.init();
lcd.backlight();
dht.begin();
pinMode(directionPin, OUTPUT);
pinMode(stepPin, OUTPUT);
for(int i = 0; i <= 2; i++){
lcd.setCursor(5, 0);
lcd.print("Loading");
delay(300);
lcd.setCursor(5, 0);
lcd.print("Loading.");
delay(300);
lcd.setCursor(5, 0);
lcd.print("Loading..");
delay(300);
lcd.setCursor(5, 0);
lcd.print("Loading...");
delay(300);
lcd.setCursor(12, 0);
lcd.print(" ");
}
lcd.clear();
}
void loop() {
char keypad = customKeypad.getKey();
int temp = dht.readTemperature();
int joyvalue = analogRead(joy);
if(!passed){
lcd.setCursor(0, 0);
lcd.print("Password: ");
if(keypad){
chpass += keypad;
lcd.setCursor(10, 0);
lcd.print(chpass);
if(chpass.length() == 4){
if(password == chpass){
lcd.clear();
lcd.setCursor(5, 0);
lcd.print("Correct");
delay(500);
passed = true;
lcd.clear();
Made = true;
}
else{
lcd.clear();
lcd.setCursor(5, 0);
lcd.print("Wrong");
delay(500);
passed = false;
lcd.clear();
chpass = "";
}
}
}
}
if(passed && Made){
lcd.setCursor(2,0);
lcd.print("Made By Zeyd");
delay(2500);
Made = false;
lcd.clear();
}
if(passed && !Made){
lcd.setCursor(0,0);
lcd.print("T");
lcd.setCursor(2,0);
lcd.print("IDT");
lcd.setCursor(7,0);
lcd.print("M");
lcd.setCursor(9,0);
lcd.print("IDTM");
lcd.setCursor(13,0);
lcd.print("MS");
lcd.setCursor(0,1);
lcd.print(temp);
lcd.setCursor(2,1);
lcd.print(IDT);
lcd.setCursor(7,1);
lcd.print(M);
lcd.setCursor(9,1);
lcd.print(IDTM);
lcd.setCursor(13,1);
lcd.print(MS);
if(keypad){
lcd.clear();
currentMode = keypad;
}
switch(currentMode){
case 'A':
lcd.clear();
lcd.setCursor(0,0);
lcd.print("T");
lcd.setCursor(2,0);
lcd.print("IDT");
lcd.setCursor(7,0);
lcd.print("M");
lcd.setCursor(9,0);
lcd.print("IDTM");
lcd.setCursor(13,0);
lcd.print("MS");
lcd.setCursor(0,1);
lcd.print(temp);
lcd.setCursor(2,1);
lcd.print(IDT);
lcd.setCursor(7,1);
lcd.print(M);
lcd.setCursor(9,1);
lcd.print(IDTM);
lcd.setCursor(13,1);
lcd.print(MS);
break;
case 'B':
lcd.clear();
lcd.setCursor(6, 0);
lcd.print("TEMP");
lcd.setCursor(14, 0);
lcd.print("IDT");
lcd.setCursor(6, 1);
lcd.print(temp);
lcd.setCursor(14, 1);
lcd.print(IDT);
chane(IDT);
break;
}
}
if(passed){
digitalWrite(directionPin, LOW);
for(int i = 0; i < 200; i++){
digitalWrite(stepPin, HIGH);
delayMicroseconds(20);
digitalWrite(stepPin, LOW);
delay(10);
}
}
}
void chane(int a){
int joyvalue = analogRead(joy);
if(joyvalue == 1023){
a++;
}
else if(joyvalue == 0){
a--;
}
}