Fingerprint Based Biometric Voting Machine Using Arduino – Source Code

Here is the 3rd step on your project “Fingerprint Based Biometric Voting Machine Using Arduino – Source Code”

Read: Why the NSA Called Me After Midnight and Requested My Source Code

Step 3: Source Code and Step by Step Code Explanation

The complete code for this Fingerprint Voting System Project using Arduino is given at the end of the article; here we are explaining some important functions of the code.

The code uses the SPFD5408, Software Serial, and FPS_GT511C3 libraries. SPFD5408 library is the modified version of the original Adafruit Library. These library files can be downloaded from the links given below:

After including the libraries and defining some important parameters, we can get into the programming part. There are three sections involved in this program. One is creating a UI of a voting machine, second is getting the touch-points for buttons & detecting the buttons based on the touch and finally calculating the results and save them into Arduino’s memory.

1. Creating UI:

I have created a simple UI with three buttons and the name of the project. The TFT display library allows you to draw Lines, Rectangle, Circles, Chars, Strings and a lot more of any preferred color and size. Here two rectangular buttons are created using fillRoundRect and drawRoundRect functions. Syntax for tft.drawRoundRect function is given below:

tft.drawRoundRect(int16_t x0, int16_t y0, int16_t w, int16_t h, int16_t radius, uint16_t color)


x0= X co-ordinate of the starting point of rectangular

y0= Y coordinate of the starting point of rectangular

w = Width of the rectangular

h = Height of the Rectangular

radius= Radius of the round corner

color = Colour of the Rect.

void drawHome()



tft.drawRoundRect(0, 0, 319, 240, 8, WHITE); //Page border

tft.fillRoundRect(10, 70, 220, 50, 8, GOLD);

tft.drawRoundRect(10, 70, 220, 50, 8, WHITE); //Vote

tft.fillRoundRect(10, 160, 220, 50, 8, GOLD);

tft.drawRoundRect(10, 160, 220, 50, 8, WHITE); //Enroll

tft.fillRoundRect(10, 250, 220, 50, 8, GOLD); //Result

tft.drawRoundRect(10, 250, 220, 50, 8, WHITE);

tft.setCursor(65, 5);




tft.setCursor(57, 29);




tft.setCursor(25, 82);

tft.print(“Candidate 1”);

tft.setCursor(25, 172);

tft.print(“Candidate 2”);

tft.setCursor(25, 262);

tft.print(“Candidate 3”);


2. Getting the Touch-Points and Detecting Buttons:

Now in the second section of the code, we will detect the button touchpoints and then use these points to predict the button. ts.getPoint() function is used to detect the user touch on TFT display. ts.getPoint gives the Raw ADC values for the touched area. These RAW ADC values are then converted to Pixel Coordinates using the map function.

TSPoint p = ts.getPoint();

if (p.z > ts.pressureThreshhold)


p.x = map(p.x, TS_MAXX, TS_MINX, 0, 320);

p.y = map(p.y, TS_MAXY, TS_MINY, 0, 240);





Now, since we know the X and Y coordinates for each button, we can predict where the user has touched by using the ‘if’ statement.

if (p.x > 70 && p.x < 120 && p.y > 10 && p.y < 220 && p.z > MINPRESSURE && p.z < MAXPRESSURE)


Serial.println(“Candidate 1”);

When a voter presses the candidate button, he will be asked to scan the finger on the fingerprint sensor. If finger ID is authorized then the voter is allowed to vote. If any Non-registered user wants to vote then the fingerprint module will not detect its ID into the system and the display will show ‘Sorry You Can’t Vote ’.

if (fps.IsPressFinger())



int id = fps.Identify1_N();

if (id <200)


msg = “Candidate 1”;


EEPROM.write(0, vote1);

tft.setCursor(42, 170);

tft.print(“Thank You”);



3. Result:

The last step is getting the vote count from EEPROM memory and comparing the votes of all three candidates. A Candidate with the highest votes wins. The result can only be accessed from the serial monitor and will not be displayed on the TFT screen.;;;



if((vote1 > vote2 && vote1 > vote3))


Serial.print(“Can1 Wins”);



Here is the 3rd step on your project “Fingerprint Based Biometric Voting Machine Using Arduino – Source Code”


Leave a Reply

Your email address will not be published. Required fields are marked *

Related Posts