Obsah:

Safe Box: 3 kroky
Safe Box: 3 kroky

Video: Safe Box: 3 kroky

Video: Safe Box: 3 kroky
Video: НОЧЬ В СТРАШНОМ ДОМЕ С ДЕМОНОМ / НЕ СТОИЛО СЮДА ПРИХОДИТЬ 2024, Júl
Anonim
Trezor
Trezor
Trezor
Trezor
Trezor
Trezor

To by mal byť váš konečný výsledok po zostavení a nahraní kódu.

Krok 1: Veci, ktoré budete potrebovať

Veci, ktoré budete potrebovať
Veci, ktoré budete potrebovať
Veci, ktoré budete potrebovať
Veci, ktoré budete potrebovať
Veci, ktoré budete potrebovať
Veci, ktoré budete potrebovať
Veci, ktoré budete potrebovať
Veci, ktoré budete potrebovať

Prepojovacie vodiče, odpor 220 ohmov, obrazovka LCD 16 x 2, tlačidlá, servomotor, doska na chlieb, Arduino Uno.

Krok 2: Kód

James chinchay

#zahrnúť

#include #include

int adresa = 0; statický nepodpísaný dlhý SaveTimer; statický nepodpísaný dlhý SaveDelay = (30 * 1000);

char CODE [10] = "1234E"; char Str [10]; char Dĺžka kódu = 4; int Pozícia = 0; bool odomknutý; statický bez znamienka dlhý DisplayTimer; statický nepodpísaný dlhý DisplayDelay = 200;

LiquidCrystal lcd (12, 11, 9, 8, 7, 6);

int tlačidloPin1 = 2; int tlačidloPin2 = 3; int tlačidloPin3 = 4; int tlačidloPin4 = 5;

int zadacie tlačidlo = 10; int clearlockbutton = 13;

Servo myServo; // nastavenie programu konštrukcie void setup () {

myServo.attach (A1);

int EEPROMCodeOK = true; pre (Pos = 0; Pos <= (CodeLength); Pos ++) {Str [Pos] = EEPROM.read (Pos); if (! (strrchr ("1123456789", Str [Pos]))) {// nie je platný kód EEPROMCodeOK = false; }} Pozícia ++; Str [Pos] = EEPROM.read (Poz); if (Str [CodeLength + 1]! = 'E') EEPROMCodeOK = false; if (EEPROMCodeOK) {Str [CodeLength + 2] = '\ 0'; strncpy (CODE, Str, CodeLength + 1); } ClearCode (); // nastavenie vstupov pinMode (buttonPin1, INPUT_PULLUP); pinMode (buttonPin2, INPUT_PULLUP); pinMode (buttonPin3, INPUT_PULLUP); pinMode (buttonPin4, INPUT_PULLUP);

pinMode (Enterbutton, INPUT_PULLUP); pinMode (clearlockbutton, INPUT_PULLUP);

lcd.begin (16, 2); lcd.setCursor (0, 0); // nastavenie zaslaných správ lcd.print („Dobrý deň, pán Birch“); oneskorenie (2000); lcd.clear (); lcd.setCursor (0, 0); // nastavenie výzvy na zadanie hesla lcd.print ("Heslo:");

DisplayTimer = milis () + 200; }

prázdna slučka () {

Zámok ();

Pos = obmedzenie (Pos, 0, CodeLength); // tlačidlá čítania int buttonState1 = digitalRead (buttonPin1); int buttonState2 = digitalRead (buttonPin2); int buttonState3 = digitalRead (buttonPin3); int buttonState4 = digitalRead (buttonPin4);

int clButtonState = digitalRead (clearlockbutton); int enterButtonState = digitalRead (enterbutton);

lcd.setCursor (9, 0); // požiadavky na aktiváciu if (buttonState1 == LOW) {Str [Pos] = '1'; Poz ++; Str [Pos] = '\ 0'; oneskorenie (250); while (digitalRead (buttonPin1) == LOW);

}

else if (buttonState2 == LOW) {Str [Pos] = '2'; Poz ++; Str [Pos] = '\ 0'; oneskorenie (250); while (digitalRead (buttonPin2) == LOW);

}

else if (buttonState3 == LOW) {Str [Pos] = '3'; Poz ++; Str [Pos] = '\ 0'; oneskorenie (250); while (digitalRead (buttonPin3) == LOW); }

else if (buttonState4 == LOW) {Str [Pos] = '4'; Poz ++; Str [Pos] = '\ 0'; oneskorenie (250); while (digitalRead (buttonPin4) == LOW);

} else if (enterButtonState == LOW) {Str [Pos] = 'E'; Poz ++; Str [Pos] = '\ 0'; oneskorenie (250); while (digitalRead (buttonPin1) == LOW); if (strcmp (Str, CODE) == 0) {Unlocked = true; lcd.setCursor (0, 0); lcd.print („prístup povolený“); oneskorenie (2000); lcd.clear (); lcd.print ("Odomknutý"); } else if (SaveTimer> millis () && (Pos + 1) == CodeLength) {

strcpy (KÓD, Str); pre (Pos = 0; Pos <= (CodeLength+1); Pos ++) {EEPROM.write (Pos, Str [Pos]); } lcd.setCursor (0, 0); lcd.print („Ukladací kód:“); lcd.setCursor (0, 1); lcd.print (Str);

Odomknutý = true; }

inak {

lcd.clear (); lcd.print („Prístup odmietnutý.“); oneskorenie (2000); lcd.clear (); lcd.print ("Heslo:");

} // odblokovanie kódu pri (Odomknuté) {Unlock (); if (digitalRead (clearlockbutton) == LOW) {delay (200); lcd.clear (); lcd.print („uzamknutý“); oneskorenie (2000); lcd.clear (); Unlocked = false; SaveTimer = milis () + 30 000; }}

ClearCode ();

}

else if (clButtonState == LOW) {oneskorenie (500);

while (clearlockbutton == LOW); if ((milis () - SaveTimer)> 4500) {

}

ClearCode ();

}

if ((long) (millis () - DisplayTimer)> = 0) {DisplayTimer += DisplayDelay; lcd.setCursor (9, 0); lcd.print (Str); lcd.print ("");

} }

zrušiť ClearCode () {

Pozícia = 0; Str [Pos] = '\ 0'; lcd.setCursor (0, 0); lcd.print ("Heslo:"); lcd.setCursor (0, 1); lcd.print ("");

}

zrušiť Odomknúť () {

myServo.write (150);

} // tlačidlo uzamknutia programu neplatné Lock () {

myServo.write (50);

}

Krok 3:

keď je všetko hotové, malo by to vyzerať takto.

Odporúča: