0
  • 聊天消息
  • 系統(tǒng)消息
  • 評論與回復
登錄后你可以
  • 下載海量資料
  • 學習在線課程
  • 觀看技術(shù)視頻
  • 寫文章/發(fā)帖/加入社區(qū)
會員中心
創(chuàng)作中心

完善資料讓更多小伙伴認識你,還能領(lǐng)取20積分哦,立即完善>

3天內(nèi)不再提示

構(gòu)建一個基于密碼的電源ON/OFF開關(guān)電路

科技觀察員 ? 來源:homemade-circuits ? 作者:homemade-circuits ? 2023-07-27 11:25 ? 次閱讀

在這篇文章中,我們將構(gòu)建一個基于密碼的電源ON/OFF開關(guān)電路,只有在輸入正確的密碼時,它才能打開和關(guān)閉交流電源。這可以防止當前可能正在使用高壓線路和設(shè)備的技術(shù)人員觸電的危險。

公用電源的密碼保護至關(guān)重要

對于任何電工或技術(shù)人員來說,最大的噩夢是某人意外激活交流線路,這可能會在眨眼間殺死或?qū)ι眢w器官造成致命損害。

這種受密碼保護的電源開/關(guān)開關(guān)電路可防止此類不幸事件,并允許技術(shù)人員通過輸入正確的密碼而不僅僅是翻轉(zhuǎn)杠桿來安全地打開交流電源。

該項目提供了更改存儲在Arduino微控制器EEPROM中的密碼的功能。

人體甚至動物身體都有自己的電氣系統(tǒng),這有助于將信息從身體的一個部位發(fā)送到另一個部位。信息以具有可測量幅度和頻率的電信號形式發(fā)送。它還有助于收縮和放松肌肉,例如我們的心臟。

有趣的事實:心臟有一個多諧振蕩器,稱為“SA節(jié)點”或“竇房”;控制心率。如果竇房衰竭,我們必須使用起搏器將外部電信號施加到心臟。

我們身體現(xiàn)有電信號的任何激增都會使我們失去對自己身體部位的控制。這就是為什么人們在接觸開放的帶電電線時會感到卡住和癱瘓的原因。

我們的身體有合理的電阻和良好的電導率。我們知道,任何有電阻的元件在電流通過時都會產(chǎn)生熱量。

這也適用于人體;熱量會損害器官,并可能導致血液沸騰。如果他/她觸電的時間足夠長,這個人遲早可能會死。

目前,這已經(jīng)足夠醫(yī)療電子產(chǎn)品了。讓我們繼續(xù)討論技術(shù)細節(jié)。

該項目由LCD顯示屏,4 x 3字母數(shù)字鍵盤,狀態(tài)LED和繼電器組成。

Arduino 和 LCD 連接的原理圖:

Password Based AC Mains ON/OFF Circuit

顯示器連接到 arduino 的模擬引腳,從 A0 到 A5。顯示器異常連接到模擬引腳(其功能與連接到數(shù)字引腳相同),因此鍵盤可以連接到數(shù)字引腳(從
2 到 9)。

使用 10 K 歐姆電位計調(diào)整顯示對比度。

鍵盤連接:

Password Based AC Mains ON/OFF keypad connection

鍵盤有 8 根電纜,應連接到 Arduino,從引腳 #2 到引腳
#9。鍵盤最左邊的電線必須轉(zhuǎn)到引腳#9,并將鍵盤的下一個右線連接到引腳#8,7,6,5,4,3,2,鍵盤的最后一根或最右邊的電線必須連接到引腳#2。

其余電氣連接:

Password Based AC Mains ON/OFF electrical wiring details

您需要從以下鏈接下載并添加鍵盤庫:github.com/Chris--A/Keypad 在編譯代碼之前。

Arduino微控制器的EEPROM最初會存儲一些隨機值。我們必須重置為零,這樣我們的主程序就不會混淆。要將EEPROM值設(shè)置為零,請先上傳以下程序,然后再上傳主程序。

程序代碼

重置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:”);

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 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)項目:

·完成硬件設(shè)置后,上傳EEPROM重置代碼。

·現(xiàn)在,上傳主程序代碼。

·它會要求您在LCD上創(chuàng)建6位數(shù)字密碼(不少于或更多),創(chuàng)建密碼并按“ A”。

·再次重新輸入密碼,然后按“A”。您的密碼已保存。

·您可以通過按“C”更改密碼。輸入當前密碼并輸入新密碼。

·要打開或關(guān)閉交流電源,請按“D”并輸入密碼并按“A”。

按鍵 A、B、C 和 D 的功能:

A – 輸入/是

B – 取消/否

C – 更改密碼

D – 切換交流電源

聲明:本文內(nèi)容及配圖由入駐作者撰寫或者入駐合作網(wǎng)站授權(quán)轉(zhuǎn)載。文章觀點僅代表作者本人,不代表電子發(fā)燒友網(wǎng)立場。文章及其配圖僅供工程師學習之用,如有內(nèi)容侵權(quán)或者其他違規(guī)問題,請聯(lián)系本站處理。 舉報投訴
  • 電源
    +關(guān)注

    關(guān)注

    184

    文章

    17404

    瀏覽量

    248781
  • 開關(guān)電路
    +關(guān)注

    關(guān)注

    58

    文章

    551

    瀏覽量

    66281
