Scoreboard project (First Project) Need some advice

For my first project I'm building a scoreboard for my brothers shuffleboard table. It will also be used for washers and cornhole games. I found several scoreboard projects using arduino and the MAX7219 chip to drive the LED displays but none of them did exactly what I was looking for. I looked at several scoreboard codes and some arduino tutorial videos and taught myself how code the arduino enough to modify them to suit my needs. I wanted the scores to count up, count down, each score have a reset and be displayed on dual two-digit LED seven segment displays. I have finished modifying the code in arduino and have built the prototype. After a few bug fixes it is working as intended!

Here is a sketch of the prototype I did in Fritzing.

This is the code if anyone is interested. I'm sure it could be written more efficiently but this is my first attempt so forgive me if so.

/* Arduino 7 Segment scoreboard 
 * Using the MAX7219CNG LED Driver
 
Modified oroginal code from https://www.brainy-bits.com to add score down buttons and reset buttons
*/

#include "LedControl.h"  // Library used for communcation with 7 segment

LedControl lc=LedControl(12,11,10,1);  //  (DIN, CLK, LOAD, number of Max7219 chips)

// Variable to hold current scores
int scoreRed=0;
int scoreBlue=0;

// Variables to split whole number into single digits
int rightdigit;
int leftdigit;

// Switches pin connection to Arduino UNO
#define redUp 2
#define blueUp 3
#define redDown 4
#define blueDown 5
#define redReset 6
#define blueReset 7

void setup() {
  pinMode(redUp,INPUT_PULLUP);
  pinMode(blueUp,INPUT_PULLUP);
  pinMode(redDown,INPUT_PULLUP);
  pinMode(blueDown,INPUT_PULLUP);
  pinMode(redReset,INPUT_PULLUP);
  pinMode(blueReset,INPUT_PULLUP);
  
  lc.shutdown(0,false);  // Wake up MAX7219

  lc.setIntensity(0,7);  // Set brightness to medium

  lc.clearDisplay(0);  // Clear all displays connected to MAX7219 chip #

// Put zeros on both displays at startup
  
  lc.setDigit(0,0,0,false);  // (Max7219 chip #, Digit, value, DP on or off) Red Score
  lc.setDigit(0,1,0,false);
  
  lc.setDigit(0,2,0,false);  // (Max7219 chip #, Digit, value, DP on or off) Blue Score
  lc.setDigit(0,3,0,false);

}


void loop() { 

  // If switch redUp is clicked
  if (!digitalRead(redUp)) {
    
    scoreRed++;  // Increase scoreRed by 1
  
    // convert whole number to single digits
    rightdigit=scoreRed%10;
    leftdigit=scoreRed%100/10;

    // Display extracted digits on the display
    lc.setDigit(0,0,leftdigit,false);
    lc.setDigit(0,1,rightdigit,false);

    // Wait until switch is released to continue
    while (!digitalRead(redUp)) { 
    }
    delay(5);  // Small delay to debounce the switch
  }

  // If switch redDown is clicked
  if (!digitalRead(redDown)) {
    
    scoreRed--;  // Decrease scoreRed by 1
  
    // convert whole number to single digits
    rightdigit=scoreRed%10;
    leftdigit=scoreRed%100/10;

    // Display extracted digits on the display
    lc.setDigit(0,0,leftdigit,false);
    lc.setDigit(0,1,rightdigit,false);

    // Wait until switch is released to continue
    while (!digitalRead(redDown)) { 
    }
    delay(5);  // Small delay to debounce the switch
  }

    // If switch redReset is clicked
    if (!digitalRead(redReset)) {
    
    scoreRed=00;  // Reset scoreRed to 0
  
    lc.setDigit(0,0,0,false);
    lc.setDigit(0,1,0,false);

    // Wait until switch is released to continue
    while (!digitalRead(redReset)) { 
    }
    delay(5);  // Small delay to debounce the switch
  }

    // If switch blueUp is clicked
    if (!digitalRead(blueUp)) {
      
    scoreBlue++;  // Increase scoreBlue by 1

    // convert whole number to single digits
    rightdigit=scoreBlue%10;
    leftdigit=scoreBlue%100/10;

    // Display extracted digits on the display
    lc.setDigit(0,2,leftdigit,false);
    lc.setDigit(0,3,rightdigit,false);

    // Wait until switch is released to continue
    while (!digitalRead(blueUp)) { 
    }    
    delay(5); // Small delay to debounce the switch
  }

  // If switch blueDown is clicked
  if (!digitalRead(blueDown)) {
    
    scoreBlue--;  // Decrease scoreBlue by 1
  
    // convert whole number to single digits
    rightdigit=scoreBlue%10;
    leftdigit=scoreBlue%100/10;

    // Display extracted digits on the display
    lc.setDigit(0,2,leftdigit,false);
    lc.setDigit(0,3,rightdigit,false);
    
    // Wait until switch is released to continue
    while (!digitalRead(blueDown)) { 
    }
    delay(5);  // Small delay to debounce the switch
  }

    // If switch blueReset is clicked
    if (!digitalRead(blueReset)) {
    
    scoreBlue=00;  // Reset scoreBlue to 0
  
    lc.setDigit(0,2,0,false);
    lc.setDigit(0,3,0,false);

    // Wait until switch is released to continue
    while (!digitalRead(blueReset)) { 
    }
    delay(5);  // Small delay to debounce the switch
  }
  
}

