Sisällysluettelo:

Tallelokero: 3 vaihetta
Tallelokero: 3 vaihetta

Video: Tallelokero: 3 vaihetta

Video: Tallelokero: 3 vaihetta
Video: Näin onnistut pistoolikyykyssä! - 3 vaihetta 2024, Heinäkuu
Anonim
Tallelokero
Tallelokero
Tallelokero
Tallelokero
Tallelokero
Tallelokero

Tämän lopputuloksen pitäisi olla sen kokoamisen ja koodin lataamisen jälkeen.

Vaihe 1: Tarvitsemasi asiat

Asioita, joita tarvitset
Asioita, joita tarvitset
Asioita, joita tarvitset
Asioita, joita tarvitset
Asioita, joita tarvitset
Asioita, joita tarvitset
Asioita, joita tarvitset
Asioita, joita tarvitset

Hyppyjohdot, 220 OHM vastus, 16x2 LCD -näyttö, painikkeet, servomoottori, leipälauta, Arduino Uno.

Vaihe 2: Koodi

James chinchay

#sisältää

#Sisällytä #Sisällytä

int -osoite = 0; staattinen allekirjoittamaton pitkä SaveTimer; staattinen allekirjoittamaton pitkä SaveDelay = (30 * 1000);

char CODE [10] = "1234E"; char Str [10]; char CodeLength = 4; int Pos = 0; bool Avattu; staattinen allekirjoittamaton pitkä DisplayTimer; staattinen allekirjoittamaton pitkä DisplayDelay = 200;

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

int -painikePin1 = 2; int -painikePin2 = 3; int -painikePin3 = 4; int -painikePin4 = 5;

int enterbutton = 10; int clearlockbutton = 13;

Servo myServo; // konstruointiohjelman määrittäminen void setup () {

myServo.attach (A1);

int EEPROMCodeOK = tosi; for (Pos = 0; Pos <= (CodeLength); Pos ++) {Str [Pos] = EEPROM.read (Pos); if (! (strrchr ("1123456789", Str [Pos])))) {// ei kelvollinen koodi EEPROMCodeOK = false; }} Pos ++; Str [Pos] = EEPROM.read (Pos); jos (Str [CodeLength + 1]! = 'E') EEPROMCodeOK = false; if (EEPROMCodeOK) {Str [CodeLength + 2] = '\ 0'; strncpy (CODE, Str, CodeLength + 1); } ClearCode (); // tulojen määrittäminen pinMode (buttonPin1, INPUT_PULLUP); pinMode (buttonPin2, INPUT_PULLUP); pinMode (buttonPin3, INPUT_PULLUP); pinMode (buttonPin4, INPUT_PULLUP);

pinMode (enter -painike, INPUT_PULLUP); pinMode (Clearlock -painike, INPUT_PULLUP);

lcd. alku (16, 2); lcd.setCursor (0, 0); // viestien lcd.print ("Hei herra Birch") asettaminen; viive (2000); lcd.clear (); lcd.setCursor (0, 0); // salasanakehotteen asettaminen lcd.print ("Salasana:");

DisplayTimer = millis () + 200; }

void loop () {

Lukko();

Pos = rajoittaa (Pos, 0, CodeLength); // lukupainikkeet 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); // aktivointivaatimukset, jos (buttonState1 == LOW) {Str [Pos] = '1'; Pos ++; Str [Pos] = '\ 0'; viive (250); while (digitalRead (buttonPin1) == LOW);

}

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

}

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

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

} else if (enterButtonState == LOW) {Str [Pos] = 'E'; Pos ++; Str [Pos] = '\ 0'; viive (250); while (digitalRead (buttonPin1) == LOW); if (strcmp (Str, CODE) == 0) {Avattu = true; lcd.setCursor (0, 0); lcd.print ("Pääsy myönnetty"); viive (2000); lcd.clear (); lcd.print ("Avattu"); } muu jos (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 ("Tallennuskoodi:"); lcd.setCursor (0, 1); lcd.print (Str);

Lukitsematon = totta; }

muu {

lcd.clear (); lcd.print ("Pääsy estetty."); viive (2000); lcd.clear (); lcd.print ("Salasana:");

} // koodin lukituksen avaaminen (Unlocked) {Unlock (); if (digitalRead (clearlockbutton) == LOW) {delay (200); lcd.clear (); lcd.print ("Lukittu"); viive (2000); lcd.clear (); Avattu = epätosi; SaveTimer = millis () + 30000; }}

ClearCode ();

}

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

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

}

ClearCode ();

}

if ((pitkä) (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 ("Salasana:"); lcd.setCursor (0, 1); lcd.print ("");

}

void Unlock () {

myServo.write (150);

} // ohjelman lukituspainike void Lock () {

myServo.write (50);

}

Vaihe 3:

kun kaikki on tehty, sen pitäisi näyttää tältä.

Suositeltava: