adarsh bhola
Published © GPL3+

Electronic Voting machine with security feature

It is a simple Electronic Voting Machine with a keypad based security system to enter the voting machine

IntermediateFull instructions provided10 hours1,396
Electronic Voting machine with security feature

Things used in this project

Hardware components

Arduino UNO
Arduino UNO
×2
Resistor 220 ohm
Resistor 220 ohm
×4
Resistor 10k ohm
Resistor 10k ohm
×5
Single Turn Potentiometer- 10k ohms
Single Turn Potentiometer- 10k ohms
×2
RGB Backlight LCD - 16x2
Adafruit RGB Backlight LCD - 16x2
×2
Pushbutton switch 12mm
SparkFun Pushbutton switch 12mm
×5
Jumper wires (generic)
Jumper wires (generic)
×24
SG90 Micro-servo motor
SG90 Micro-servo motor
×1
Buzzer
Buzzer
×1
Gatronic Technologies 4x4 keypad
×1

Software apps and online services

Arduino IDE
Arduino IDE
Adafruit proteus

Story

Read more

Schematics

EVM_security_lock

It is for the first part of the project

EVM

It is used in the second part of the project.

Code

Electronic voting machine_security_lock

Arduino
It is used in the first part of the project
#include <Keypad.h>
#include <LiquidCrystal.h>
#include <Servo.h>

Servo myservo;

LiquidCrystal lcd(A0, A1, A2, A3, A4, A5);

const int buzzer=8;

#define Password_Length 7 // Give enough room for six chars + NULL char

int pos = 0;    // variable to store the servo position

char Data[Password_Length]; // 6 is the number of chars it can hold + the null char = 7
char Master[Password_Length] = "AB*123";
byte data_count = 0;
char customKey;

const byte ROWS = 4;
const byte COLS = 4;
char keys[ROWS][COLS] = {
  {'1','2','3','A'},
  {'4','5','6','B'},
  {'7','8','9','C'},
  {'*','0','#','D'}
};
bool door = true;

byte rowPins[ROWS] = {0,1,2,3}; //connect to the row pinouts of the keypad
byte colPins[COLS] = {4,5,6,7}; //connect to the column pinouts of the keypad

Keypad customKeypad(makeKeymap(keys),rowPins,colPins,ROWS,COLS); //initialize an instance of class NewKeypad

void setup()
{
  pinMode(buzzer,OUTPUT);
  myservo.attach(9);
  ServoClose();
  lcd.begin(16, 2);
  lcd.print("Hello, You!");
  delay(2000);
  lcd.clear();
}

void loop()
{
  if (door == 0)
  {
    customKey = customKeypad.getKey();
    if (customKey=='#')
    {
      lcd.clear();
      ServoClose();
      lcd.setCursor(0,0);
      lcd.print("  Door is close");
      delay(3000);
      door = 1;
    }
  }

  else Open();
}

void clearData()
{
  while (data_count != 0)
  { // This can be used for any array size,
    Data[data_count--] = 0; //clear array for new data
  }
  return;
}

void ServoOpen()
{
  for (pos = 180; pos >= 0; pos -= 5) { // goes from 0 degrees to 180 degrees
    // in steps of 1 degree
    myservo.write(pos);              // tell servo to go to position in variable 'pos'
    delay(15);                       // waits 15ms for the servo to reach the position
  }
}

void ServoClose()
{
  for (pos = 0; pos <= 180; pos += 5) { // goes from 180 degrees to 0 degrees
    myservo.write(pos);              // tell servo to go to position in variable 'pos'
    delay(15);                       // waits 15ms for the servo to reach the position
  }
}

void Open()
{
  lcd.setCursor(0,0);
  lcd.print(" Enter 6 di Passwd");
  
  customKey = customKeypad.getKey();
  if (customKey) // makes sure a key is actually pressed, equal to (customKey != NO_KEY)
  {
    Data[data_count] = customKey; 
    lcd.setCursor(data_count,1); 
    lcd.print("*"); 
    data_count++;
  }

  if (data_count==Password_Length-1)
  {
    if (strcmp(Data,Master)==0) 
    {
      lcd.clear();
      ServoOpen();
      lcd.setCursor(0,0);
      lcd.print("  Door is Open");
      door = 0;
    }
    else
    {
      lcd.clear();
      lcd.setCursor(0,0);
      tone(buzzer,1000);
      lcd.print("Wrong Password");
      delay(1000);
      noTone(buzzer);
      door = 1;
    }
    clearData();
  }
}

Electronic voting machine

Arduino
It is used in the second part of the project
#include <LiquidCrystal.h>

LiquidCrystal lcd(12,11,5,4,3,2);

