problem code for hold buttons

goodmorning guys..
i need a little help with this project..i want to play it like a game..the first person to press will win..but the problem is that the first player will always win at the does not call for the timer function..why?

//Define the Buttons

#include "ClickButton.h"

//button input pins (digital)
int b1 = 7;
int b2 = 8; 
int b3 = 9;
const int bu4=6;

//button status
int bu1, bu2, bu3 = 0;

int lastClickCode=0;
int r,x=0;

//Status of whether or not a button has been pressed;
int hold = 0;

ClickButton button1(bu4, LOW, CLICK_PULLUP);

void setup() {                
  //allows you to see on a computer who buzzed in first

 //Lockout Status LED pin with is statndard on the Arduino Board(s)
  pinMode(13, OUTPUT);
  //Button inputs defined
  pinMode(b1, INPUT);
  pinMode(b2, INPUT);
  pinMode(b3, INPUT);

  //The delay allows time for the voltage to stabilize (exp. because the electronics are not removed from the buttons!)

void loop(){

void sign() {
  //Read to see if a button is pushed
  if(hold == 0){
    bu1 = digitalRead(b1);
    bu2 = digitalRead(b2);
    bu3 = digitalRead(b3);
  //If the status of any of the Buttons has changed to being pulled low
  //lockout the other users and light up the appropriate button
    //player 1
     	     hold = 1; //lockout the other users

      	    Serial.println("Player 1"); 
    //player 2
          if(bu2 == 0){
              hold = 1; //lockout the other users
              Serial.println("Player 2");
    //player 3
          if(bu3 == 0){
      hold = 1; //lockout the other users
      Serial.println("Player 3");

void timer(){
   // Note: Will return the last click decoded, even if no new clicks are received!
  // Toggle LED on single clicks. But only if the click code is new
  if( == CLICK_SINGLECLICK && != lastClickCode)

  // blink faster if double clicked
  if( == CLICK_DOUBLECLICKED&&!=lastClickCode) 
  // blink even faster if triple clicked
  if( == CLICK_TRIPLECLICKED&&!=lastClickCode) {
  Serial.println(" ");

  // update the LED

  // Save previous button click code
  lastClickCode =;

///////////////////////////////SELECTS TIME TO USE////////////////////////////////

What do you have connected to pins 7, 8, and 9? Switches, presumably. But, how are they wired?

Using the internal pullup resistors is easier than using external resistors. Simply connect one leg of the switch to ground and the other leg to a pin, and enable the pullup, using INPUT_PULLUP as the pinMode (1.0+) or adding digitalWrite(pinNumber, HIGH); after the pinMode(pinNumber, INPUT); statement.

Then, HIGH is not pressed and LOW is pressed.

thank you sir…i have finally make it to work…but another problem is that the function timer(); cant be called after the loop of having the first winner, again, it just waits for another input to happen…should i use interrupts? because the system goes like this, after selecting the winner, the game master should select a time enable him to answer… if he cant answer with in that time …it will go back to the loop…thanks sir…:smiley:

another problem is that the function timer(); cant be called after the loop of having the first winner, again, it just waits for another input to happen.

You haven’t posted new code or described what changes you have made to the hardware.

should i use interrupts?

What would trigger the interrupt? What would you do when the interrupt occurred. Typically, the need to use interrupts is quite obvious. If you aren’t sure, you probably don’t need interrupts.