Beverage Dispenser: Arduino Code for GT-511C3 Fingerprint Scanner

Attached below is the code we used on for our Arduino board. We used this board primarily because the fingerprint scanner used already had a library developed that was for the Arduino board. FPS_GT511C3, available here: https://github.com/sparkfun/Fingerprint_Scanner-TTL

Our code opens the Serial with a baud rate of 115200. It then proceeds to set up the GT-511C3 fingerprint scanner and execute the loop. This loop waits for a finger to be scanned. In the event that a finger is detected on the scanner, the print is identified with the Identify1_N command and the corresponding id (a value less that 200 if the print is recognized) is copied to an “id” variable. If the fingerprint is successfully identified, a success message and the id read is sent through serial. The way we sent the different IDs to the A3BU was rather ingenious, I believe.  The Arduino sends a high pin value to the A3BU, waits for an amount of time equal to 100 multiplied by the ID found plus one, then transitions the pin back to low. The A3BU can then read how long the pin is high and translate that to the corresponding user using a similar formula to the one mentioned earlier. This emulates a duty cycle and is, in my opinion, a clever way to communicate with the A3BU, since sending just an integer proved to be much more complicated than it sounds. Lastly, the id is set to 201, which prevents duplicate data from being sent to the A3BU. Without this line, the loop would constantly send this duty cycle, causing duplication of data.

 

Arduino Code:



#include "FPS_GT511C3.h"

#include "SoftwareSerial.h"

FPS_GT511C3 fps(10,11); //Serial pins

void setup()

{

Serial.begin(115200); //Set baud rate

fps.Open(); //initialize finger print scanner library

fps.SetLED(true); //Turn on FPS backlight

pinMode(3,OUTPUT); //A3BU output pin

pinMode(5, OUTPUT); //Red LED pin

delay(100); //give time for initialization

}

 

void loop()

{

int delay_comm; //value used to delay to set id to a3bu

int id; //id for each person

if (fps.IsPressFinger()) //check to see if finger is on scanner

{

fps.CaptureFinger(false); //

id = fps.Identify1_N(); //set id to id of fps

if (id <200)

{

Serial.print("Verified ID:");

Serial.println(id);

}

else

{

Serial.println("Finger not found");

delay(3000);

digitalWrite(5,LOW); //make sure a3bu does not get signal

}

}

else

{

Serial.println("Please press finger");

}

&nbsp;

delay_comm = ( 100 *( id + 1 )); //set amount of delay of signals to a3bu

if( id >= 0 && id < 200 )

{

&nbsp;

Serial.println("Pin High"); //test to see if pin goes high

digitalWrite(3,HIGH);

delay(delay_comm);

Serial.println("Pin Low"); //make pin low to give mulitple signals to a3bu

digitalWrite(3,LOW);

delay(1000);

}

id = 201; //set id to value that cannot be in if statement above

}