0
  • 聊天消息
  • 系统消息
  • 评论与回复
登录后你可以
  • 下载海量资料
  • 学习在线课程
  • 观看技术视频
  • 写文章/发帖/加入社区
会员中心
创作中心

完善资料让更多小伙伴认识你,还能领取20积分哦,立即完善>

3天内不再提示

构建一个基于密码的电源ON/OFF开关电路

科技观察员 来源:homemade-circuits 作者:homemade-circuits 2023-07-27 11:25 次阅读

在这篇文章中,我们将构建一个基于密码的电源ON/OFF开关电路,只有在输入正确的密码时,它才能打开和关闭交流电源。这可以防止当前可能正在使用高压线路和设备的技术人员触电的危险。

公用电源的密码保护至关重要

对于任何电工或技术人员来说,最大的噩梦是某人意外激活交流线路,这可能会在眨眼间杀死或对身体器官造成致命损害。

这种受密码保护的电源开/关开关电路可防止此类不幸事件,并允许技术人员通过输入正确的密码而不仅仅是翻转杠杆来安全地打开交流电源。

该项目提供了更改存储在Arduino微控制器EEPROM中的密码的功能。

人体甚至动物身体都有自己的电气系统,这有助于将信息从身体的一个部位发送到另一个部位。信息以具有可测量幅度和频率的电信号形式发送。它还有助于收缩和放松肌肉,例如我们的心脏。

有趣的事实:心脏有一个多谐振荡器,称为“SA节点”或“窦房”;控制心率。如果窦房衰竭,我们必须使用起搏器将外部电信号施加到心脏。

我们身体现有电信号的任何激增都会使我们失去对自己身体部位的控制。这就是为什么人们在接触开放的带电电线时会感到卡住和瘫痪的原因。

我们的身体有合理的电阻和良好的电导率。我们知道,任何有电阻的元件在电流通过时都会产生热量。

这也适用于人体;热量会损害器官,并可能导致血液沸腾。如果他/她触电的时间足够长,这个人迟早可能会死。

目前,这已经足够医疗电子产品了。让我们继续讨论技术细节。

该项目由LCD显示屏,4 x 3字母数字键盘,状态LED和继电器组成。

Arduino 和 LCD 连接的原理图:

Password Based AC Mains ON/OFF Circuit

显示器连接到 arduino 的模拟引脚,从 A0 到 A5。显示器异常连接到模拟引脚(其功能与连接到数字引脚相同),因此键盘可以连接到数字引脚(从
2 到 9)。

使用 10 K 欧姆电位计调整显示对比度。

键盘连接:

Password Based AC Mains ON/OFF keypad connection

键盘有 8 根电缆,应连接到 Arduino,从引脚 #2 到引脚
#9。键盘最左边的电线必须转到引脚#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值设置为零,请先上传以下程序,然后再上传主程序。

程序代码

重置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开关项目:

·完成硬件设置后,上传EEPROM重置代码。

·现在,上传主程序代码。

·它会要求您在LCD上创建6位数字密码(不少于或更多),创建密码并按“ A”。

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

·您可以通过按“C”更改密码。输入当前密码并输入新密码。

·要打开或关闭交流电源,请按“D”并输入密码并按“A”。

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

A – 输入/是

B – 取消/否

C – 更改密码

D – 切换交流电源

声明:本文内容及配图由入驻作者撰写或者入驻合作网站授权转载。文章观点仅代表作者本人,不代表电子发烧友网立场。文章及其配图仅供工程师学习之用,如有内容侵权或者其他违规问题,请联系本站处理。 举报投诉
  • 电源
    +关注

    关注

    184

    文章

    17705

    浏览量

    249975
  • 开关电路
    +关注

    关注

    58

    文章

    553

    浏览量

    66396
收藏 人收藏

    评论

    相关推荐

    求助触摸开关电路

    各位大神,我想求助电源开关电路电路要求如下:1、电源开关为触摸式。2、需要打开电源时,手指
    发表于 12-26 14:47

    求助触摸电源开关电路

    各位大神,我想求助电源开关电路,用来控制交流220V电源开关电路要求如下:1、
    发表于 12-26 15:33

    台灯的on-off触摸开关电路怎么改为普通机械开关电路

    `台灯的on-off触摸开关电路怎么改为普通机械开关电路`
    发表于 06-27 11:30

    介绍USB控制的电源开关电路

    现在很多设备几乎都有或多个USB端口,我们其实可以用这个USB端口用作当作自动开关,来控制市电供电的设备。本次,老宇哥给大家介绍
    发表于 02-17 06:26

    电子式电源开关电路

    电子式电源开关电路
    发表于 03-01 11:05 2615次阅读
    电子式<b class='flag-5'>电源开关电路</b>

    简易电子密码开关电路

    简易电子密码开关电路图 使用时依次按下AN1,AN2,AN3才能打开用电器。关机需按动AN4--AN6任键即可。
    发表于 11-17 11:36 1189次阅读
    简易电子<b class='flag-5'>密码</b><b class='flag-5'>开关电路</b>图

    数字密码开关电路

    数字密码开关电路图 本密码可在9位数以内设置,可设置达三百多万种密码
    发表于 11-17 11:48 1828次阅读
    数字<b class='flag-5'>密码</b><b class='flag-5'>开关电路</b>图

    EPROM密码开关电路

    EPROM密码开关电路 本装置是将EPROM 2764用于密码开关的实例。
    发表于 11-17 22:36 1088次阅读
    EPROM<b class='flag-5'>密码</b><b class='flag-5'>开关电路</b>

    密码电子开关电路原理

    密码电子开关电路原理   工作原理:该装置的电路工作原理见下图。该密码电子开关设计了三开锁按
    发表于 12-30 09:49 1877次阅读

    模拟开关电路概述

    模拟开关电路概述 模拟开关电路即对模拟信号进行“通/断”(ON/OFF)控制的电路,现在般由晶体管(二极管、双极型三极管、场效应管等)作
    发表于 05-24 10:55 3904次阅读

    分享不错的触摸开关电路

    这是触摸开关电路,用于打开和关闭连接到 220V 家用电器装置的电子设备。这是非常简单的电路
    的头像 发表于 06-16 16:19 2776次阅读
    分享<b class='flag-5'>一</b><b class='flag-5'>个</b>不错的触摸<b class='flag-5'>开关电路</b>

    简单的磁开关电路分享

    开关电路如下图所示,可以用不同的电子元件构建,如磁开关、3V 电池、470 欧姆电阻和 LED。电路连接如下图所示。这是
    的头像 发表于 07-05 14:49 3917次阅读
    <b class='flag-5'>一</b><b class='flag-5'>个</b>简单的磁<b class='flag-5'>开关电路</b>分享

    开关电路的好处?生活中的开关电路有哪些?

    开关电路的好处?生活中的开关电路有哪些? 开关电路是指
    的头像 发表于 10-22 15:18 2219次阅读

    如何设计nmos管和pmos管的开关电路

    设计NMOS和PMOS管的开关电路涉及到电路的基础知识、原理和设计过程。在本文中,我们将详细讨论NMOS和PMOS管的工作原理、开关电路
    的头像 发表于 12-21 16:57 6431次阅读

    NMOS与PMOS经典电源开关电路的深入解析

    NMOS低边开关电路切换的是对地的导通,PMOS作为高边开关电路切换的是对电源的导通。
    发表于 04-10 11:45 7445次阅读
    NMOS与PMOS经典<b class='flag-5'>电源开关电路</b>的深入解析