收藏 人收藏

    評論

    相關(guān)推薦

    求助觸摸開關(guān)電路

    各位大神,我想求助電源開關(guān)電路,電路要求如下:1、電源開關(guān)為觸摸式。2、需要打開電源時,手指
    發(fā)表于 12-26 14:47

    求助觸摸電源開關(guān)電路

    各位大神,我想求助電源開關(guān)電路,用來控制交流220V電源開關(guān),電路要求如下:1、
    發(fā)表于 12-26 15:33

    臺燈的on-off觸摸開關(guān)電路怎么改為普通機械開關(guān)電路?

    `臺燈的on-off觸摸開關(guān)電路怎么改為普通機械開關(guān)電路`
    發(fā)表于 06-27 11:30

    介紹USB控制的電源開關(guān)電路

    現(xiàn)在很多設(shè)備幾乎都有或多個USB端口,我們其實可以用這個USB端口用作當作自動開關(guān),來控制市電供電的設(shè)備。本次,老宇哥給大家介紹
    發(fā)表于 02-17 06:26

    電子式電源開關(guān)電路

    電子式電源開關(guān)電路
    發(fā)表于 03-01 11:05 ?2478次閱讀
    電子式<b class='flag-5'>電源開關(guān)電路</b>

    簡易電子密碼開關(guān)電路

    簡易電子密碼開關(guān)電路圖 使用時依次按下AN1,AN2,AN3才能打開用電器。關(guān)機需按動AN4--AN6任鍵即可。
    發(fā)表于 11-17 11:36 ?1178次閱讀
    簡易電子<b class='flag-5'>密碼</b><b class='flag-5'>開關(guān)電路</b>圖

    數(shù)字密碼開關(guān)電路

    數(shù)字密碼開關(guān)電路圖 本密碼可在9位數(shù)以內(nèi)設(shè)置,可設(shè)置達三百多萬種密碼。
    發(fā)表于 11-17 11:48 ?1820次閱讀
    數(shù)字<b class='flag-5'>密碼</b><b class='flag-5'>開關(guān)電路</b>圖

    EPROM密碼開關(guān)電路

    EPROM密碼開關(guān)電路 本裝置是將EPROM 2764用于密碼開關(guān)的實例。
    發(fā)表于 11-17 22:36 ?1074次閱讀
    EPROM<b class='flag-5'>密碼</b><b class='flag-5'>開關(guān)電路</b>

    密碼電子開關(guān)電路原理

    密碼電子開關(guān)電路原理   工作原理:該裝置的電路工作原理見下圖。該密碼電子開關(guān)設(shè)計了三開鎖按
    發(fā)表于 12-30 09:49 ?1841次閱讀

    模擬開關(guān)電路概述

    模擬開關(guān)電路概述 模擬開關(guān)電路即對模擬信號進行“通/斷”(ON/OFF)控制的電路,現(xiàn)在般由晶體管(二極管、雙極型三極管、場效應管等)作
    發(fā)表于 05-24 10:55 ?3835次閱讀

    分享不錯的觸摸開關(guān)電路

    這是觸摸開關(guān)電路,用于打開和關(guān)閉連接到 220V 家用電器裝置的電子設(shè)備。這是非常簡單的電路
    的頭像 發(fā)表于 06-16 16:19 ?2631次閱讀
    分享<b class='flag-5'>一</b><b class='flag-5'>個</b>不錯的觸摸<b class='flag-5'>開關(guān)電路</b>

    簡單的磁開關(guān)電路分享

    開關(guān)電路如下圖所示,可以用不同的電子元件構(gòu)建,如磁開關(guān)、3V 電池、470 歐姆電阻和 LED。電路連接如下圖所示。這是
    的頭像 發(fā)表于 07-05 14:49 ?3540次閱讀
    <b class='flag-5'>一</b><b class='flag-5'>個</b>簡單的磁<b class='flag-5'>開關(guān)電路</b>分享

    開關(guān)電路的好處?生活中的開關(guān)電路有哪些?

    開關(guān)電路的好處?生活中的開關(guān)電路有哪些? 開關(guān)電路是指
    的頭像 發(fā)表于 10-22 15:18 ?1942次閱讀

    如何設(shè)計nmos管和pmos管的開關(guān)電路

    設(shè)計NMOS和PMOS管的開關(guān)電路涉及到電路的基礎(chǔ)知識、原理和設(shè)計過程。在本文中,我們將詳細討論NMOS和PMOS管的工作原理、開關(guān)電路
    的頭像 發(fā)表于 12-21 16:57 ?5313次閱讀

    NMOS與PMOS經(jīng)典電源開關(guān)電路的深入解析

    NMOS低邊開關(guān)電路切換的是對地的導通,PMOS作為高邊開關(guān)電路切換的是對電源的導通。
    發(fā)表于 04-10 11:45 ?6009次閱讀
    NMOS與PMOS經(jīng)典<b class='flag-5'>電源開關(guān)電路</b>的深入解析