0% found this document useful (0 votes)
8 views4 pages

Pass based Device Con_MCU

The document is an Arduino sketch for a password-based switching system using a keypad and an LCD display. It allows users to toggle four relays based on a password input, displaying their status on the LCD. The code includes functions for checking the password and updating the relay status messages.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views4 pages

Pass based Device Con_MCU

The document is an Arduino sketch for a password-based switching system using a keypad and an LCD display. It allows users to toggle four relays based on a password input, displaying their status on the LCD. The code includes functions for checking the password and updating the relay status messages.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

#include <Keypad.

h>
#include<LiquidCrystal.h>

LiquidCrystal lcd(13, 12, 11, 10, 9, 8);

#define RLY1 A0
#define RLY2 A1
#define RLY3 A2
#define RLY4 A3

#define Password_Length 5

char u_pass_1[5] = "1234";

char Data[5];
byte data_count = 0;
char customKey;
byte pass_sts = 0;
String msg1, msg2, msg3, msg4;

char hexaKeys[ROWS][COLS] = {
{'1', '2', '3'},
{'4', '5', '6'},
{'7', '8', '9'},
{'*', '0', '#'}
}

byte rowPins[ROWS] = {2, 3, 4, 5};


byte colPins[COLS] = {6, 7, 8};

Keypad customKeypad = Keypad(makeKeymap(hexaKeys), rowPins, colPins,


ROWS, COLS);

void setup(){
pinMode(RLY1, OUTPUT);
pinMode(RLY2, OUTPUT);
pinMode(RLY3, OUTPUT);
pinMode(RLY4, OUTPUT);

lcd.print("Welcome To PASS");
lcd.setCursor(0, 1);
lcd.print("Based Switching SYS");
delay(2000);
}

void loop(){
if (pass_sts == 1){

lcd.setCursor(0,0);
lcd.print("L1:");
lcd.print(msg1);
lcd.print(" L2:");
lcd.print(msg2);
lcd.setCursor(0,1);
lcd.print("L3:");
lcd.print(msg3);
lcd.print(" L4:");
lcd.print(msg4);

customKey = customKeypad.getKey();

if (customKey){

if(customKey == '1'){
digitalWrite(RLY1, !digitalRead(RLY1));
delay(100);
}
else if(customKey == '2'){
digitalWrite(RLY2, !digitalRead(RLY2));
delay(100);
}
else if(customKey == '3'){
digitalWrite(RLY3, !digitalRead(RLY3));
delay(100);
}
else if(customKey == '4'){
digitalWrite(RLY4, !digitalRead(RLY4));
delay(100);
}
else if(customKey == '#'){
pass_sts = 0;
}
update_msg();
}
}
else{
Check_Pass();
}

void update_msg(){

if (digitalRead(RLY1) == 1){
msg1 = "On";
}
else{
msg1 = "Off";
}
if (digitalRead(RLY2) == 1){
msg2 = "On";
}
else{
msg2 = "Off";
}
if (digitalRead(RLY3) == 1){
msg3 = "On";
}
else{
msg3 = "Off";
}
if (digitalRead(RLY4) == 1){
msg4 = "On";
}
else{
msg4 = "Off";
}

void Check_Pass(){
lcd.setCursor(0,0);
lcd.print("Enter PASS-KEY");

customKey = customKeypad.getKey();

if (customKey){
Data[data_count] = customKey;
lcd.setCursor(0,0);
lcd.print("Enter PASS-KEY");
lcd.setCursor(0,1);
lcd.setCursor(data_count,1);
lcd.print(Data[data_count]);
data_count++;
}

if(data_count == Password_Length-1){
lcd.clear();

if(!strcmp(Data, u_pass_1)){
lcd.setCursor(0,0);
lcd.print("Valid USER, OK");
lcd.setCursor(0,1);
delay(2000);
pass_sts = 1;
update_msg();
return;
}
else{
lcd.setCursor(0,0);
lcd.print("KEY NOT MATCHH !");
delay(2000);
update_msg();
return;
}

You might also like