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