Saturday, January 13, 2018

Advance Voting Machine GUI Demo Using MATLAB

Hello Everyone in one of our last post we have shared a project named "Voting Machine based on MATLAB GUI", this project was very basic in nature, and in this post we are going to add few more scenarios to make this system more useful and practical.
Advanced Voting GUI in MATLAB
So some of the additional feature of this project are as follow:
  • Voters who's names and Id's are present in Database can only vote.
  • Duplicate Voting is not allowed.
  • Voting Percentage is also calculated.
So with the above mentioned features one can create a more robust and professional system.
To create database, Microsoft Excel is used and names of voters and there voting id's are written in two different columns. For this project a sample database of 10 voters is created and is shown in the image given below.
Database of 10 Voters in Excel
We have the database now, and then in system we have to load this data, and based on the ID's we have to take action whether a voter can vote or not.
Whenever someone presses the voting button, system will asks for it's voting id (as shown in image below) and then search the voting id in it's database.
Enter Voting ID

There are two cases now, one if voting id exist and in another case, it doesn't exist. System will display following screens in these two cases.
Case 1: If Voter Id exist, the system will greet voter with message "Thank You" as shown below.
Thank You for Voting
Case 2: If Voter Id doesn't exist, the system will generate an error, as shown below.
User Not Found
Now coming to the another case, when voter is trying to enter vote twice, so in this case system will generate a message that you can't vote multiple times as shown below.
Multiple Times Voting Not Allowed.
And then finally on pressing the result button, results are shown on the screen as follow.
Voting Results, Party1 is clear Winner :-)
Source Code
Download Source From GitHub 

There are basically two main parts of the project, one is loading and storing the data and another is using this data to increase the vote count or display messages or error to the voters.
Coming to the first part, i.e loading the Excel file data into MATLAB, this is done using the following piece of code.
global party1;

% Open Voter ID List File
filename = 'VotingList.xlsx';
[~, ~, raw] = xlsread(filename);
voters_name = raw(2:end, 2);
voters_id = raw(2:end, 3);
% Create voting status variable to keep track of person's who already voted
voting_status = zeros(numel(voters_name), 1);

As can we seen in above code, three new global variables are declared, voters_name will contain the names of all voters, voters_id will contain the voter ids and voting_status variable is initialized to zero, this variable will keep track if a voter has given his vote or not.

Now coming to second and most important part, where decision is made if a voter is a legal voter or not.
global party1;
global voters_name
global voters_id
global voting_status

prompt = {'Enter your Voter ID ?'};
dlg_title = 'Input';
num_lines = 1;
defaultans = {'1234567890'};
answer = inputdlg(prompt,dlg_title,num_lines,defaultans);
index = find([voters_id{:}] == str2double(answer));
if index
  %disp (voters_name(index));
  name = string(voters_name(index));
  if voting_status(index) == 0
    party1 = party1+1;
    % Voting Done
    voting_status(index) = 1;
    msgbox(sprintf('Thank you "%s" for voting',name),'Vote Success')
  else
    msgbox(sprintf('"%s" you cant give vote multiple times', name),'Duplicate')
  end
else
  errordlg('User Not Found','Database Error');
end

As can be seen in the above code, Voter ID is prompted on screen and then this voter id is used to search, in database, if match is found then, system will check if this voter has given vote earlier or not, if not given, voter status will be updated so that voter can't vote multiple times.

The following video links shows complete demo of this project.

Please contact us in case of any doubt.

Future Possibilities
The above system has limitation, that if someone else remembers your voting ID, then that voter can give your vote, to overcome this situation and make system more interesting, Bio-metric system or finger print scanner can be added to this project, if we get time, we will definitely post this project also.

No comments:

Post a Comment