在這篇文章中,我們將構建一個基于密碼的電源ON/OFF開關電路,只有在輸入正確的密碼時,它才能打開和關閉交流電源。這可以防止當前可能正在使用高壓線路和設備的技術人員觸電的危險。
公用電源的密碼保護至關重要
對于任何電工或技術人員來說,最大的噩夢是某人意外激活交流線路,這可能會在眨眼間殺死或對身體器官造成致命損害。
這種受密碼保護的電源開/關開關電路可防止此類不幸事件,并允許技術人員通過輸入正確的密碼而不僅僅是翻轉杠桿來安全地打開交流電源。
該項目提供了更改存儲在Arduino微控制器EEPROM中的密碼的功能。
人體甚至動物身體都有自己的電氣系統,這有助于將信息從身體的一個部位發送到另一個部位。信息以具有可測量幅度和頻率的電信號形式發送。它還有助于收縮和放松肌肉,例如我們的心臟。
有趣的事實:心臟有一個多諧振蕩器,稱為“SA節點”或“竇房”;控制心率。如果竇房衰竭,我們必須使用起搏器將外部電信號施加到心臟。
我們身體現有電信號的任何激增都會使我們失去對自己身體部位的控制。這就是為什么人們在接觸開放的帶電電線時會感到卡住和癱瘓的原因。
我們的身體有合理的電阻和良好的電導率。我們知道,任何有電阻的元件在電流通過時都會產生熱量。
這也適用于人體;熱量會損害器官,并可能導致血液沸騰。如果他/她觸電的時間足夠長,這個人遲早可能會死。
該項目由LCD顯示屏,4 x 3字母數字鍵盤,狀態LED和繼電器組成。
Arduino 和 LCD 連接的原理圖:
顯示器連接到 arduino 的模擬引腳,從 A0 到 A5。顯示器異常連接到模擬引腳(其功能與連接到數字引腳相同),因此鍵盤可以連接到數字引腳(從
2 到 9)。
使用 10 K 歐姆電位計調整顯示對比度。
鍵盤連接:
鍵盤有 8 根電纜,應連接到 Arduino,從引腳 #2 到引腳
#9。鍵盤最左邊的電線必須轉到引腳#9,并將鍵盤的下一個右線連接到引腳#8,7,6,5,4,3,2,鍵盤的最后一根或最右邊的電線必須連接到引腳#2。
其余電氣連接:
您需要從以下鏈接下載并添加鍵盤庫:github.com/Chris--A/Keypad 在編譯代碼之前。
Arduino微控制器的EEPROM最初會存儲一些隨機值。我們必須重置為零,這樣我們的主程序就不會混淆。要將EEPROM值設置為零,請先上傳以下程序,然后再上傳主程序。
重置EEPROM的程序(首先上傳):
//------------------Program Developed by R.GIRISH------------------//
#include《EEPROM.h》
int address = -1;
int value = 0;
int i = 0;
int j = 0;
int k = 0;
void setup()
{
Serial.begin(9600);
Serial.println(“Reading EEPROM:”);
for(i = 0; i《10; i++)
{
Serial.println(EEPROM.read(i));
}
Serial.println(“Wrting null value:”);
for(j = 0; j《10; j++)
{
address = address + 1;
EEPROM.write(address, value);
}
for(k = 0; k《10; k++)
{
Serial.println(EEPROM.read(i));
}
Serial.println(“Done!!!”);
}
void loop()
{
// Do nothing here.
}
//------------------Program Developed by R.GIRISH------------------//
Main Program (Upload this second):
//------------------Program Developed by R.GIRISH------------------//
#include 《Keypad.h》
#include《EEPROM.h》
#include《LiquidCrystal.h》
LiquidCrystal lcd(A5, A4, A3, A2, A1, A0);
const int relay = 10;
const int LED = 11;
const byte ROWS = 4;
const byte COLS = 4;
char key1;
char key2;
char key3;
char key4;
char key5;
char key6;
char keyABCD;
char compkey1;
char compkey2;
char compkey3;
char compkey4;
char compkey5;
char compkey6;
int wordAddress1 = 0;
int wordAddress2 = 1;
int wordAddress3 = 2;
int wordAddress4 = 3;
int wordAddress5 = 4;
int wordAddress6 = 5;
int outputStatusAddress = 6;
int outputStatusValue = 0;
int passwordExistAddress = 7;
int passwordExistValue = 0;
int toggleAddress = 8;
int toggleValue = 0;
int check = 0;
char keys[ROWS][COLS] =
{
{‘D’,‘#’,‘0’,‘*’},
{‘C’,‘9’,‘8’,‘7’},
{‘B’,‘6’,‘5’,‘4’},
{‘A’,‘3’,‘2’,‘1’}
};
byte rowPins[ROWS] = {6,7,8,9};
byte colPins[COLS] = {2,3,4,5};
Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS
);
void setup()
{
lcd.begin(16,2);
pinMode(relay, OUTPUT);
digitalWrite(relay, LOW);
pinMode(LED, OUTPUT);
digitalWrite(LED, LOW);
lcd.clear();
lcd.setCursor(0,0);
lcd.print(“ WELCOME”);
lcd.setCursor(0,1);
lcd.print(“****************”);
delay(2000);
}
void loop()
{
apex:
passwordExistValue = EEPROM.read(passwordExistAddress);
if(passwordExistValue == 1) {goto normal;}
if(passwordExistValue != 1)
{
top:
lcd.clear();
lcd.setCursor(0,0);
lcd.print(“Set new 6 digit”);
lcd.setCursor(0,1);
lcd.print(“pin numer:”);
if((key1 == ‘*’) || (key1 == ‘#’) || (key1 == ‘A’) || (key1 == ‘B’) ||
(key1 == ‘C’) || (key1 == ‘D’))
{
lcd.clear();
lcd.setCursor(0,0);
lcd.print(“Enter 6 digit,”);
lcd.setCursor(0,1);
lcd.print(“then press ‘A/B’。”);
delay(2500);
goto top;
}
else
{
lcd.clear();
lcd.setCursor(0,0);
lcd.print(“*”);
lcd.setCursor(0,1);
lcd.print(“YES ‘A’ NO ‘B’”);
}
key2 = keypad.waitForKey();
if((key2 == ‘*’) || (key2 == ‘#’) || (key2 == ‘A’) || (key2 == ‘B’) ||
(key2 == ‘C’) || (key2 == ‘D’))
{
lcd.clear();
lcd.setCursor(0,0);
lcd.print(“Enter 6 digit,”);
lcd.setCursor(0,1);
lcd.print(“then press ‘A/B’。”);
delay(2500);
goto top;
}
else
{
lcd.clear();
lcd.setCursor(0,0);
lcd.print(“**”);
lcd.setCursor(0,1);
lcd.print(“YES ‘A’ NO ‘B’”);
}
key3 = keypad.waitForKey();
if((key3 == ‘*’) || (key3 == ‘#’) || (key3 == ‘A’) || (key3 == ‘B’) ||
(key3 == ‘C’) || (key3 == ‘D’))
{
lcd.clear();
lcd.setCursor(0,0);
lcd.print(“Enter 6 digit,”);
lcd.setCursor(0,1);
lcd.print(“then press ‘A/B’。”);
delay(2500);
goto top;
}
else
{
lcd.clear();
lcd.setCursor(0,0);
lcd.print(“***”);
lcd.setCursor(0,1);
lcd.print(“YES ‘A’ NO ‘B’”);
}
key4 = keypad.waitForKey();
if((key4 == ‘*’) || (key4 == ‘#’) || (key4 == ‘A’) || (key4 == ‘B’) ||
(key4 == ‘C’) || (key4 == ‘D’))
{
lcd.clear();
lcd.setCursor(0,0);
lcd.print(“Enter 6 digit,”);
lcd.setCursor(0,1);
lcd.print(“then press ‘A/B’。”);
delay(2500);
goto top;
}
else
{
lcd.clear();
lcd.setCursor(0,0);
lcd.print(“****”);
lcd.setCursor(0,1);
lcd.print(“YES ‘A’ NO ‘B’”);
}
key5 = keypad.waitForKey();
if((key5 == ‘*’) || (key5 == ‘#’) || (key5 == ‘A’) || (key5 == ‘B’) ||
(key5 == ‘C’) || (key5 == ‘D’))
{
lcd.clear();
lcd.setCursor(0,0);
lcd.print(“Enter 6 digit,”);
lcd.setCursor(0,1);
lcd.print(“then press ‘A/B’。”);
delay(2500);
goto top;
}
else
{
lcd.clear();
lcd.setCursor(0,0);
lcd.print(“*****”);
lcd.setCursor(0,1);
lcd.print(“YES ‘A’ NO ‘B’”);
}
key6 = keypad.waitForKey();
if((key6 == ‘*’) || (key6 == ‘#’) || (key6 == ‘A’) || (key6 == ‘B’) ||
(key6 == ‘C’) || (key6 == ‘D’))
{
lcd.clear();
lcd.setCursor(0,0);
lcd.print(“Enter 6 digit,”);
lcd.setCursor(0,1);
lcd.print(“then press ‘A/B’。”);
delay(2500);
goto top;
}
else
{
lcd.clear();
lcd.setCursor(0,0);
lcd.print(“******”);
lcd.setCursor(0,1);
lcd.print(“YES ‘A’ NO ‘B’”);
}
}
keyABCD = keypad.waitForKey();
if(keyABCD == ‘A’)
{
wrong:
lcd.clear();
lcd.setCursor(0,0);
lcd.print(“Re-type PIN NO:”);
lcd.setCursor(0,1);
lcd.print(“----------------”);
compkey1 = keypad.waitForKey();
if((compkey1 == ‘*’) || (compkey1 == ‘#’) || (compkey1 == ‘A’) || (compkey1
== ‘B’) || (compkey1 == ‘C’) || (compkey1 == ‘D’))
{
lcd.clear();
lcd.setCursor(0,0);
lcd.print(“Enter 6 digit,”);
lcd.setCursor(0,1);
lcd.print(“then press ‘A/B’。”);
delay(2500);
goto wrong;
}
else
{
lcd.clear();
lcd.setCursor(0,0);
lcd.print(“*”);
lcd.setCursor(0,1);
lcd.print(“YES ‘A’ NO ‘B’”);
}
compkey2 = keypad.waitForKey();
if((compkey2 == ‘*’) || (compkey2 == ‘#’) || (compkey2 == ‘A’) || (compkey2
== ‘B’) || (compkey2 == ‘C’) || (compkey2 == ‘D’))
{
lcd.clear();
lcd.setCursor(0,0);
lcd.print(“Enter 6 digit,”);
lcd.setCursor(0,1);
lcd.print(“then press ‘A/B’。”);
delay(2500);
goto wrong;
}
else
{
lcd.clear();
lcd.setCursor(0,0);
lcd.print(“**”);
lcd.setCursor(0,1);
lcd.print(“YES ‘A’ NO ‘B’”);
}
compkey3 = keypad.waitForKey();
if((compkey3 == ‘*’) || (compkey3 == ‘#’) || (compkey3 == ‘A’) || (compkey3
== ‘B’) || (compkey3 == ‘C’) || (compkey3 == ‘D’))
{
lcd.clear();
lcd.setCursor(0,0);
lcd.print(“Enter 6 digit,”);
lcd.setCursor(0,1);
lcd.print(“then press ‘A/B’。”);
delay(2500);
goto wrong;
}
else
{
lcd.clear();
lcd.setCursor(0,0);
lcd.print(“***”);
lcd.setCursor(0,1);
lcd.print(“YES ‘A’ NO ‘B’”);
}
compkey4 = keypad.waitForKey();
if((compkey4 == ‘*’) || (compkey4 == ‘#’) || (compkey4 == ‘A’) || (compkey4
== ‘B’) || (compkey4 == ‘C’) || (compkey4 == ‘D’))
{
lcd.clear();
lcd.setCursor(0,0);
lcd.print(“Enter 6 digit,”);
lcd.setCursor(0,1);
lcd.print(“then press ‘A/B’。”);
delay(2500);
goto wrong;
}
else
{
lcd.clear();
lcd.setCursor(0,0);
lcd.print(“****”);
lcd.setCursor(0,1);
lcd.print(“YES ‘A’ NO ‘B’”);
}
compkey5 = keypad.waitForKey();
if((compkey5 == ‘*’) || (compkey5 == ‘#’) || (compkey5 == ‘A’) || (compkey5
== ‘B’) || (compkey5 == ‘C’) || (compkey5 == ‘D’))
{
lcd.clear();
lcd.setCursor(0,0);
lcd.print(“Enter 6 digit,”);
lcd.setCursor(0,1);
lcd.print(“then press ‘A/B’。”);
delay(2500);
goto wrong;
}
else
{
lcd.clear();
lcd.setCursor(0,0);
lcd.print(“*****”);
lcd.setCursor(0,1);
lcd.print(“YES ‘A’ NO ‘B’”);
}
compkey6 = keypad.waitForKey();
if((compkey6 == ‘*’) || (compkey6 == ‘#’) || (compkey6 == ‘A’) || (compkey6
== ‘B’) || (compkey6 == ‘C’) || (compkey6 == ‘D’))
{
lcd.clear();
lcd.setCursor(0,0);
lcd.print(“Enter 6 digit,”);
lcd.setCursor(0,1);
lcd.print(“then press ‘A/B’。”);
delay(2500);
goto wrong;
}
else
{
lcd.clear();
lcd.setCursor(0,0);
lcd.print(“******”);
lcd.setCursor(0,1);
lcd.print(“YES ‘A’ NO ‘B’”);
}
keyABCD = keypad.waitForKey();
if(keyABCD == ‘A’)
{
if(key1 == compkey1)
{
check = check + 1;
}
if(key2 == compkey2)
{
check = check + 1;
}
if(key3 == compkey3)
{
check = check + 1;
}
if(key4 == compkey4)
{
check = check + 1;
}
if(key5 == compkey5)
{
check = check + 1;
}
if(key6 == compkey6)
{
check = check + 1;
}
if(check == 6)
{
lcd.clear();
lcd.setCursor(0,0);
lcd.print(“Password has”);
lcd.setCursor(0,1);
lcd.print(“been saved.”);
delay(2000);
passwordExistValue = 1;
EEPROM.write(passwordExistAddress,passwordExistValue);
EEPROM.write(wordAddress1, key1);
EEPROM.write(wordAddress2, key2);
EEPROM.write(wordAddress3, key3);
EEPROM.write(wordAddress4, key4);
EEPROM.write(wordAddress5, key5);
EEPROM.write(wordAddress6, key6);
if(EEPROM.read(outputStatusAddress) == 1)
{
lcd.clear();
lcd.setCursor(0,0);
lcd.print(“STATUS:”);
lcd.print(“MAINS ON”);
lcd.setCursor(0,1);
lcd.print(“----------------”);
digitalWrite(LED, HIGH);
digitalWrite(relay, HIGH);
toggleValue = 0;
EEPROM.write(toggleAddress,toggleValue);
}
if(EEPROM.read(outputStatusAddress) == 0)
{
lcd.clear();
lcd.setCursor(0,0);
lcd.print(“STATUS:”);
lcd.print(“MAINS OFF”);
lcd.setCursor(0,1);
lcd.print(“----------------”);
digitalWrite(LED, LOW);
digitalWrite(relay, LOW);
toggleValue = 1;
EEPROM.write(toggleAddress,toggleValue);
}
}
else
{
lcd.clear();
lcd.setCursor(0,0);
lcd.print(“Password”);
lcd.setCursor(0,1);
lcd.print(“Mismatched !!!”);
delay(2000);
goto top;
}
if(keyABCD == ‘B’)
{
goto wrong;
}
}
}
if(keyABCD == ‘B’)
{
goto top;
}
normal:
lcd.clear();
lcd.setCursor(0,0);
lcd.print(“STATUS:”);
if(EEPROM.read(outputStatusAddress) == 1)
{
lcd.print(“MAINS ON”);
lcd.setCursor(0,1);
lcd.print(“----------------”);
digitalWrite(LED, HIGH);
digitalWrite(relay, HIGH);
toggleValue = 0;
EEPROM.write(toggleAddress,toggleValue);
}
if(EEPROM.read(outputStatusAddress) == 0)
{
lcd.print(“MAINS OFF”);
lcd.setCursor(0,1);
lcd.print(“----------------”);
digitalWrite(LED, LOW);
digitalWrite(relay, LOW);
toggleValue = 1;
EEPROM.write(toggleAddress,toggleValue);
}
keyABCD = keypad.waitForKey();
if(keyABCD == ‘C’)
{
pass:
lcd.clear();
lcd.setCursor(0,0);
lcd.print(“Enter current”);
lcd.setCursor(0,1);
lcd.print(“PIN:”);
key1 = keypad.waitForKey();
if((key1 == ‘*’) || (key1 == ‘#’) || (key1 == ‘A’) || (key1 == ‘B’) ||
(key1 == ‘C’) || (key1 == ‘D’))
{
lcd.clear();
lcd.setCursor(0,0);
lcd.print(“Enter 6 digit,”);
lcd.setCursor(0,1);
lcd.print(“then press ‘A/B’。”);
delay(2500);
goto pass;
}
else
{
lcd.clear();
lcd.setCursor(0,0);
lcd.print(“*”);
lcd.setCursor(0,1);
lcd.print(“YES ‘A’ NO ‘B’”);
}
key2 = keypad.waitForKey();
if((key2 == ‘*’) || (key2 == ‘#’) || (key2 == ‘A’) || (key2 == ‘B’) ||
(key2 == ‘C’) || (key2 == ‘D’))
{
lcd.clear();
lcd.setCursor(0,0);
lcd.print(“Enter 6 digit,”);
lcd.setCursor(0,1);
lcd.print(“then press ‘A/B’。”);
delay(2500);
goto pass;
}
else
{
lcd.clear();
lcd.setCursor(0,0);
lcd.print(“**”);
lcd.setCursor(0,1);
lcd.print(“YES ‘A’ NO ‘B’”);
}
key3 = keypad.waitForKey();
if((key3 == ‘*’) || (key3 == ‘#’) || (key3 == ‘A’) || (key3 == ‘B’) ||
(key3 == ‘C’) || (key3 == ‘D’))
{
lcd.clear();
lcd.setCursor(0,0);
lcd.print(“Enter 6 digit,”);
lcd.setCursor(0,1);
lcd.print(“then press ‘A/B’。”);
delay(2500);
goto pass;
}
else
{
lcd.clear();
lcd.setCursor(0,0);
lcd.print(“***”);
lcd.setCursor(0,1);
lcd.print(“YES ‘A’ NO ‘B’”);
}
key4 = keypad.waitForKey();
if((key4 == ‘*’) || (key4 == ‘#’) || (key4 == ‘A’) || (key4 == ‘B’) ||
(key4 == ‘C’) || (key4 == ‘D’))
{
lcd.clear();
lcd.setCursor(0,0);
lcd.print(“Enter 6 digit,”);
lcd.setCursor(0,1);
lcd.print(“then press ‘A/B’。”);
delay(2500);
goto pass;
}
else
{
lcd.clear();
lcd.setCursor(0,0);
lcd.print(“****”);
lcd.setCursor(0,1);
lcd.print(“YES ‘A’ NO ‘B’”);
}
key5 = keypad.waitForKey();
if((key5 == ‘*’) || (key5 == ‘#’) || (key5 == ‘A’) || (key5 == ‘B’) ||
(key5 == ‘C’) || (key5 == ‘D’))
{
lcd.clear();
lcd.setCursor(0,0);
lcd.print(“Enter 6 digit,”);
lcd.setCursor(0,1);
lcd.print(“then press ‘A/B’。”);
delay(2500);
goto pass;
}
else
{
lcd.clear();
lcd.setCursor(0,0);
lcd.print(“*****”);
lcd.setCursor(0,1);
lcd.print(“YES ‘A’ NO ‘B’”);
}
key6 = keypad.waitForKey();
if((key6 == ‘*’) || (key6 == ‘#’) || (key6 == ‘A’) || (key6 == ‘B’) ||
(key6 == ‘C’) || (key6 == ‘D’))
{
lcd.clear();
lcd.setCursor(0,0);
lcd.print(“Enter 6 digit,”);
lcd.setCursor(0,1);
lcd.print(“then press ‘A/B’。”);
delay(2500);
goto pass;
}
else
{
lcd.clear();
lcd.setCursor(0,0);
lcd.print(“******”);
lcd.setCursor(0,1);
lcd.print(“YES ‘A’ NO ‘B’”);
}
keyABCD = keypad.waitForKey();
if(keyABCD == ‘A’)
{
check = 0;
char readkey1 = EEPROM.read(wordAddress1);
char readkey2 = EEPROM.read(wordAddress2);
char readkey3 = EEPROM.read(wordAddress3);
char readkey4 = EEPROM.read(wordAddress4);
char readkey5 = EEPROM.read(wordAddress5);
char readkey6 = EEPROM.read(wordAddress6);
if(key1 == readkey1) {check = check + 1;}
if(key2 == readkey2) {check = check + 1;}
if(key3 == readkey3) {check = check + 1;}
if(key4 == readkey4) {check = check + 1;}
if(key5 == readkey5) {check = check + 1;}
if(key6 == readkey6) {check = check + 1;}
if(check == 6)
{
passwordExistValue = 0;
EEPROM.write(passwordExistAddress,passwordExistValue);
check = 0;
goto apex;
}
else if(check != 6)
{
lcd.clear();
lcd.setCursor(0,0);
lcd.print(“Incorrect”);
lcd.setCursor(0,1);
lcd.print(“Pasword !!!”);
delay(2000);
goto normal;
}
if(keyABCD == ‘B’) {goto normal;}
}
}
if(keyABCD == ‘D’)
{
toggle:
lcd.clear();
lcd.setCursor(0,0);
lcd.print(“Enter the PIN:”);
lcd.setCursor(0,1);
key1 = keypad.waitForKey();
if((key1 == ‘*’) || (key1 == ‘#’) || (key1 == ‘A’) || (key1 == ‘B’) ||
(key1 == ‘C’) || (key1 == ‘D’))
{
lcd.clear();
lcd.setCursor(0,0);
lcd.print(“Enter 6 digit,”);
lcd.setCursor(0,1);
lcd.print(“then press ‘A/B’。”);
delay(2500);
goto toggle;
}
else
{
lcd.clear();
lcd.setCursor(0,0);
lcd.print(“*”);
lcd.setCursor(0,1);
lcd.print(“YES ‘A’ NO ‘B’”);
}
key2 = keypad.waitForKey();
if((key2 == ‘*’) || (key2 == ‘#’) || (key2 == ‘A’) || (key2 == ‘B’) ||
(key2 == ‘C’) || (key2 == ‘D’))
{
lcd.clear();
lcd.setCursor(0,0);
lcd.print(“Enter 6 digit,”);
lcd.setCursor(0,1);
lcd.print(“then press ‘A/B’。”);
delay(2500);
goto toggle;
}
else
{
lcd.clear();
lcd.setCursor(0,0);
lcd.print(“**”);
lcd.setCursor(0,1);
lcd.print(“YES ‘A’ NO ‘B’”);
}
key3 = keypad.waitForKey();
if((key3 == ‘*’) || (key3 == ‘#’) || (key3 == ‘A’) || (key3 == ‘B’) ||
(key3 == ‘C’) || (key3 == ‘D’))
{
lcd.clear();
lcd.setCursor(0,0);
lcd.print(“Enter 6 digit,”);
lcd.setCursor(0,1);
lcd.print(“then press ‘A/B’。”);
delay(2500);
goto toggle;
}
else
{
lcd.clear();
lcd.setCursor(0,0);
lcd.print(“***”);
lcd.setCursor(0,1);
lcd.print(“YES ‘A’ NO ‘B’”);
}
key4 = keypad.waitForKey();
if((key4 == ‘*’) || (key4 == ‘#’) || (key4 == ‘A’) || (key4 == ‘B’) ||
(key4 == ‘C’) || (key4 == ‘D’))
{
lcd.clear();
lcd.setCursor(0,0);
lcd.print(“Enter 6 digit,”);
lcd.setCursor(0,1);
lcd.print(“then press ‘A/B’。”);
delay(2500);
goto toggle;
}
else
{
lcd.clear();
lcd.setCursor(0,0);
lcd.print(“****”);
lcd.setCursor(0,1);
lcd.print(“YES ‘A’ NO ‘B’”);
}
key5 = keypad.waitForKey();
if((key5 == ‘*’) || (key5 == ‘#’) || (key5 == ‘A’) || (key5 == ‘B’) ||
(key5 == ‘C’) || (key5 == ‘D’))
{
lcd.clear();
lcd.setCursor(0,0);
lcd.print(“Enter 6 digit,”);
lcd.setCursor(0,1);
lcd.print(“then press ‘A/B’。”);
delay(2500);
goto toggle;
}
else
{
lcd.clear();
lcd.setCursor(0,0);
lcd.print(“*****”);
lcd.setCursor(0,1);
lcd.print(“YES ‘A’ NO ‘B’”);
}
key6 = keypad.waitForKey();
if((key6 == ‘*’) || (key6 == ‘#’) || (key6 == ‘A’) || (key6 == ‘B’) ||
(key6 == ‘C’) || (key6 == ‘D’))
{
lcd.clear();
lcd.setCursor(0,0);
lcd.print(“Enter 6 digit,”);
lcd.setCursor(0,1);
lcd.print(“then press ‘A/B’。”);
delay(2500);
goto toggle;
}
else
{
lcd.clear();
lcd.setCursor(0,0);
lcd.print(“******”);
lcd.setCursor(0,1);
lcd.print(“YES ‘A’ NO ‘B’”);
}
check = 0;
if(EEPROM.read(wordAddress1) == key1)
{
check = check + 1;
}
if(EEPROM.read(wordAddress2) == key2)
{
check = check + 1;
}
if(EEPROM.read(wordAddress3) == key3)
{
check = check + 1;
}
if(EEPROM.read(wordAddress4) == key4)
{
check = check + 1;
}
if(EEPROM.read(wordAddress5) == key5)
{
check = check + 1;
}
if(EEPROM.read(wordAddress6) == key6)
{
check = check + 1;
}
keyABCD = keypad.waitForKey();
if(keyABCD == ‘B’)
{
goto normal;
}
if(keyABCD == ‘A’)
{
if(check == 6 && EEPROM.read(toggleAddress) == 1)
{
outputStatusValue = 1;
EEPROM.write(outputStatusAddress, outputStatusValue);
goto normal;
}
if(check == 6 && EEPROM.read(toggleAddress) == 0)
{
outputStatusValue = 0;
EEPROM.write(outputStatusAddress, outputStatusValue);
goto normal;
}
if(check != 6)
{
lcd.clear();
lcd.setCursor(0,0);
lcd.print(“Incorrect”);
lcd.setCursor(0,1);
lcd.print(“Password !!!”);
delay(1500);
goto normal;
}
}
}
}
如何操作此基于密碼的電源ON/OFF開關項目:
·完成硬件設置后,上傳EEPROM重置代碼。
·現在,上傳主程序代碼。
·它會要求您在LCD上創建6位數字密碼(不少于或更多),創建密碼并按“ A”。
·再次重新輸入密碼,然后按“A”。您的密碼已保存。
·您可以通過按“C”更改密碼。輸入當前密碼并輸入新密碼。
·要打開或關閉交流電源,請按“D”并輸入密碼并按“A”。
按鍵 A、B、C 和 D 的功能:
A – 輸入/是
B – 取消/否
C – 更改密碼
D – 切換交流電源
-
電源
+關注
關注
184文章
17704瀏覽量
249963 -
開關電路
+關注
關注
58文章
553瀏覽量
66394
發布評論請先 登錄
相關推薦
評論