Introduction: Easy Arduino Pushbutton Scoring for Two Teams

Here is a simple pushbutton scoring setup for two teams. It has an up and a down button for each team and a reset button to set the scores back to 0. It displays the scores in the Serial Monitor. I'm sure with minimal changes you can make it work for whatever application you need it for.

Step 1: Materials

Step 2: Wire the Buttons

The buttons on the left are the micro switches out of the bottom of the arcade buttons.

Cut one end off of 5 of the wires, strip the end, and crimp the terminal connectors on. The terminal connectors slide onto the micro switch terminals.

Use the breadboard and wires to hook up the system.

Step 3: Upload the Program

Copy and paste the program into the Arduino IDE and upload to the Arduino

Program:

-----------------------------------------------------------------------------------------------------

/*
Two team up and down pushbutton scoring with reset
What it does:
Senses when the buttons change state and adds or subtracts
one from the appropriate teams total
Reset button sets both teams scores back to zero
Prints results in Serial Monitor
Feel free to use and modify this for any purpose
Enjoy!
*/
const byte Button = A0;
const byte Button1 = A1;
const byte Reset = A2;
const byte Button2 = A3;
const byte Button3 = A4;
byte ButtonState;
byte ButtonState1;
byte ResetState;
byte ButtonState2;
byte ButtonState3;
byte lastState = LOW;
byte count = 0;
byte count1 = 0;
void setup() {
Serial.begin(9600);
pinMode(Button, INPUT);
pinMode(Button1, INPUT);
pinMode(Reset, INPUT);
pinMode(Button2, INPUT);
pinMode(Button3, INPUT);
}
void loop() {
//Buttons
ButtonState = digitalRead(Button);
ButtonState1 = digitalRead(Button1);
ResetState = digitalRead(Reset);
ButtonState2 = digitalRead(Button2);
ButtonState3 = digitalRead(Button3);
//Buttons End
//Button Count and Display
if(ButtonState && ButtonState != lastState) // button latch, no debounce needed.
{
if(count < 255) // This will check to see if the count is within a range of 0 - 255, and anything over that, it will reset count back to 0. Of course, this will happen anyways because count is a BYTE, and not an int or any other type.
count += 1; // same as count = count + 5;
else
count = 0;
delay(250);
Serial.print("Red Team score: ");
Serial.println(count);
}
if(ButtonState1 && ButtonState1 != lastState) // button latch, no debounce needed.
{
if(count < 255) // This will check to see if the count is within a range of 0 - 255, and anything over that, it will reset count back to 0. Of course, this will happen anyways because count is a BYTE, and not an int or any other type.
count -= 1; // same as count = count + 5;
else
count = 0;
delay(250);
Serial.print("Red Team score: ");
Serial.println(count);
}
if(ResetState && ResetState != lastState) // button latch, no debounce needed.
{
if(count < 255) // This will check to see if the count is within a range of 0 - 255, and anything over that, it will reset count back to 0. Of course, this will happen anyways because count is a BYTE, and not an int or any other type.
count = 0;
else
count = 0;
count1 = 0;
delay(250);
Serial.print("Red Team score: ");
Serial.println(count);
Serial.print("Blue Team score: ");
Serial.println(count1);
}
if(ButtonState2 && ButtonState2 != lastState) // button latch, no debounce needed.
{
if(count1 < 255) // This will check to see if the count is within a range of 0 - 255, and anything over that, it will reset count back to 0. Of course, this will happen anyways because count is a BYTE, and not an int or any other type.
count1 += 1; // same as count = count + 5;
else
count1 = 0;
delay(250);
Serial.print("Blue Team score: ");
Serial.println(count1);
}
if(ButtonState3 && ButtonState3 != lastState) // button latch, no debounce needed.
{
if(count1 < 255) // This will check to see if the count is within a range of 0 - 255, and anything over that, it will reset count back to 0. Of course, this will happen anyways because count is a BYTE, and not an int or any other type.
count1 -= 1; // same as count = count + 5;
else
count1 = 0;
delay(250);
Serial.print("Blue Team score: ");
Serial.println(count1);
}

lastState = ButtonState;
//Button Count and Display End
}//Void loop end

-------------------------------------------------------------------------------------------------------------------------

Step 4: Use the System

The values will display in the Serial Monitor.