在這篇文章中,我們將構(gòu)建一個(gè)基于密碼的電源ON/OFF開關(guān)電路,只有在輸入正確的密碼時(shí),它才能打開和關(guān)閉交流電源。這可以防止當(dāng)前可能正在使用高壓線路和設(shè)備的技術(shù)人員觸電的危險(xiǎn)。
公用電源的密碼保護(hù)至關(guān)重要
對(duì)于任何電工或技術(shù)人員來說,最大的噩夢是某人意外激活交流線路,這可能會(huì)在眨眼間殺死或?qū)ι眢w器官造成致命損害。
這種受密碼保護(hù)的電源開/關(guān)開關(guān)電路可防止此類不幸事件,并允許技術(shù)人員通過輸入正確的密碼而不僅僅是翻轉(zhuǎn)杠桿來安全地打開交流電源。
該項(xiàng)目提供了更改存儲(chǔ)在Arduino微控制器EEPROM中的密碼的功能。
人體甚至動(dòng)物身體都有自己的電氣系統(tǒng),這有助于將信息從身體的一個(gè)部位發(fā)送到另一個(gè)部位。信息以具有可測量幅度和頻率的電信號(hào)形式發(fā)送。它還有助于收縮和放松肌肉,例如我們的心臟。
有趣的事實(shí):心臟有一個(gè)多諧振蕩器,稱為“SA節(jié)點(diǎn)”或“竇房”;控制心率。如果竇房衰竭,我們必須使用起搏器將外部電信號(hào)施加到心臟。
我們身體現(xiàn)有電信號(hào)的任何激增都會(huì)使我們失去對(duì)自己身體部位的控制。這就是為什么人們?cè)诮佑|開放的帶電電線時(shí)會(huì)感到卡住和癱瘓的原因。
我們的身體有合理的電阻和良好的電導(dǎo)率。我們知道,任何有電阻的元件在電流通過時(shí)都會(huì)產(chǎn)生熱量。
這也適用于人體;熱量會(huì)損害器官,并可能導(dǎo)致血液沸騰。如果他/她觸電的時(shí)間足夠長,這個(gè)人遲早可能會(huì)死。
目前,這已經(jīng)足夠醫(yī)療電子產(chǎn)品了。讓我們繼續(xù)討論技術(shù)細(xì)節(jié)。
該項(xiàng)目由LCD顯示屏,4 x 3字母數(shù)字鍵盤,狀態(tài)LED和繼電器組成。
Arduino 和 LCD 連接的原理圖:
顯示器連接到 arduino 的模擬引腳,從 A0 到 A5。顯示器異常連接到模擬引腳(其功能與連接到數(shù)字引腳相同),因此鍵盤可以連接到數(shù)字引腳(從
2 到 9)。
使用 10 K 歐姆電位計(jì)調(diào)整顯示對(duì)比度。
鍵盤連接:
鍵盤有 8 根電纜,應(yīng)連接到 Arduino,從引腳 #2 到引腳
#9。鍵盤最左邊的電線必須轉(zhuǎn)到引腳#9,并將鍵盤的下一個(gè)右線連接到引腳#8,7,6,5,4,3,2,鍵盤的最后一根或最右邊的電線必須連接到引腳#2。
其余電氣連接:
您需要從以下鏈接下載并添加鍵盤庫:github.com/Chris--A/Keypad 在編譯代碼之前。
Arduino微控制器的EEPROM最初會(huì)存儲(chǔ)一些隨機(jī)值。我們必須重置為零,這樣我們的主程序就不會(huì)混淆。要將EEPROM值設(shè)置為零,請(qǐng)先上傳以下程序,然后再上傳主程序。
重置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開關(guān)項(xiàng)目:
·完成硬件設(shè)置后,上傳EEPROM重置代碼。
·現(xiàn)在,上傳主程序代碼。
·它會(huì)要求您在LCD上創(chuàng)建6位數(shù)字密碼(不少于或更多),創(chuàng)建密碼并按“ A”。
·再次重新輸入密碼,然后按“A”。您的密碼已保存。
·您可以通過按“C”更改密碼。輸入當(dāng)前密碼并輸入新密碼。
·要打開或關(guān)閉交流電源,請(qǐng)按“D”并輸入密碼并按“A”。
按鍵 A、B、C 和 D 的功能:
A – 輸入/是
B – 取消/否
C – 更改密碼
D – 切換交流電源
-
電源
+關(guān)注
關(guān)注
184文章
17830瀏覽量
251274 -
開關(guān)電路
+關(guān)注
關(guān)注
58文章
554瀏覽量
66493
發(fā)布評(píng)論請(qǐng)先 登錄
相關(guān)推薦
評(píng)論