I've also written code to include a "coin flip" button using LED's to indicate the winner of the flip to see who goes first but still need to debug and test it a bit more.

My issue is how to design the circuit for the LED's when I build the final version. I plan to use 4 LED's in series with a 33 ohm resistor for each of the 7 segments. From what I read the arduino can not supply the needed voltage (9v) or the have the mA capacity to power the 4 digits. I will be using a 9v power supply and split it to power the arduino and the LED circuit but have no idea how to make the two circuits at different voltages (5v & 9v) talk to each other to display the score on the LED circuit.

Any help or suggestions would be appreciated

Thanks,
Jerry

The Vin and barrel jack of the Arduino can take 7 ~ 12VDc (The barrel Jack has additoinal reverse polarity protection
At 9V and with 4 LEDs attached, there should not be enough power draw to overheat the internal regulator.
Else, use something like a LM341-5.0 voltage regulator.
This PDF provides some info.
Page 10 shows a typical usage diagram.

Thanks for your reply.

I will be powering the arduino through the barrel jack with a 9v power supply. The voltage of the arduino pin output is only 5v. Each 4 LED segment is only 20mA but with 7 segments per digit and 4 digits total the mA draw for all 28 segments would be greater than the arduino could supply and at only 5v instead of the 9v required.

I need to figure out how to take the 5v signal from the MAX7219 and send it the the LED's at 9v.

Jerry

What LEDs are you using?
You might need to use a different driver if the power/voltage requirements of the LED exceeds the capabilities of the MAX7219

Standard 5mm red LEDs. 2.1v 20mA.

jfrodgers:
Standard 5mm red LEDs. 2.1v 20mA.

That, is not a 7 segment LED display. It is a single LED

Are you saying that your project is instead going to use 4 separate LED-matrix numbers?

Whatever the case, I suggest that you read through this article. It will show you how to run an Arduino, two MAX7219 drivers, an 8x8 LED matrix and up to 8 7-segment LEDs from a single 5V power source.

Just check which type your LEDs are. Common Cathode or Common Anode

Hi,

As a suggestion, can't you use the display you have and get, when the Toss Button is pressed, the score board output of the winner to flash 88 ON and OFF, no need for extra display hardware.

All you will need is a mode switch, "Coin Toss" or "Game Score".
You can use one of the existing buttons as the Toss Button.

Tom... :slight_smile:

To make your button presses a bit more reliable - even though you have a debounce delay()
Look into state-change detection - which will add two lines to your code, and solve that problem

darrob:
That, is not a 7 segment LED display. It is a single LED

Are you saying that your project is instead going to use 4 separate LED-matrix numbers?

Whatever the case, I suggest that you read through this article. It will show you how to run an Arduino, two MAX7219 drivers, an 8x8 LED matrix and up to 8 7-segment LEDs from a single 5V power source.

Just check which type your LEDs are. Common Cathode or Common Anode

I’m using 4 red leds in series with a 33 ohm resistor to make up each of the seven segments for each digit. So 28 leds total for each of the four digits.

TomGeorge:
Hi,

As a suggestion, can't you use the display you have and get, when the Toss Button is pressed, the score board output of the winner to flash 88 ON and OFF, no need for extra display hardware.

All you will need is a mode switch, "Coin Toss" or "Game Score".
You can use one of the existing buttons as the Toss Button.

Tom... :slight_smile:

I hadn't thought about that, great suggestion. I'm still very new to coding the arduino and adding a button and 2 leds seemed simpler.

Maxim have an app note on driving LED with higher voltage requirements here
See figure 3 for ideas.

Well the size and scope of the project has changed and I will be using 4 MAX7219 8x8 LED Matrix for the display. Two for each score. I've been trying to modify the code from the 7 segment to Matrix but I'm not having much luck. I'm sure I need to load the digits into an array of some sort but I'm lost. I'm also not sure i have the digits set up correctly either. Below how they are ordered. Red score is Matrix 3 & 2, Blue score is Matrix 1 & 0.

Red Blue
(3) (2) (1) (0)

I've put frames into an array for a simple coin flip also and arrows to point left or right at random but haven't finished it.

Any help would be very much appreciated, time is a factor now and My head is about to explode lol.

Thanks,
Jerry

Code as of now

#include "LedControl.h"  // Library used for communcation with 7 segment

int DIN=12;  //initialize data (load) to pin 12
int CLK=11;  //initialize clock to pin 11
int CS=10;  //initialize chip select to pin 10
int MAX=4;  //number of displays connected
int delayTime=75;  // Delay between Frames

LedControl lc=LedControl(DIN,CLK,CS,MAX);  // Pins: DIN,CLK,CS, # of Display connected

// Variable to hold current scores
int scoreRed=0;
int scoreBlue=0;

// Variables to split whole number into single digits
int rightdigit;
int leftdigit;

// Switches pin connection to Arduino UNO
#define redUp 2
#define redDown 3
#define redReset 4
#define blueUp 5
#define blueDown 6
#define blueReset 7
#define flipButton 8

// Coin Frames 1-4 & Arrows values in arrays
byte Coin1[] = {B00011000,B00011000,B00011000,B00011000,B00011000,B00011000,B00011000,B00011000};
byte Coin2[] = {B00000010,B00000111,B00001110,B00011100,B00111000,B01110000,B11100000,B01000000};
byte Coin3[] = {B00000000,B00000000,B00000000,B11111111,B11111111,B00000000,B00000000,B00000000};
byte Coin4[] = {B01000000,B11100000,B01110000,B00111000,B00011100,B00001110,B00000111,B00000010};
byte RTARW[] = {B00111000,B00111000,B00111000,B00111000,B11111110,B01111100,B00111000,B00010000};  //Left Arrow Rotated
byte LTARW[] = {B00010000,B00111000,B01111100,B11111110,B00111000,B00111000,B00111000,B00111000};  //Right Arrow Rotated

void setup() {
  pinMode(redUp,INPUT_PULLUP);
  pinMode(blueUp,INPUT_PULLUP);
  pinMode(redDown,INPUT_PULLUP);
  pinMode(blueDown,INPUT_PULLUP);
  pinMode(redReset,INPUT_PULLUP);
  pinMode(blueReset,INPUT_PULLUP);
  pinMode(flipButton,INPUT_PULLUP);
  
  lc.shutdown(0,false);  // Wake up displays
  lc.shutdown(1,false);
  lc.shutdown(2,false);
  lc.shutdown(3,false);

  lc.setIntensity(0,5);  // Set intensity levels
  lc.setIntensity(1,5);
  lc.setIntensity(2,5);
  lc.setIntensity(3,5);

  lc.clearDisplay(0);  // Clear Displays
  lc.clearDisplay(1);
  lc.clearDisplay(2);
  lc.clearDisplay(3);
  
// Put zeros on both displays at startup
  lc.setDigit(0,0,0,false);  // (Max7219 chip #, Digit, value, DP on or off) Red Score
  lc.setDigit(1,1,0,false);
  
  lc.setDigit(2,2,0,false);  // (Max7219 chip #, Digit, value, DP on or off) Blue Score
  lc.setDigit(3,3,0,false);

}

void loop() { 

  // If switch redUp is clicked
  if (!digitalRead(redUp)) {
    
    scoreRed++;  // Increase scoreRed by 1
  
    // convert whole number to single digits
    rightdigit=scoreRed%10;
    leftdigit=scoreRed%100/10;

    // Display extracted digits on the display
    lc.setDigit(0,0,leftdigit,false);
    lc.setDigit(1,1,rightdigit,false);

    // Wait until switch is released to continue
    while (!digitalRead(redUp)) { 
    }
    delay(5);  // Small delay to debounce the switch
  }

  // If switch redDown is clicked
  if (!digitalRead(redDown)) {
    
    scoreRed--;  // Decrease scoreRed by 1
  
    // convert whole number to single digits
    rightdigit=scoreRed%10;
    leftdigit=scoreRed%100/10;

    // Display extracted digits on the display
    lc.setDigit(0,0,leftdigit,false);
    lc.setDigit(1,1,rightdigit,false);

    // Wait until switch is released to continue
    while (!digitalRead(redDown)) { 
    }
    delay(5);  // Small delay to debounce the switch
  }

    // If switch redReset is clicked
    if (!digitalRead(redReset)) {
    
    scoreRed=00;  // Reset scoreRed to 0
  
    lc.setDigit(0,0,0,false);
    lc.setDigit(1,1,0,false);

    // Wait until switch is released to continue
    while (!digitalRead(redReset)) { 
    }
    delay(5);  // Small delay to debounce the switch
  }

    // If switch blueUp is clicked
    if (!digitalRead(blueUp)) {
      
    scoreBlue++;  // Increase scoreBlue by 1

    // convert whole number to single digits
    rightdigit=scoreBlue%10;
    leftdigit=scoreBlue%100/10;

    // Display extracted digits on the display
    lc.setDigit(2,2,leftdigit,false);
    lc.setDigit(3,3,rightdigit,false);

    // Wait until switch is released to continue
    while (!digitalRead(blueUp)) { 
    }    
    delay(5); // Small delay to debounce the switch
  }

  // If switch blueDown is clicked
  if (!digitalRead(blueDown)) {
    
    scoreBlue--;  // Decrease scoreBlue by 1
  
    // convert whole number to single digits
    rightdigit=scoreBlue%10;
    leftdigit=scoreBlue%100/10;

    // Display extracted digits on the display
    lc.setDigit(2,2,leftdigit,false);
    lc.setDigit(3,3,rightdigit,false);
    
    // Wait until switch is released to continue
    while (!digitalRead(blueDown)) { 
    }
    delay(5);  // Small delay to debounce the switch
  }

    // If switch blueReset is clicked
    if (!digitalRead(blueReset)) {
    
    scoreBlue=00;  // Reset scoreBlue to 0
  
    lc.setDigit(2,2,0,false);
    lc.setDigit(3,3,0,false);

    // Wait until switch is released to continue
    while (!digitalRead(blueReset)) { 
    }
    delay(5);  // Small delay to debounce the switch
  }

}

Hello!
I tried to copy the your scoreboard from you first post. I have no experiences with Arduino, no further experience in electronics. But I want to build a fixed scoreboard into a hobby project. So I have no incentives to "deep dive" into it, but I would like to get it usable. :grin: Maybe you could help me...
I'm at this point:

There is no reaction to any of the push buttons. I guess the 7 segments have to glow completely? Maybe there is something not connected correctly? Is it possible to give me a hint, what have to be fixed by the picture?
They are 7 segment cathode screens 3621AS and it's not a original Uno, but I hope that's not the prblem. I copied the code from the first positing 1:1 and installied it on the board.
Thank you!

Solved! :wink: The 7-Segments have another configuration of their pins.