Orodha ya maudhui:

Sanduku salama: 3 Hatua
Sanduku salama: 3 Hatua

Video: Sanduku salama: 3 Hatua

Video: Sanduku salama: 3 Hatua
Video: 3я НОЧЬ В ДОМЕ С ПРИВИДЕНИЯМИ / 3rd NIGHT AT THE HAUNTED HOUSE 2024, Novemba
Anonim
Sanduku salama
Sanduku salama
Sanduku salama
Sanduku salama
Sanduku salama
Sanduku salama

Hii ndio matokeo yako ya mwisho yanapaswa kuwa baada ya kuiweka pamoja na kupakia nambari.

Hatua ya 1: Vitu Utakavyohitaji

Vitu Utakavyohitaji
Vitu Utakavyohitaji
Vitu Utakavyohitaji
Vitu Utakavyohitaji
Vitu Utakavyohitaji
Vitu Utakavyohitaji
Vitu Utakavyohitaji
Vitu Utakavyohitaji

Waya za Jumper, kontena la 220 OHM, Skrini ya LCD 16x2, Vifungo vya kushinikiza, Servo Motor, Breadboard, Arduino Uno.

Hatua ya 2: Kanuni

James chinchay

# pamoja

#jumuisha #jumuisha

anwani ya int = 0; tuli isiyosainiwa kwa muda mrefu SaveTimer; tuli isiyo sainiwa kwa muda mrefu SaveDelay = (30 * 1000);

char CODE [10] = "1234E"; char Str [10]; Char CodeLength = 4; int Pos = 0; bool Imefunguliwa; tuli isiyo sainiwa kwa muda mrefu DisplayTimer; tuli isiyo sainiwa kwa muda mrefu DisplayDelay = 200;

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

kifungo cha intPin1 = 2; kifungo cha ndaniPin2 = 3; kifungo cha ndaniPin3 = 4; kifungo cha ndaniPin4 = 5;

kitufe cha kuingia = 10; kifungo wazi = 13;

Servo myServo; // kuanzisha usanidi wa batili wa mpango wa ujenzi () {

myServo.ambatanisha (A1);

int EEPROMCodeOK = kweli; kwa (Pos = 0; Pos <= (CodeLength); Pos ++) {Str [Pos] = EEPROM.read (Pos); ikiwa (! (strrchr ("1123456789", Str [Pos]))) {// sio nambari halali EEPROMCodeOK = uwongo; }} Pos ++; Str [Pos] = EEPROM.soma (Pos); ikiwa (Str [CodeLength + 1]! = 'E') EEPROMCodeOK = uwongo; ikiwa (EEPROMCodeOK) {Str [CodeLength + 2] = '\ 0'; strncpy (CODE, Str, CodeLength + 1); } ClearCode (); // kuanzisha pembejeo pinMode (buttonPin1, INPUT_PULLUP); pinMode (kifungoPin2, INPUT_PULLUP); pinMode (kifungoPin3, INPUT_PULLUP); pinMode (kifungoPin4, INPUT_PULLUP);

pinMode (kitufe cha kuingiza, INPUT_PULLUP); pinMode (kifungo cha wazi, INPUT_PULLUP);

lcd kuanza (16, 2); lcd.setCursor (0, 0); // kuanzisha lcd iliyochapishwa message ("Hello Mr Birch"); kuchelewa (2000); lcd wazi (); lcd.setCursor (0, 0); // kuanzisha haraka kwa nywila lcd.print ("Nenosiri:");

DisplayTimer = milimita () + 200; }

kitanzi batili () {

Kufuli ();

Pos = kubana (Pos, 0, CodeLength); // vifungo vya kusoma int kifungoState1 = kusoma kwa dijiti (kifungoPin1); kifungo cha ndaniState2 = kusoma kwa dijiti (kifungoPin2); kifungo cha ndaniState3 = kusoma kwa dijiti (kifungoPin3); kifungo cha ndaniState4 = kusoma kwa dijiti (kifungoPin4);

int clButtonState = kusoma kwa dijiti (kitufe cha wazi); int enterButtonState = kusoma kwa dijiti (kitufe cha kuingiza);

lcd.setCursor (9, 0); // mahitaji ya kuamsha ikiwa (buttonState1 == LOW) {Str [Pos] = '1'; Pos ++; Str [Pos] = '\ 0'; kuchelewesha (250); wakati (digitalRead (buttonPin1) == LOW);

}

vinginevyo ikiwa (buttonState2 == LOW) {Str [Pos] = '2'; Pos ++; Str [Pos] = '\ 0'; kuchelewesha (250); wakati (digitalRead (buttonPin2) == LOW);

}

vinginevyo ikiwa (buttonState3 == LOW) {Str [Pos] = '3'; Pos ++; Str [Pos] = '\ 0'; kuchelewesha (250); wakati (digitalRead (buttonPin3) == LOW); }

vinginevyo ikiwa (buttonState4 == LOW) {Str [Pos] = '4'; Pos ++; Str [Pos] = '\ 0'; kuchelewesha (250); wakati (digitalRead (buttonPin4) == LOW);

} mwingine ikiwa (enterButtonState == LOW) {Str [Pos] = 'E'; Pos ++; Str [Pos] = '\ 0'; kuchelewesha (250); wakati (digitalRead (buttonPin1) == LOW); ikiwa (strcmp (Str, CODE) == 0) {Imefunguliwa = kweli; lcd.setCursor (0, 0); lcd.print ("Ufikiaji Umepewa"); kuchelewa (2000); lcd wazi (); lcd.print ("Imefunguliwa"); } vingine ikiwa (SaveTimer> millis () && (Pos + 1) == CodeLength) {

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

Imefunguliwa = kweli; }

mwingine {

lcd wazi (); lcd.print ("Ufikiaji Umekataliwa."); kuchelewa (2000); lcd wazi (); lcd.print ("Nenosiri:");

} // kufungua nambari wakati (Imefunguliwa) {Kufungua (); ikiwa (digitalRead (clearlockbutton) == LOW) {kuchelewa (200); lcd wazi (); lcd.print ("Imefungwa"); kuchelewa (2000); lcd wazi (); Imefunguliwa = uwongo; SaveTimer = milimita () + 30000; }}

ClearCode ();

}

vinginevyo ikiwa (clButtonState == LOW) {kuchelewa (500);

wakati (clearlockbutton == LOW); ikiwa ((millis () - SaveTimer)> 4500) {

}

ClearCode ();

}

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

} }

batili ClearCode () {

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

}

Kufungua batili () {

andika (150);

} // kifungo cha kufunga mpango batili Lock () {

andika (50);

}

Hatua ya 3:

ikifanywa kila kitu inapaswa kuonekana kama hii.

Ilipendekeza: