Sadržaj:

Sef: 3 koraka
Sef: 3 koraka

Video: Sef: 3 koraka

Video: Sef: 3 koraka
Video: ▶️ Двойная ложь 3 и 4 серия | Сериал / 2018 / Мелодрама 2024, Juli
Anonim
Sef
Sef
Sef
Sef
Sef
Sef

Ovo bi vaš konačni rezultat trebao biti nakon sastavljanja i učitavanja koda.

Korak 1: Stvari koje će vam trebati

Stvari koje će vam trebati
Stvari koje će vam trebati
Stvari koje će vam trebati
Stvari koje će vam trebati
Stvari koje će vam trebati
Stvari koje će vam trebati
Stvari koje će vam trebati
Stvari koje će vam trebati

Žice kratkospojnika, otpornik 220 OHM, LCD ekran 16x2, dugmad, servo motor, iverica, Arduino Uno.

Korak 2: Kodirajte

James chinchay

#include

#include #include

int adresa = 0; statički nepotpisani dugi SaveTimer; statički nepotpisani dugi SaveDelay = (30 * 1000);

char CODE [10] = "1234E"; char Str [10]; char CodeLength = 4; int Pos = 0; bool Otključano; statički nepotpisani dugi DisplayTimer; statički nepotpisani dugi DisplayDelay = 200;

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

int buttonPin1 = 2; int buttonPin2 = 3; int buttonPin3 = 4; int buttonPin4 = 5;

int enterbutton = 10; int clearlockbutton = 13;

Servo myServo; // postavljanje programa za izgradnju void setup () {

myServo.attach (A1);

int EEPROMCodeOK = true; for (Pos = 0; Pos <= (CodeLength); Pos ++) {Str [Pos] = EEPROM.čitano (Pos); if (! (strrchr ("1123456789", Str [Pos]))) {// nije važeći kôd EEPROMCodeOK = false; }} Pos ++; Str [Pos] = EEPROM.čitano (Poz); if (Str [CodeLength + 1]! = 'E') EEPROMCodeOK = false; if (EEPROMCodeOK) {Str [CodeLength + 2] = '\ 0'; strncpy (CODE, Str, CodeLength + 1); } ClearCode (); // postavljanje ulaza 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); // postavljanje poruka s lcd.print ("Zdravo gospodine Birch"); kašnjenje (2000); lcd.clear (); lcd.setCursor (0, 0); // postavljanje upita za lozinku lcd.print ("Lozinka:");

DisplayTimer = millis () + 200; }

void loop () {{100} {101}

Lock ();

Pos = ograničiti (Pos, 0, CodeLength); // dugmad za čitanje int buttonState1 = digitalRead (buttonPin1); int buttonState2 = digitalRead (buttonPin2); int buttonState3 = digitalRead (buttonPin3); int buttonState4 = digitalRead (buttonPin4);

int clButtonState = digitalRead (dugme za brisanje); int enterButtonState = digitalRead (enterbutton);

lcd.setCursor (9, 0); // zahtjevi za aktiviranje if (buttonState1 == LOW) {Str [Pos] = '1'; Pos ++; Str [Pos] = '\ 0'; kašnjenje (250); while (digitalRead (buttonPin1) == LOW);

}

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

}

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

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

} else if (enterButtonState == LOW) {Str [Pos] = 'E'; Pos ++; Str [Pos] = '\ 0'; kašnjenje (250); while (digitalRead (buttonPin1) == LOW); if (strcmp (Str, CODE) == 0) {Otključano = tačno; lcd.setCursor (0, 0); lcd.print ("Pristup odobren"); kašnjenje (2000); lcd.clear (); lcd.print ("Otključano"); } else if (SaveTimer> millis () && (Pos + 1) == CodeLength) {{100} {101}

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

Otključano = tačno; }

else {

lcd.clear (); lcd.print ("Pristup odbijen."); kašnjenje (2000); lcd.clear (); lcd.print ("Lozinka:");

} // otključavanje koda dok je (Otključano) {Otključano (); if (digitalRead (clearlockbutton) == LOW) {odgoda (200); lcd.clear (); lcd.print ("Zaključano"); kašnjenje (2000); lcd.clear (); Otključano = netačno; SaveTimer = millis () + 30000; }}

ClearCode ();

}

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

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

}

ClearCode ();

}

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

} }

void ClearCode () {

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

}

void Otključaj () {

myServo.write (150);

} // dugme za zaključavanje programa void Lock () {

myServo.write (50);

}

Korak 3:

kada se sve uradi trebalo bi da izgleda ovako.

Preporučuje se: