Problem with fingerprint sensor and blynk
Hello.
actually my program has the same error as Problem with fingerprint sensor and blynk. I have tried what was told there, and I still could not finish my program, this is my program
#include <Adafruit_Fingerprint.h>
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include <SoftwareSerial.h>
LiquidCrystal_I2C lcd (0x27,16,2);
SoftwareSerial ArduinoUno (9, 10);
SoftwareSerial mySerial(4, 5);
Adafruit_Fingerprint finger = Adafruit_Fingerprint(&mySerial);
int Buzzer = 3;
int RELAY_1 = 8;
int Laser = 6;
int Detector = 7;
int sensorsentuh = 13;
int nilaisensor;
int idFinger;
#define RELAY_ON 0
#define RELAY_OFF 1
boolean currentState = LOW;
boolean lastState = LOW;
boolean RelayState = LOW;
void setup() {
Serial.begin(9600);
finger.begin(57600);
digitalWrite(RELAY_1, RELAY_OFF);
pinMode(sensorsentuh, INPUT);
pinMode(Buzzer, OUTPUT);
pinMode(RELAY_1, OUTPUT);
pinMode(Laser, OUTPUT);
pinMode(Detector, INPUT);
digitalWrite(Laser, HIGH);
digitalWrite(Detector, HIGH);
digitalWrite(Buzzer, LOW);
digitalWrite(RELAY_1, HIGH);
if (finger.verifyPassword()) {
Serial.println("FingerPrint Sensor Ditemukan!");
lcd.begin();
lcd.print("Put Your Finger");
} else {
Serial.println("FingerPrint Sensor Tidak Ditemukan! :(");
while (1) {
delay(1);
}
}
ArduinoUno.begin(4800);
}
void loop() {
if(RelayState == LOW){
detector();
}
while (ArduinoUno.available() > 0) {
int val = ArduinoUno.parseInt();
if (ArduinoUno.read() == '\n') {
Serial.println(val);
if (val == HIGH) {
digitalWrite(RELAY_1, RELAY_ON);
RelayState = HIGH;
digitalWrite(Laser, LOW);
boolean val = digitalRead(Detector);
Serial.println(val);
}
else {
digitalWrite(RELAY_1, RELAY_OFF);
RelayState = LOW;
digitalWrite(Detector, LOW); //detektor mati
digitalWrite(Laser, LOW); //laser mati
}
}
}
//Proses Input Fingerprint
FINGERPRINT();
if (idFinger >= 0) {
digitalWrite(RELAY_1, LOW); //Pintu kebuka
digitalWrite(Detector, LOW); //detektor mati
digitalWrite(Laser, LOW); //laser mati
lcd.begin(); //lcd nyala
lcd.print("silahkan masuk");
lcd.setCursor (0,1);
lcd.print("tutup kembali");
delay(5000); //delay 5 detik
lcd.clear();
digitalWrite(RELAY_1, HIGH);
}
currentState = digitalRead(sensorsentuh);
if (currentState == HIGH && lastState == LOW) {
Serial.println("pressed");
delay(1);
if (RelayState == HIGH) {
/*delay (5000);*/
digitalWrite(RELAY_1, RELAY_OFF);
RelayState = LOW;
digitalWrite(Detector, LOW); //detektor mati
digitalWrite(Laser, LOW); //laser mati
lcd.begin();
lcd.setCursor (0,1);
lcd.print("sistem menyala");
lcd.print("kembali");
} else {
digitalWrite(RELAY_1, RELAY_ON);
RelayState = HIGH;
digitalWrite(Laser, LOW);
boolean val = digitalRead(Detector);
Serial.println(val);
lcd.begin();
lcd.setCursor (0,1);
lcd.print("sistem sedang");
lcd.print("dimatikan");
}
}
lastState = currentState;
}
void detector() {
int detected = digitalRead(Detector);// read Laser sensor
if( detected == LOW){
digitalWrite(Buzzer,HIGH);// set the buzzer ON
Serial.println("Detected!");
}else{
digitalWrite(Buzzer,LOW); // Set the buzzer OFF
Serial.println("No laser");
// Laser Sensor code for Robojax.com
}
//delay(200);
{
digitalWrite(Laser, HIGH);
boolean val = digitalRead(Detector);
Serial.println(val);
}
}
/*void NodeMCU(){
while (ArduinoUno.available() > 0) {
int pal = ArduinoUno.parseInt();
if (ArduinoUno.read() == '\n') {
Serial.println(pal);
if (pal == HIGH) {
digitalWrite(RELAY_1, RELAY_ON);
RelayState = HIGH;
digitalWrite(Laser, LOW);
boolean pal = digitalRead(Detector);
Serial.println(pal);
}
else {
digitalWrite(RELAY_1, RELAY_OFF);
RelayState = LOW;
digitalWrite(Detector, LOW); //detektor mati
digitalWrite(Laser, LOW); //laser mati
}
}
}
}*/
//----------------------------------------------------FINGERPRINT----------------------------------------------//
void FINGERPRINT() {
idFinger = getFingerprintIDez();
delay(50);
}
//----------------------------------------------------PROSES FINGERPRINT--------------------------------------//
uint8_t getFingerprintID() {
uint8_t p = finger.getImage();
switch (p) {
case FINGERPRINT_OK:
Serial.println("Image taken");
break;
case FINGERPRINT_NOFINGER:
Serial.println("No finger detected");
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");
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);
return finger.fingerID;
}
// returns -1 if failed, otherwise returns ID #
int getFingerprintIDez() {
uint8_t p = finger.getImage();
if (p != FINGERPRINT_OK) return -1;
p = finger.image2Tz();
if (p != FINGERPRINT_OK) return -1;
p = finger.fingerFastSearch();
if (p != FINGERPRINT_OK) return -1;
// found a match!
Serial.print("Found ID #"); Serial.print(finger.fingerID);
Serial.print(" with confidence of "); Serial.println(finger.confidence);
return finger.fingerID;
}
//--------------------------------END FINGERPRINT----------------------------------------------//
I am a beginner, I do not know my mistake where in making the program above, I am very grateful if you can help me