const int sw1=10;
const int sw2=8;
const int sw3=9;
const int sw4=13;
const int sw5=6;
int vote1=0;
int vote2=0;
int vote3=0;
void setup() {
  // put your setup code here, to run once:
  pinMode(sw1,INPUT);
  pinMode(sw2,INPUT);
  pinMode(sw3,INPUT);
  pinMode(sw4,INPUT);
  pinMode(sw5,INPUT);
  lcd.begin(16,2);
  lcd.clear();
  lcd.setCursor(4,0);
  lcd.print("ELECTRONIC");
  lcd.setCursor(0,1);
  lcd.print("VOTING");
  lcd.setCursor(8,1);
  lcd.print("MACHINE");
  delay(3000);
  lcd.clear();
  lcd.begin(16,2);
  lcd.setCursor(0,0);
  lcd.print("CAST YOUR VOTE:");
  lcd.setCursor(0,1);
  lcd.print("BJP");
  lcd.setCursor(6,1);
  lcd.print("AAP");
  lcd.setCursor(12,1);
  lcd.print("CONG");
}

void loop() {
  // put your main code here, to run repeatedly:
  if(digitalRead(sw1)==HIGH)
  {
    vote1=vote1+1;
    lcd.clear();
    lcd.setCursor(0,0);
    delay(200);
    lcd.print("THANKS FOR");
    lcd.setCursor(5,1);
    lcd.print("VOTING");
    while(digitalRead(sw4)==LOW);
    admin();  
  }
  else if(digitalRead(sw2)==HIGH)
  {
    vote2=vote2+1;
    lcd.clear();
    lcd.setCursor(0,0);
    delay(200);
    lcd.print("THANKS FOR");
    lcd.setCursor(5,1);
    lcd.print("VOTING");
    while(digitalRead(sw4)==LOW);
    admin();
  }
  else if(digitalRead(sw3)==HIGH)
  {
    vote3=vote3+1;
    lcd.clear();
    lcd.setCursor(0,0);
    delay(200);
    lcd.print("THANKS FOR");
    lcd.setCursor(5,1);
    lcd.print("VOTING");
    while(digitalRead(sw4)==LOW);
    admin();
  }
  
  if(digitalRead(sw5)==HIGH)
  {
    int max_vote=0;
    int flag=0;
    lcd.clear();
    lcd.begin(16,2);
    lcd.setCursor(0,0);
    lcd.print("BJP");
    lcd.setCursor(6,0);
    lcd.print("AAP");
    lcd.setCursor(12,0);
    lcd.print("CONG");
    lcd.setCursor(0,1);
    lcd.print(vote1);
    lcd.setCursor(6,1);
    lcd.print(vote2);
    lcd.setCursor(12,1);
    lcd.print(vote3);
    delay(2000);
    lcd.clear();
    delay(2000);
    if(vote1>max_vote)
    {
      max_vote=vote1;
    }
    if(vote2>max_vote)
    {
      max_vote=vote2;
    }
    if(vote3>max_vote)
    {
      max_vote=vote3;
    }
    if((vote1==max_vote)&&(vote2!=max_vote)&&(vote3!=max_vote))
    {
      flag=1;
      lcd.setCursor(5,0);
      lcd.print("BJP");
      lcd.setCursor(8,1);
      lcd.print("Wins!");
      delay(2000);
      lcd.clear();
      lcd.setCursor(0,0);
      lcd.print("no. of votes won");
      lcd.setCursor(6,1);
      lcd.print(vote1);
      delay(2000);
    }
    if((vote2==max_vote)&&(vote1!=max_vote)&&(vote3!=max_vote))
    {
      flag=1;
      lcd.setCursor(5,0);
      lcd.print("AAP");
      lcd.setCursor(8,1);
      lcd.print("Wins!");
      delay(2000);
      lcd.clear();
      lcd.setCursor(0,0);
      lcd.print("no. of votes won");
      lcd.setCursor(6,1);
      lcd.print(vote2);
      delay(2000);
    }
    if((vote3==max_vote)&&(vote1!=max_vote)&&(vote2!=max_vote))
    {
      flag=1;
      lcd.setCursor(5,0);
      lcd.print("CONG");
      lcd.setCursor(8,1);
      lcd.print("Wins!");
      delay(2000);
      lcd.clear();
      lcd.setCursor(0,0);
      lcd.print("no. of votes won:");
      lcd.setCursor(6,1);
      lcd.print(vote3);
      delay(2000);
    }
    if(flag==0)
    {
      lcd.setCursor(0,0);
      lcd.print("Clash between:");
      lcd.setCursor(0,1);
      if(vote1==max_vote)
      {
        lcd.print("BJP ");
      }
      if(vote2==max_vote)
      {
        lcd.print("AAP ");
      }
      if(vote3==max_vote)
      {
        lcd.print("CONG ");
      }
      delay(2000);
      lcd.clear();
      lcd.setCursor(0,0);
      lcd.print("no. of votes won:");
      lcd.setCursor(6,1);
      lcd.print(max_vote);
      delay(2000);
    }
  }
}
void admin()
{
  if(digitalRead(sw4)==HIGH)
  {
    lcd.begin(16,2);
    lcd.setCursor(0,0);
    lcd.print("CAST YOUR VOTE:");
    lcd.setCursor(0,1);
    lcd.print("BJP");
    lcd.setCursor(6,1);
    lcd.print("AAP");
    lcd.setCursor(12,1);
    lcd.print("CONG"); 
  }
}

Credits

adarsh bhola
10 projects • 8 followers
I am a student at VIT University,chennai campus.I have been developing for 2 years.I got started in embedded systems through 8051 uc
Contact

Comments

Please log in or sign up to comment.