I have tried to use this code but I keep getting error " SoftwareSerial does not have a type"
I have tried to follow this tutorial
int getFingerprintIDez();
// pin #2 is IN from sensor (GREEN wire)
// pin #3 is OUT from arduino (WHITE wire)
SoftwareSerial mySerial(2, 3);
LiquidCrystal lcd(9, 8, 7, 6, 5, 4); // initialize the library with the numbers of the interface pins
Adafruit_Fingerprint finger = Adafruit_Fingerprint(&mySerial);
void setup()
{ Serial.begin(9600); // initialize the serial communications:
lcd.begin(16,2); lcd.setCursor(0,0); lcd.print("Scan your finger");
pinMode(13,OUTPUT);
pinMode(12,OUTPUT);
pinMode(11, OUTPUT);
pinMode(A0, INPUT);
finger.begin(57600); // set the data rate for the sensor serial port }
void loop() // run over and over again
{
getFingerprintID();
delay(100);
digitalWrite (13,HIGH);
}
uint8_t getFingerprintID()
{ uint8_t p = finger.getImage();
switch (p)
{
case FINGERPRINT_OK:
lcd.clear();
lcd.print(" Image taken... ");
delay(1000);
break;
case FINGERPRINT_NOFINGER:
return p;
case FINGERPRINT_PACKETRECIEVEERR:
return p;
case FINGERPRINT_IMAGEFAIL:
return p;
default:
return p; }
// OK success!
p = finger.image2Tz();
switch (p) {
case FINGERPRINT_OK:
break;
case FINGERPRINT_IMAGEMESS:
return p;
case FINGERPRINT_PACKETRECIEVEERR:
return p;
case FINGERPRINT_FEATUREFAIL:
return p;
case FINGERPRINT_INVALIDIMAGE:
return p;
default:
return p; }
// OK converted!
p = finger.fingerFastSearch();
if (p == FINGERPRINT_OK)
{
lcd.clear();
lcd.print(" Found match! ");
digitalWrite(11, HIGH);
delay(1000);
digitalWrite(11,LOW); // turn on green LED to indicate match
}
else if(p == FINGERPRINT_NOTFOUND)
{
lcd.clear();
lcd.setCursor(0,0);
lcd.print(" Did not match! ");
delay(1000);
lcd.clear();
lcd.setCursor(0,0);
lcd.print(" scan finger! ");
return p;
}
else
{ return p; }
// IF FOUND A MATCH............
lcd.clear();
lcd.setCursor(0,0);
lcd.print("Found ID #");
lcd.print(finger.fingerID);
lcd.setCursor(0,1);
lcd.print("confidence ");
lcd.print(finger.confidence); }
// 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!
digitalWrite(13, LOW);
delay(10);
digitalWrite(13, HIGH);
delay(10);
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("Found ID # ");
lcd.print(finger.fingerID);
lcd.setCursor(0, 1);
lcd.print("confidence ");
lcd.print(finger.confidence);
return finger.fingerID;
}
You have not included the SoftwareSerial library in your program
I'm not sure what you mean by software serial :-S
Sorry
englewood:
I'm not sure what you mean by software serial :-S
Sorry
Look at the fourth line.
Edit - and the error you're getting...
Okay, I can see the 4th line says "SoftwareSerial mySerial(2, 3);"
I'm very new to this code writing and I just took the example from the Tutorial - How do I fix this 
englewood:
Okay, I can see the 4th line says "SoftwareSerial mySerial(2, 3);"
I'm very new to this code writing and I just took the example from the Tutorial - How do I fix this 
Reply #1
By the way, the authors of that Tutorial must have mangled the code when they uploaded it.
****************************************************/
/**********************MODIFIED BY PELEGREN of bedRoonics Labs**********************************/
/********************** ARDUINO FINGERPRINT SCANNER with 16x2 LCD monitor***************/
#include
#include
#include
#include
int getFingerprintIDez();
So the code is useless then :-(.
Add the line
#include <SoftwareSerial.h>
at the start of the program
Thanks, got pass the error message.
Now I have this one
Arduino: 1.6.5 (Windows 8.1), Board: "Arduino/Genuino Uno"
sketch_sep03a:14: error: 'Adafruit_Fingerprint' does not name a type
sketch_sep03a.ino: In function 'void setup()':
sketch_sep03a:30: error: 'finger' was not declared in this scope
sketch_sep03a:34: error: a function-definition is not allowed here before '{' token
sketch_sep03a:46: error: a function-definition is not allowed here before '{' token
sketch_sep03a:217: error: expected '}' at end of input
'Adafruit_Fingerprint' does not name a type
.
Ive put this line in
#include <Adafruit_Fingerprint.h>
And the error has gone but not sure if its correct as I get this error messages now
Arduino: 1.6.5 (Windows 8.1), Board: "Arduino/Genuino Uno"
sketch_sep03a.ino: In function 'void setup()':
sketch_sep03a:34: error: a function-definition is not allowed here before '{' token
sketch_sep03a:46: error: a function-definition is not allowed here before '{' token
sketch_sep03a:217: error: expected '}' at end of input
a function-definition is not allowed here before '{' token
This report would have more information with
"Show verbose output during compilation"
enabled in File > Preferences.
That code is appalling to read. There should only be one terminating semicolon on one line, and the only thing that may follow it is a comment.
I know it's not your code, but if you put each statement on its own line, remove unnecessary blank lines, then do auto-format (Tools menu), and repost your code (using code tags!) we might have a fighting chance!
Please post your whole program as it is now using code tags. Select the text of the code in the message editor and click the code icon (</>) above the editor window. Formatting the code (Ctrl/T) in the IDE and removing the superfluous blank lines before copying here would be helpful too.
finger.begin(57600); // set the data rate for the sensor serial port }
Move the }
to the next line away from the comment.
EDIT:
I could swear there was a program listing in the previous message...
Better, but it would be even better with the extraneous blank lines removed and each { and } on its own line.
In the meantime, you have
void loop() // run over and over again
{
getFingerprintID();
The getFingerprintID() function returns a value but you are not assigning it to a variable so the compiler thinks that you are defining a function here.
I was just making some changes before the posts
#include <SoftwareSerial.h>
#include <LiquidCrystal.h>
#include <Adafruit_Fingerprint.h>
int getFingerprintIDez();
// pin #2 is IN from sensor (GREEN wire)
// pin #3 is OUT from arduino (WHITE wire)
SoftwareSerial mySerial(2, 3);
LiquidCrystal lcd(9, 8, 7, 6, 5, 4); // initialize the library with the numbers of the interface pins
Adafruit_Fingerprint finger = Adafruit_Fingerprint(&mySerial);
void setup()
{
Serial.begin(9600); // initialize the serial communications:
lcd.begin(16, 2); lcd.setCursor(0, 0); lcd.print("Scan your finger");
pinMode(13, OUTPUT);
pinMode(12, OUTPUT);
pinMode(11, OUTPUT);
pinMode(A0, INPUT);
finger.begin(57600); // set the data rate for the sensor serial port }
void loop() // run over and over again
{
}
getFingerprintID();
delay(100);
digitalWrite (13, HIGH);
}
uint8_t getFingerprintID()
{ uint8_t p = finger.getImage();
switch (p)
{
case FINGERPRINT_OK:
lcd.clear();
lcd.print(" Image taken... ");
delay(1000);
break;
case FINGERPRINT_NOFINGER:
return p;
case FINGERPRINT_PACKETRECIEVEERR:
return p;
case FINGERPRINT_IMAGEFAIL:
return p;
default:
return p;
}
// OK success!
p = finger.image2Tz();
switch (p) {
case FINGERPRINT_OK:
break;
case FINGERPRINT_IMAGEMESS:
return p;
case FINGERPRINT_PACKETRECIEVEERR:
return p;
case FINGERPRINT_FEATUREFAIL:
return p;
case FINGERPRINT_INVALIDIMAGE:
return p;
default:
return p;
}
// OK converted!
p = finger.fingerFastSearch();
if (p == FINGERPRINT_OK)
{
lcd.clear();
lcd.print(" Found match! ");
digitalWrite(11, HIGH);
delay(1000);
digitalWrite(11, LOW); // turn on green LED to indicate match
}
else if (p == FINGERPRINT_NOTFOUND)
{
lcd.clear();
lcd.setCursor(0, 0);
lcd.print(" Did not match! ");
delay(1000);
lcd.clear();
lcd.setCursor(0, 0);
lcd.print(" scan finger! ");
return p;
}
else
{
return p;
}
// IF FOUND A MATCH............
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("Found ID #");
lcd.print(finger.fingerID);
lcd.setCursor(0, 1);
lcd.print("confidence ");
lcd.print(finger.confidence);
}
// 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!
digitalWrite(13, LOW);
delay(10);
digitalWrite(13, HIGH);
delay(10);
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("Found ID # ");
lcd.print(finger.fingerID);
lcd.setCursor(0, 1);
lcd.print("confidence ");
lcd.print(finger.confidence);
return finger.fingerID;
}
void loop() // run over and over again
{
}
Now you have nothing in the loop() function. I assume that the closing brace above should not be there.
I have found this code but when uploading I get this error message
Arduino: 1.6.5 (Windows 8.1), Board: "Arduino/Genuino Uno"
Sketch uses 7,508 bytes (23%) of program storage space. Maximum is 32,256 bytes.
Global variables use 846 bytes (41%) of dynamic memory, leaving 1,202 bytes for local variables. Maximum is 2,048 bytes.
This report would have more information with
"Show verbose output during compilation"
enabled in File > Preferences.
#include <LiquidCrystal.h>
LiquidCrystal lcd(6, 7, 8, 9, 10, 11);
#include <Adafruit_Fingerprint.h>
#if ARDUINO >= 100
#include <SoftwareSerial.h>
#else
#include <NewSoftSerial.h>
#endif
uint8_t getFingerprintEnroll(uint8_t id);
int k;
// pin #2 is IN from sensor (GREEN wire)
// pin #3 is OUT from arduino (WHITE wire)
#if ARDUINO >= 100
SoftwareSerial mySerial(14, 15);
#else
NewSoftSerial mySerial(14`, 15);
#endif
Adafruit_Fingerprint finger = Adafruit_Fingerprint(&mySerial);
uint8_t id = 0;
void setup()
{
lcd.begin(16, 2);
lcd.print("FingerPrintSensor");
Serial.begin(9600);
Serial.println("fingertest");
//mySerial.print("Detect");
// set the data rate for the sensor serial port
finger.begin(9600);
//mySerial.print("Detect");
if (finger.verifyPassword()) {
Serial.println("Found fingerprint sensor!");
} else {
Serial.println("Did not find fingerprint sensor :(");
while (1);
} lcd.clear();
}
void loop() // run over and over again
{
Serial.println("Type in the ID # you want to save this finger as...");
lcd.print(" ID=" );
//lcd.print(k);
// while (true) {
// while (! Serial.available());
// char c = Serial.read();
// if (! isdigit(c)) break;
// id *= 10;
// id += c - '0';
// }
id++;
Serial.print("Enrolling ID #");
Serial.println(id);
lcd.print(id);
while (! getFingerprintEnroll(id) );
}
uint8_t getFingerprintEnroll(uint8_t id) {
uint8_t p = -1;
Serial.println("Waiting for valid finger to enroll");
lcd.print("Put the Finger");
while (p != FINGERPRINT_OK) {
p = finger.getImage();
switch (p) {
case FINGERPRINT_OK:
Serial.println("Image taken");
break;
case FINGERPRINT_NOFINGER:
Serial.println(".");
break;
case FINGERPRINT_PACKETRECIEVEERR:
Serial.println("Communication error");
break;
case FINGERPRINT_IMAGEFAIL:
Serial.println("Imaging error");
break;
default:
Serial.println("Unknown error");
break;
}
}
// OK success!
p = finger.image2Tz(1);
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;
}
Serial.println("Remove finger");
delay(2000);
p = 0;
while (p != FINGERPRINT_NOFINGER) {
p = finger.getImage();
}
p = -1;
Serial.println("Place same finger again");
while (p != FINGERPRINT_OK) {
p = finger.getImage();
switch (p) {
case FINGERPRINT_OK:
{
Serial.println("Image taken");
break;
}
case FINGERPRINT_NOFINGER:
Serial.print(".");
break;
case FINGERPRINT_PACKETRECIEVEERR:
Serial.println("Communication error");
break;
case FINGERPRINT_IMAGEFAIL:
Serial.println("Imaging error");
break;
default:
Serial.println("Unknown error");
break;
}
}
// OK success!
p = finger.image2Tz(2);
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.createModel();
if (p == FINGERPRINT_OK) {
Serial.println("Prints matched!");
} else if (p == FINGERPRINT_PACKETRECIEVEERR) {
Serial.println("Communication error");
return p;
} else if (p == FINGERPRINT_ENROLLMISMATCH) {
Serial.println("Fingerprints did not match");
return p;
} else {
Serial.println("Unknown error");
return p;
}
p = finger.storeModel(id);
if (p == FINGERPRINT_OK) {
Serial.println("Stored!");
} else if (p == FINGERPRINT_PACKETRECIEVEERR) {
Serial.println("Communication error");
return p;
} else if (p == FINGERPRINT_BADLOCATION) {
Serial.println("Could not store in that location");
return p;
} else if (p == FINGERPRINT_FLASHERR) {
Serial.println("Error writing to flash");
return p;
} else {
Serial.println("Unknown error");
return p;
}
}
]
What error? All I see is a memory usage report from a successful compilation.
Ive sorted it - was on the wrong com port.