This shows you the differences between two versions of the page.
pm:prj2023:abirlica:andreigabriel [2023/05/28 17:43] gabriel.andrei1707 [Software Design] |
pm:prj2023:abirlica:andreigabriel [2023/05/28 17:54] (current) gabriel.andrei1707 [Concluzii] |
||
---|---|---|---|
Line 52: | Line 52: | ||
Adafruit_Fingerprint finger = Adafruit_Fingerprint(&mySerial); | Adafruit_Fingerprint finger = Adafruit_Fingerprint(&mySerial); | ||
- | |||
- | int val; // variable to read the value from the analog pin | ||
int fingerprintID = 0; | int fingerprintID = 0; | ||
Line 123: | Line 121: | ||
myservo.write(180); | myservo.write(180); | ||
+ | } | ||
+ | </note> | ||
+ | |||
+ | Main function | ||
+ | <note tip> | ||
+ | void loop() { | ||
+ | | ||
+ | previousButtonState = presentButtonState; | ||
+ | presentButtonState = digitalRead(buttonPinPass); | ||
+ | |||
+ | while(ultrasonic.read() < 50 && !ledState){ | ||
+ | tone(buzzer, NOTE_D8, 10); // alarm on | ||
+ | delay(50); | ||
+ | } | ||
+ | |||
+ | if(previousButtonState == HIGH && presentButtonState == LOW) {/* if the previous state is the HIGH and present state is LOW then */ | ||
+ | int found = 1; | ||
+ | |||
+ | while(finger.getImage() != FINGERPRINT_OK && ledState != HIGH){ | ||
+ | previousButtonState = presentButtonState; | ||
+ | presentButtonState = digitalRead(buttonPinPass); | ||
+ | if(previousButtonState == HIGH && presentButtonState == LOW) { | ||
+ | found = 0; | ||
+ | break; | ||
+ | } | ||
+ | delay(100); | ||
+ | |||
+ | } | ||
+ | | ||
+ | if(found){ | ||
+ | // found a match! | ||
+ | Serial.print("Found ID #"); | ||
+ | Serial.print(finger.fingerID); | ||
+ | |||
+ | ledState = !ledState; // change the state of the LED | ||
+ | |||
+ | digitalWrite(ledPin, ledState); /* write that changed state to the LED */ | ||
+ | |||
+ | // move the servo | ||
+ | if(ledState){ | ||
+ | // open door | ||
+ | for (int pos = 180; pos >= 90; pos -= 1) { | ||
+ | myservo.write(pos); | ||
+ | delay(15); | ||
+ | } | ||
+ | } | ||
+ | else{ | ||
+ | // close door | ||
+ | for (int pos = 90; pos <= 180; pos += 1) { | ||
+ | myservo.write(pos); | ||
+ | delay(15); | ||
+ | } | ||
+ | } | ||
+ | } | ||
+ | |||
+ | } | ||
+ | |||
+ | // play song | ||
+ | if(digitalRead(buttonPinAlarm) == HIGH){ | ||
+ | buzz_function(); | ||
+ | } | ||
+ | | ||
} | } | ||
</note> | </note> | ||
Line 131: | Line 191: | ||
</note> | </note> | ||
+ | <note tip> | ||
+ | Pentru realizarea proiectului am folosit urmatoarele biblioteci: | ||
+ | #include <Adafruit_Fingerprint.h> | ||
+ | |||
+ | #include <Servo.h> | ||
+ | |||
+ | #include <Ultrasonic.h> | ||
+ | |||
+ | |||
+ | Am conectat senzorul fingerprint la pinii care permit comunicarea cu placa Arduino. | ||
+ | Servo motorul deschide si inchide usa de carton. | ||
+ | </note> | ||
===== Download ===== | ===== Download ===== | ||
<note warning> | <note warning> | ||
+ | |||
+ | |||
+ | |||
+ | https://github.com/GabrielAndrei17/Proiect-PM | ||
</note> | </note> |