Arduino Fingerprint based attendance system
Here is an example of an Arduino code that could be used to implement a fingerprint-based attendance system:
#include <Adafruit_Fingerprint.h>
#include <SoftwareSerial.h>
#define rxPin 2
#define txPin 3
#define ledPin 13
SoftwareSerial fingerprintSerial(rxPin, txPin);
Adafruit_Fingerprint finger = Adafruit_Fingerprint(&fingerprintSerial);
int id;
void setup() {
// initialize serial communication and the fingerprint sensor
Serial.begin(9600);
fingerprintSerial.begin(57600);
// initialize the LED pin as an output
pinMode(ledPin, OUTPUT);
// reset the fingerprint sensor and check its status
if (finger.begin()) {
Serial.println("Fingerprint sensor initialized");
} else {
Serial.println("Error initializing fingerprint sensor");
}
}
void loop() {
// check if there is a fingerprint to be read
id = finger.getImage();
if (id == FINGERPRINT_OK) {
// image captured successfully
Serial.println("Image captured successfully");
// create a template from the image
id = finger.createTemplate();
if (id == FINGERPRINT_OK) {
// template created successfully
Serial.println("Template created successfully");
// search the fingerprint database for a match
id = finger.searchTemplate();
if (id == FINGERPRINT_OK) {
// fingerprint found in database
Serial.println("Fingerprint found in database");
digitalWrite(ledPin, HIGH); // turn on the LED
delay(1000); // wait for 1 second
digitalWrite(ledPin, LOW); // turn off the LED
} else {
// fingerprint not found in database
Serial.println("Fingerprint not found in database");
}
} else {
// error creating template
Serial.println("Error creating template");
}
} else if (id == FINGERPRINT_NOFINGER) {
// no fingerprint detected
Serial.println("No fingerprint detected");
} else if (id == FINGERPRINT_PACKETRECIEVEERR) {
// error receiving data from the fingerprint sensor
Serial.println("Error receiving data from fingerprint sensor");
} else if (id == FINGERPRINT_IMAGEFAIL) {
// error capturing fingerprint image
Serial.println("Error capturing fingerprint image");
}
}
This code uses the Adafruit Fingerprint library to communicate with a fingerprint sensor via a software serial connection. It captures an image of the fingerprint, creates a template from the image, and searches a fingerprint database for a match. If a match is found, it turns on an LED for one second to indicate that the attendance has been recorded.
Note that this code is just an example and may need to be modified to work with your specific fingerprint sensor and application requirements. For example, you may need to adjust the baud rate and pin connections to match your hardware setup, and you may need to add code to store and retrieve fingerprint data from a database or other storage mechanism.
Comments
Post a Comment