Arduino is taking the systemic order button signal input first not the one which is pressed at first instance

Hello I am a student Arduino Programmer! :innocent:

I am using Arduino UNO (later I will use MEGA) with Some buttons to make a voting machine. Now the machine has one glitch that when two buttons are pressed around the same time ( within 1 second ) , Arduino is Picking up the systematically set up first as in the circuit not the one which has been pressed first in the instance of 1-0.5 second.

I am not sure that is it due to high delay between the vote time or so

Thank you Before
I Appreciate your replies :smiley:
CODE

int s1 = 2;
int s2 = 3;
int s3 = 4;
int s4 = 5;
int b = 6;
int r = 8;
int t = 5000;
int vc = 0;
int t2 = 3000;/*Delay Time after each vote*/
int l1 = 9;
int l2 =10;
int l3 = 11;
int l4 = 12;
void setup() {
  Serial.begin(9600);
 
  pinMode(s1,INPUT_PULLUP);
  pinMode(s2,INPUT_PULLUP);
  pinMode(s3,INPUT_PULLUP);
  pinMode(s4,INPUT_PULLUP);
  pinMode(6,OUTPUT);
  pinMode(r,INPUT_PULLUP);
  pinMode(l1,OUTPUT);
  pinMode(l2,OUTPUT);
  pinMode(l3,OUTPUT);
  pinMode(l4,OUTPUT);
}

void loop() {
  if(digitalRead(s1) == LOW)
  {
    Serial.println("Candidate 1 Vote Registered");
    vc = vc + 1;
    Serial.println("Total Vote polled");
    Serial.println(vc);
    digitalWrite(b,HIGH);
    digitalWrite(l1,HIGH);

    delay(t);
    }
  
  
  else if(digitalRead(s2) == LOW)
  {
    Serial.println("Candidate 2 Vote Registered");
    vc = vc + 1;
    Serial.println("Total Vote polled");
    Serial.println(vc);
    digitalWrite(b,HIGH);
    digitalWrite(l2,HIGH);
    delay(t);
    }
 
  else if(digitalRead(s3) == LOW)
  {
    Serial.println("Candidate 3 Vote Registered");
     vc = vc + 1;
    Serial.println("Total Vote polled");
    Serial.println(vc);
    digitalWrite(b,HIGH);
    digitalWrite(l3,HIGH);
    delay(t);
    }
 
  else if(digitalRead(s4) == LOW)
  {
    Serial.println("Candidate 4 Vote Registered");
     vc = vc + 1;
    Serial.println("Total Vote polled");
    Serial.println(vc);
    digitalWrite(b,HIGH);
    digitalWrite(l4,HIGH);
    delay(t);
    }
   
   digitalWrite(b,LOW);
   digitalWrite(l1,LOW);
   digitalWrite(l2,LOW);
   digitalWrite(l3,LOW);
   digitalWrite(l4,LOW);
   delay(t2);

if(digitalRead(r) == LOW)
{
  vc = 0;
  Serial.println("Votecount has been reset");
  digitalWrite(b,HIGH);
  delay(250);
  digitalWrite(b,LOW);
  delay(250);
  digitalWrite(b,HIGH);
  delay(250);
  digitalWrite(b,LOW);
  delay(250);
  digitalWrite(b,HIGH);
  delay(250);
  digitalWrite(b,LOW);
  delay(250);
  digitalWrite(b,HIGH);
  delay(250);
  digitalWrite(b,LOW);
  delay(250);
  }   
}

4 posts were merged into an existing topic: I am Making an Voting Machine So How Could I Disable Switches So That I Can Receive One Vote at a time