תוכן עניינים:

כספת: 3 שלבים
כספת: 3 שלבים

וִידֵאוֹ: כספת: 3 שלבים

וִידֵאוֹ: כספת: 3 שלבים
וִידֵאוֹ: איפוס קוד כספת - איך תאפסו את הכספת שלכם בכמה שלבים פשוטים 2024, יולי
Anonim
כספת
כספת
כספת
כספת
כספת
כספת

זוהי התוצאה הסופית שלך שצריכה להיות לאחר חיבור והעלאת הקוד.

שלב 1: דברים שתצטרך

דברים שתצטרך
דברים שתצטרך
דברים שתצטרך
דברים שתצטרך
דברים שתצטרך
דברים שתצטרך
דברים שתצטרך
דברים שתצטרך

חוטי מגשר, נגד 220 OHM, מסך LCD בגודל 16x2, לחצני לחיצה, מנוע סרוו, לוח לחם, Arduino Uno.

שלב 2: קוד

ג'יימס צ'ינצ'אי

#לִכלוֹל

#כלול #כלול

int address = 0; סטטי לא ארוך חתום סטטי; סטטי ארוך ללא חתימה SaveDelay = (30 * 1000);

char CODE [10] = "1234E"; char Str [10]; char CodeLength = 4; int Pos = 0; בול נעולה; סטטי DisplayTimer ארוך וחתום סטטי; סטטי 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 clearlock = 13;

סרוו myServo; // הגדרת תוכנית לבנות הגדרת חלל () {

myServo.attach (A1);

int EEPROMCodeOK = true; עבור (Pos = 0; Pos <= (CodeLength); Pos ++) {Str [Pos] = EEPROM.read (Pos); if (! (strrchr ("1123456789", Str [Pos]))) {// לא קוד חוקי EEPROMCodeOK = false; }} Pos ++; Str [Pos] = EEPROM.read (Pos); if (Str [CodeLength + 1]! = 'E') EEPROMCodeOK = false; if (EEPROMCodeOK) {Str [CodeLength + 2] = '\ 0'; strncpy (CODE, Str, CodeLength + 1); } ClearCode (); // הגדרת כניסות pinMode (buttonPin1, INPUT_PULLUP); pinMode (buttonPin2, INPUT_PULLUP); pinMode (buttonPin3, INPUT_PULLUP); pinMode (buttonPin4, INPUT_PULLUP);

pinMode (enterbutton, INPUT_PULLUP); pinMode (כפתור clearlock, INPUT_PULLUP);

lcd.begin (16, 2); lcd.setCursor (0, 0); // הגדרת lcd.print בהודעות ("שלום מר ליבנה"); עיכוב (2000); lcd.clear (); lcd.setCursor (0, 0); // הגדרת בקשת סיסמה lcd.print ("סיסמא:");

DisplayTimer = מיליס () + 200; }

לולאת חלל () {

לנעול();

Pos = אילוץ (Pos, 0, CodeLength); // כפתורי קריאה 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); // דרישות להפעלה אם (buttonState1 == LOW) {Str [Pos] = '1'; Pos ++; Str [Pos] = '\ 0'; עיכוב (250); while (digitalRead (buttonPin1) == LOW);

}

אחרת אם (buttonState2 == LOW) {Str [Pos] = '2'; Pos ++; Str [Pos] = '\ 0'; עיכוב (250); while (digitalRead (buttonPin2) == LOW);

}

אחרת אם (buttonState3 == LOW) {Str [Pos] = '3'; Pos ++; Str [Pos] = '\ 0'; עיכוב (250); while (digitalRead (buttonPin3) == LOW); }

אחרת אם (buttonState4 == LOW) {Str [Pos] = '4'; Pos ++; Str [Pos] = '\ 0'; עיכוב (250); while (digitalRead (buttonPin4) == LOW);

} אחרת אם (enterButtonState == LOW) {Str [Pos] = 'E'; Pos ++; Str [Pos] = '\ 0'; עיכוב (250); while (digitalRead (buttonPin1) == LOW); if (strcmp (Str, CODE) == 0) {Unlocked = true; lcd.setCursor (0, 0); lcd.print ("גישה ניתנת"); עיכוב (2000); lcd.clear (); lcd.print ("לא נעול"); } אחרת אם (SaveTimer> millis () && (Pos + 1) == CodeLength) {

strcpy (CODE, Str); עבור (Pos = 0; Pos <= (CodeLength+1); Pos ++) {EEPROM.write (Pos, Str [Pos]); } lcd.setCursor (0, 0); lcd.print ("קוד שמירה:"); lcd.setCursor (0, 1); lcd.print (Str);

נעולה = נכון; }

אחר {

lcd.clear (); lcd.print ("גישה נדחתה."); עיכוב (2000); lcd.clear (); lcd.print ("סיסמא:");

} // ביטול נעילת קוד בזמן (Unlocked) {Unlock (); if (digitalRead (clearlockbutton) == LOW) {עיכוב (200); lcd.clear (); lcd.print ("נעול"); עיכוב (2000); lcd.clear (); Unlocked = false; SaveTimer = millis () + 30000; }}

ClearCode ();

}

אחרת אם (clButtonState == LOW) {עיכוב (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 ("");

} }

בטל ClearCode () {

Pos = 0; Str [Pos] = '\ 0'; lcd.setCursor (0, 0); lcd.print ("סיסמא:"); lcd.setCursor (0, 1); lcd.print ("");

}

בטל נעילה () {

myServo.write (150);

} // לחצן נעילת התוכנית חלל נעילה () {

myServo.write (50);

}

שלב 3:

בסיום הכל זה אמור להיראות כך.

מוּמלָץ: