Halo, saya memiliki masalah dalam menggunakan 2 sensor fingerprint AS608 dalam 1 Arduino UNO. apabila hanya 1 sensor saja yang diaktifkan, sensor dapat terbaca pada serial monitor dan dapat digunakan. namun jika 2 sensor yang diaktifkan, sensor tidak terbaca (device not found) dan tidak dapat digunakan.
Dan saya memiliki masalah juga tentang reset sidik jari menggunakan button.
Adakah yang dapat membantu saya? Berikut program saya untuk 2 sensor fingerprint ini
#include <Adafruit_Fingerprint.h>
#include <SoftwareSerial.h>
SoftwareSerial mySerial(4, 5);
SoftwareSerial mySerial2(2, 3); // Define another SoftwareSerial instance for the second fingerprint module
Adafruit_Fingerprint finger = Adafruit_Fingerprint(&mySerial);
Adafruit_Fingerprint finger2 = Adafruit_Fingerprint(&mySerial2); // Create an instance for the second fingerprint module
const int buttonPin = 4; // Assign the button switch to pin 4
void setup()
{
Serial.begin(9600);
while (!Serial);
delay(100);
pinMode(9, OUTPUT);
pinMode(10, OUTPUT);
pinMode(buttonPin, INPUT_PULLUP);
Serial.println("Program Dasar Akses Sidik Jari Arduino");
finger.begin(57600);
finger2.begin(57600); // Initialize the second fingerprint module
if (finger.verifyPassword() && finger2.verifyPassword())
{
Serial.println("Found fingerprint sensors!");
}
else
{
Serial.println("Did not find fingerprint sensors :(");
while (1) { delay(1); }
}
Serial.println("Waiting for valid finger...");
}
void loop()
{
if (digitalRead(buttonPin) == LOW)
{
addFingerprint();
delay(1000); // Debounce delay to avoid multiple reads
}
else
{
getFingerprintID();
}
}
uint8_t getFingerprintID()
{
uint8_t p = finger.getImage();
switch (p)
{
case FINGERPRINT_OK:
Serial.println("Image taken");
break;
case FINGERPRINT_NOFINGER:
//Serial.println(".");
return p;
case FINGERPRINT_PACKETRECIEVEERR:
Serial.println("Communication error");
return p;
case FINGERPRINT_IMAGEFAIL:
Serial.println("Imaging error");
return p;
default:
Serial.println("Unknown error");
return p;
}
// OK success!
p = finger.image2Tz();
switch (p)
{
case FINGERPRINT_OK:
Serial.println("Image converted");
break;
case FINGERPRINT_IMAGEMESS:
Serial.println("Image too messy");
return p;
case FINGERPRINT_PACKETRECIEVEERR:
Serial.println("Communication error");
return p;
case FINGERPRINT_FEATUREFAIL:
Serial.println("Could not find fingerprint features");
return p;
case FINGERPRINT_INVALIDIMAGE:
Serial.println("Could not find fingerprint features");
return p;
default:
Serial.println("Unknown error");
return p;
}
// OK converted!
p = finger.fingerFastSearch();
if (p == FINGERPRINT_OK)
{
Serial.println("Found a print match!");
}
else if (p == FINGERPRINT_PACKETRECIEVEERR)
{
Serial.println("Communication error");
return p;
}
else if (p == FINGERPRINT_NOTFOUND)
{
Serial.println("Did not find a match");
delay(1000);
return p;
}
else
{
Serial.println("Unknown error");
return p;
}
// found a match!
Serial.print("Found ID #"); Serial.print(finger.fingerID);
Serial.print(" with confidence of "); Serial.println(finger.confidence);
digitalWrite(13, HIGH);
delay(3000);
digitalWrite(13, LOW);
return finger.fingerID;
}
void addFingerprint()
{
Serial.println("Put your finger on the sensor to add a new fingerprint...");
while (!finger.getImage())
{
// Wait until a finger is placed on the sensor
}
int fingerprintID = -1;
uint8_t p = finger.image2Tz(1);
if (p == FINGERPRINT_OK)
{
Serial.println("Image captured. Remove your finger.");
delay(2000);
Serial.println("Place the same finger again...");
while (!finger.getImage())
{
// Wait until the same finger is placed on the sensor
}
p = finger.image2Tz(2);
if (p == FINGERPRINT_OK)
{
Serial.println("Fingerprints matched!");
// Store the fingerprint template on the sensor
p = finger.createModel();
if (p == FINGERPRINT_OK)
{
fingerprintID = finger.storeModel(1);
if (fingerprintID != FINGERPRINT_OK)
{
Serial.println("Failed to add fingerprint!");
}
else
{
Serial.print("Fingerprint successfully added! ID: ");
Serial.println(finger.fingerID);
digitalWrite(13, HIGH);
delay(2000);
digitalWrite(13, LOW);
}
}
else
{
Serial.println("Failed to create fingerprint template!");
}
}
else
{
Serial.println("Fingerprints did not match!");
}
}
else
{
Serial.println("Failed to capture image!");
}
}
Tolong bantu saya, Terimakasih