Sisukord:

Seif: 3 sammu
Seif: 3 sammu

Video: Seif: 3 sammu

Video: Seif: 3 sammu
Video: Оружейный сейф своими руками. 2024, Juuli
Anonim
Turvakast
Turvakast
Turvakast
Turvakast
Turvakast
Turvakast

Selline peaks olema teie lõpptulemus pärast selle kokkupanemist ja koodi üleslaadimist.

Samm: asjad, mida vajate

Asjad, mida vajate
Asjad, mida vajate
Asjad, mida vajate
Asjad, mida vajate
Asjad, mida vajate
Asjad, mida vajate
Asjad, mida vajate
Asjad, mida vajate

Jumper traadid, 220 OHM takisti, 16x2 LCD -ekraan, nupud, servomootor, leivalaud, Arduino Uno.

2. samm: kood

James chinchay

#kaasake

#kaasama #kaasama

int aadress = 0; staatiline allkirjata pikk SaveTimer; staatiline allkirjastamata pikk SaveDelay = (30 * 1000);

sümbol KOOD [10] = "1234E"; char Str [10]; char CodeLength = 4; int Pos = 0; bool lukustamata; staatiline allkirjata pikk DisplayTimer; staatiline allkirjata pikk DisplayDelay = 200;

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

int nuppPin1 = 2; int nuppPin2 = 3; int nuppPin3 = 4; int nuppPin4 = 5;

int sisestusnupp = 10; int clearlockbutton = 13;

Servo myServo; // konstrueerimisprogrammi seadistamine void setup () {

myServo.attach (A1);

int EEPROMCodeOK = tõene; for (Pos = 0; Pos <= (CodeLength); Pos ++) {Str [Pos] = EEPROM.read (Pos); if (! (strrchr ("1123456789", Str [Pos])))) {// pole kehtiv kood EEPROMCodeOK = false; }} Pos ++; Str [Pos] = EEPROM.read (Pos); kui (Str [CodeLength + 1]! = 'E') EEPROMCodeOK = false; if (EEPROMCodeOK) {Str [CodeLength + 2] = '\ 0'; strncpy (CODE, Str, CodeLength + 1); } ClearCode (); // sisendite seadistamine pinMode (buttonPin1, INPUT_PULLUP); pinMode (buttonPin2, INPUT_PULLUP); pinMode (buttonPin3, INPUT_PULLUP); pinMode (buttonPin4, INPUT_PULLUP);

pinMode (sisestusnupp, INPUT_PULLUP); pinMode (selge lukustusnupp, INPUT_PULLUP);

lcd.algus (16, 2); lcd.setCursor (0, 0); // sõnumi lcd.print seadistamine ("Tere härra kask"); viivitus (2000); lcd.clear (); lcd.setCursor (0, 0); // parooli seadistamine lcd.print ("Parool:");

DisplayTimer = millis () + 200; }

void loop () {

Lukk ();

Pos = piirata (Pos, 0, CodeLength); // lugemisnupud 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); // aktiveerimisnõuded, kui (buttonState1 == LOW) {Str [Pos] = '1'; Pos ++; Str [Pos] = '\ 0'; viivitus (250); while (digitalRead (buttonPin1) == LOW);

}

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

}

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

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

} else if (enterButtonState == LOW) {Str [Pos] = 'E'; Pos ++; Str [Pos] = '\ 0'; viivitus (250); while (digitalRead (buttonPin1) == LOW); if (strcmp (Str, CODE) == 0) {Lukustamata = true; lcd.setCursor (0, 0); lcd.print ("Juurdepääs lubatud"); viivitus (2000); lcd.clear (); lcd.print ("Lukustamata"); } muu, kui (SaveTimer> millis () && (Pos + 1) == CodeLength) {

strcpy (CODE, Str); for (Pos = 0; Pos <= (CodeLength+1); Pos ++) {EEPROM.write (Pos, Str [Pos]); } lcd.setCursor (0, 0); lcd.print ("Salvestuskood:"); lcd.setCursor (0, 1); lcd.print (Str);

Lukustamata = tõsi; }

muu {

lcd.clear (); lcd.print ("Juurdepääs keelatud."); viivitus (2000); lcd.clear (); lcd.print ("Parool:");

} // koodi avamine samas (Unlocked) {Unlock (); if (digitalRead (clearlockbutton) == LOW) {delay (200); lcd.clear (); lcd.print ("Lukustatud"); viivitus (2000); lcd.clear (); Lukustamata = vale; SaveTimer = millis () + 30000; }}

ClearCode ();

}

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

while (clearlockbutton == LOW); kui ((millis () - SaveTimer)> 4500) {

}

ClearCode ();

}

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

} }

tühine ClearCode () {

Pos = 0; Str [Pos] = '\ 0'; lcd.setCursor (0, 0); lcd.print ("Parool:"); lcd.setCursor (0, 1); lcd.print ("");

}

tühine avamine () {

myServo.write (150);

} // programmi lukustusnupp tühine Lock () {

myServo.write (50);

}

3. samm:

kui kõik on tehtud, peaks see välja nägema selline.

Soovitan: