AD3: Arduino based Fastest Figure First Controlling System for Quiz Competition

AR-AD3: Arduino based Fastest Figure First Controlling System for Quiz Competition

This entry is part 3 of 4 in the series Advanced Arduino Projects

This code is updated with addition of one more switch for the judge. The details are given as human comments in the code. So the connections of the 5+1 switches are now different.
Please read carefully.

With this system we can detect the fastest finger first action in a quiz competition conducted in schools & colleges. For this project you require following components.

======= Connection details =======
Switches connections: 
player1: A0, player2: A1, player3: A2, player4: A3, player5: A4
Judge: A5
LED1: pin-D2, LED2: pin-D3, LED3: pin-D4, LED4: pin-D5, LED5: pin-D6
Buzzer: pin-D7

Required Components

  1. Arduino UNO/Nano – 1
  2. 5mm Red LEDs – 5 (not shown in circuit. Connect 5mm and 10mm LEDs in parallel. Fit 5 LEDs on one side of the white box and 5 LEDs on other side. One side of the box will serve as display for contestants and judges and other side of the box will serve as display to the public, who are watching the competition)
  3. 10mm Red LEDs – 5
  4. RC sockets – 5 (not shown in circuit, but can be seen in photograph)
  5. RC pins – 5 (not shown in circuit, but can be seen in photograph)
  6. 1k resistors – 5
  7. 12V/9V adapter socket – 1 (you can use a socket to power the system through external power supply like using a 12V/9V DC Adapter)
  8. 9V, 1A transformer – 1
  9. 1N4007 diodes – 2
  10. Regulator IC 7805 – 1
  11. 1000uF capacitor – 2
  12. Small size zero PCB – 1 (solder the circuit components on it)
  13. PVC boxes 10” x 12” – 2 (the two pvc boxes are fitted back to back on each other so that the complete box can be easily placed on a table with firm base)
  14. PVC boxes 4” x 4” – 5 (in photograph of the project 6 small white boxes are shown, but as the code is designed to reset the system itself automatically, so 6th box is not necessary)
  15. Push-to-on switches – 5 (in photograph of the project 6 small white boxes are shown, but as the code is designed to reset the system itself automatically, so 6th switch is not necessary)
  16. Connecting wires, etc.

The Code

/* This code was developed by Vidyasagar Academy Akola,
 * www.vsa.edu.in
 * License: You can use it for any purpose as long as you don't 
 * claim that you are its author and
 * you don't alter License terms and 
 * formulations (lines 1-10 of this file). 
 * Project: The 5 Channel Quiz Controlling System with auto reset using Arduino nano
 * Date of Creation: 17.02.2020
 * Date of Update: 08.08.2024
*/

/*    
    ======= Connection details =======
    Switches connections: 
    player1: A0, player2: A1, player3: A2, player4: A3, player5: A4
    Judge: A5
    LED1: pin-D2, LED2: pin-D3, LED3: pin-D4, LED4: pin-D5, LED5: pin-D6
    Buzzer: pin-D7
*/
int x=0;
int LED1=2;
int LED2=3;
int LED3=4;
int LED4=5;
int LED5=6;
int buzzer=7; 

void setup() 
{
  pinMode(A0,INPUT); // player1 switch input
  pinMode(A1,INPUT); // player2 switch input
  pinMode(A2,INPUT); // player3 switch input
  pinMode(A3,INPUT); // player4 switch input
  pinMode(A4,INPUT); // player5 switch input 
  pinMode(A5,INPUT); // judge switch input 
  
  pinMode(LED1,OUTPUT);
  pinMode(LED2,OUTPUT);
  pinMode(LED3,OUTPUT);
  pinMode(LED4,OUTPUT);
  pinMode(LED5,OUTPUT);

  pinMode(buzzer,OUTPUT);
  reset();
  delay(1000);
}

void loop() 
{
  int a=digitalRead(A0);   
    int b=digitalRead(A1);
      int c=digitalRead(A2);
        int d=digitalRead(A3);
          int e=digitalRead(A4);
            int judge=digitalRead(A5);

  /* Here at the start of 1st round, judge presses his button.
   * So the session starts.
   * When any contestant presses his/her button, the buttons of
   * other contestants will be disabled.
   * In this way, the 1st session is over.
   * Now since 1st session is over, the value of x = 2 in the code,
   * so any contestant cannot press his/her switch before the start
   * of the new session.
   * Now when judge presses his button, the value of x = 1
   * So new session can start.
   * In this way automatic RESET of this circuit is removed.
   */
  if(judge==LOW)
  {
    reset();
    x=1;
    
  }
  else
    x=2;

  if(a==LOW) // if player1 presses button
  { 
    if(x==1) // check if x is 1, if yes then execute the code
    {
      digitalWrite(buzzer,HIGH); // buzzer alert that a switch is pressed
      digitalWrite(LED1,HIGH); 
      x++;
      
      delay(3000);
      digitalWrite(buzzer,LOW);
    }
  }

  if(b==LOW) // if player2 presses button
  { 
    if(x==1) // check if x is 1, if yes then execute the code
    {
      digitalWrite(buzzer,HIGH); // buzzer alert that a switch is pressed
      digitalWrite(LED2,HIGH); 
      x++;

      delay(3000);
      digitalWrite(buzzer,LOW);
    }
  }

  if(c==LOW) // if player3 presses button
  { 
    if(x==1) // check if x is 1, if yes then execute the code
    {
      digitalWrite(buzzer,HIGH); // buzzer alert that a switch is pressed
      digitalWrite(LED3,HIGH); 
      x++;

      delay(3000);
      digitalWrite(buzzer,LOW);
    }
  }

  if(d==LOW) // if player4 presses button
  { 
    if(x==1) // check if x is 1, if yes then execute the code
    {
      digitalWrite(buzzer,HIGH); // buzzer alert that a switch is pressed
      digitalWrite(LED4,HIGH); 
      x++;

      delay(3000);
      digitalWrite(buzzer,LOW);
    }
  }

  if(e==LOW) // if player5 presses button
  { 
    if(x==1) // check if x is 1, if yes then execute the code
    {
      digitalWrite(buzzer,HIGH); // buzzer alert that a switch is pressed
      digitalWrite(LED5,HIGH); 
      x++;

      delay(3000);
      digitalWrite(buzzer,LOW);
    }
  }

   if(x==2)
   {
      delay(3000);
      digitalWrite(LED1,LOW);
      digitalWrite(LED2,LOW);
      digitalWrite(LED3,LOW);
      digitalWrite(LED4,LOW);
      digitalWrite(LED5,LOW);
   }
}

  void reset()
  {
    for(int i=0;i<4;i++)
    {
    digitalWrite(LED1,HIGH);
    digitalWrite(LED2,HIGH);
    digitalWrite(LED3,HIGH);
    digitalWrite(LED4,HIGH);
    digitalWrite(LED5,HIGH);
    digitalWrite(buzzer,HIGH);
    delay(100);
    digitalWrite(LED1,LOW);
    digitalWrite(LED2,LOW);
    digitalWrite(LED3,LOW);
    digitalWrite(LED4,LOW);
    digitalWrite(LED5,LOW);
    digitalWrite(buzzer,LOW);
    delay(100);
    }
  }

Circuit Diagram

Arduino based Fastest Figure First Controlling System for Quiz Competition Circuit Vidyasagar Academy Akola

The Prototype of Project

Arduino based Fastest Figure First Controlling System for Quiz Competition Vidyasagar Academy Akola
Share on your network!
Dattaraj Vidyasagar
Dattaraj Vidyasagar

Author on this website. He is veteran of Core Electronics since last 36+ years. ATL Mentor of Change, Niti Ayog, Govt. of India, Google Certified Educator, International Robotics Trainer and author of 18 books on electronics, robotics, programming languages and web designing... ➤➤

9 Comments

  1. Hey i found out 1 more problem that as it checks one by one if the button is pressed or not if 2 contestants have pressed their even before the round starts, it will show that button 1 is pressed first

    Any solution regarding this ….. BTW thanks for the referral code

  2. I wanted to say that if button1 and button 3 are pressed at same time before round starts and as round starts our system will show that button 1 was pressed first as it checks button1 the first

    • The code is now updated as per your valuable suggestion.
      Now the connections of the 5+1 switches are changed.
      ======= Connection details =======
      Switches connections:
      player1: A0, player2: A1, player3: A2, player4: A3, player5: A4
      Judge: A5
      LED1: pin-D2, LED2: pin-D3, LED3: pin-D4, LED4: pin-D5, LED5: pin-D6
      Buzzer: pin-D7
      /* Here at the start of 1st round, judge presses his button.
      * So the session starts.
      * When any contestant presses his/her button, the buttons of
      * other contestants will be disabled.
      * In this way, the 1st session is over.
      * Now since 1st session is over, the value of x = 2 in the code,
      * so any contestant cannot press his/her switch before the start
      * of the new session.
      * Now when judge presses his button, the value of x = 1
      * So new session can start.
      * In this way automatic RESET of this circuit is removed.
      */
      Please check and reply to this comment.
      Thanks for the feedback.

Leave a Reply

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