0% found this document useful (0 votes)
34 views7 pages

Code

This document contains code for an RFID voting system using Arduino. It defines variables to store voter RFID tags and vote counts. It also contains functions to read RFID tags, detect button presses to select parties, and update the LCD display with vote totals.

Uploaded by

Vini Vinay
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
34 views7 pages

Code

This document contains code for an RFID voting system using Arduino. It defines variables to store voter RFID tags and vote counts. It also contains functions to read RFID tags, detect button presses to select parties, and update the LCD display with vote totals.

Uploaded by

Vini Vinay
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 7

//***********************************************************************************

// include the library code:


#include <LiquidCrystal.h>

// initialize the library with the numbers of the interface pins


LiquidCrystal lcd(7, 6, 5, 4, 3, 2);

String RFIDOne, RFIDtwo,RFIDthree,RFIDfour, TagRFID;


char input[12];
int count;
boolean votter1 = false,votter2 = false,votter3 = false,votter4 = false;
boolean votter11 = true,votter22 = true,votter33 = true,votter44 = true;
boolean TDP = false,YSRCP = false,BJP = false;
int TDPvotter = 0,YSRCPvotter = 0,BJPvotter = 0;
boolean Access_Allowed_toVoting = false;
void setup()
{
Serial.begin(9600);

RFIDOne = String("15001A0F3434");
RFIDtwo = String("15001A0FC0C0");
RFIDthree = String("15001A204768");
RFIDfour = String("15001A20F9D6");

pinMode(8, INPUT_PULLUP);
pinMode(9, INPUT_PULLUP);
pinMode(10, INPUT_PULLUP);

// set up the LCD's number of columns and rows:


lcd.begin(20, 4);
// Print a message to the LCD.
// lcd.print("hello, world!");
}

void loop()
{

ReadCard();
ReadButton();
VerifyVoter();
lcd.setCursor(0, 0);
lcd.print(" RFID Voting System");
lcd.setCursor(0, 1);
lcd.print("TDP = ");
lcd.print(TDPvotter);
lcd.setCursor(0, 2);
lcd.print("YSRCP = ");
lcd.print(YSRCPvotter);

lcd.setCursor(0, 3);
lcd.print("BJP = ");
lcd.print(BJPvotter);
}
//---------------------------------------------------------------------------------------------------------------//---------------------------------------------------------------------------------------------------------------void VerifyVoter(){
if(votter1 || votter2 || votter3 || votter4)
{Access_Allowed_toVoting = true;}

if( Access_Allowed_toVoting && TDP )


{
TDPvotter++;
Serial.println(TDPvotter);
votter1 = false,votter2 = false,votter3 = false,votter4 = false;
TDP = false,YSRCP = false,BJP = false;
}
else if(Access_Allowed_toVoting && YSRCP )
{
YSRCPvotter++;
Serial.println(YSRCPvotter);
votter1 = false,votter2 = false,votter3 = false,votter4 = false;
TDP = false,YSRCP = false,BJP = false;
}
else if(Access_Allowed_toVoting && BJP )
{

BJPvotter++;
Serial.println(BJPvotter);
votter1 = false,votter2 = false,votter3 = false,votter4 = false;
TDP = false,YSRCP = false,BJP = false;
}
TDP = false,YSRCP = false,BJP = false;
Access_Allowed_toVoting = false;
}
//---------------------------------------------------------------------------------------------------------------//---------------------------------------------------------------------------------------------------------------void ReadButton(){
boolean Button1_Lstatus = HIGH,Button2_Lstatus = HIGH,Button3_Lstatus = HIGH;

int Button_1 = digitalRead(10);


int Button_2 = digitalRead(9);
int Button_3 = digitalRead(8);

if (Button_1 == LOW && Button1_Lstatus == HIGH) {


digitalWrite(13, HIGH);
TDP = true;
//

Serial.println("TDP");

}
else if (Button_2 == LOW && Button2_Lstatus == HIGH){
digitalWrite(13, HIGH);
YSRCP = true;
//

Serial.println("YSRCP");

}
else if (Button_3 == LOW && Button3_Lstatus == HIGH){
digitalWrite(13, HIGH);
BJP = true;
//

Serial.println("BJP");

}
}
//***********************************************************************************
void ReadCard(){
if(Serial.available())// Check if there is incoming data in the RFID Reader
Serial Buffer.
{
count = 0; // Reset the counter to zero
/* Keep reading Byte by Byte from the Buffer till the RFID Reader Buffer
is

empty
or till 12 Bytes (the ID size of our Tag) is read */
while(Serial.available() && count < 12)

{
input[count] = Serial.read(); // Read 1 Byte of data and store it in
the input[] variable;
TagRFID += input[count];
count++; // increment counter
delay(5);
// Serial.print(input[count]);
}
//Serial.println();
TagRFID.trim();
//Serial.println(TagRFID);

if (TagRFID == RFIDOne && votter11) {


//Serial.println("votter1");
votter1 = true;
votter11 = false ;
}
//---------------------------------------------------------------------------------------------------------------if (TagRFID == RFIDtwo && votter22 ) {
//

Serial.println("votter2");
votter2 = true;
votter22 = false ;

//---------------------------------------------------------------------------------------------------------------if (TagRFID == RFIDthree && votter33 ) {


//Serial.println("votter3");
votter3 = true;
votter33 = false ;
}
//---------------------------------------------------------------------------------------------------------------if (TagRFID == RFIDfour && votter44 ) {
//Serial.println("votter4");
votter4 = true;
votter44 = false ;
}
//---------------------------------------------------------------------------------------------------------------TagRFID = " ";

}
}
//---------------------------------------------------------------------------------------------------------------//----------------------------------------------------------------------------------------------------------------

You might also like