help with modifying code

hello I was working on driving an 4 digit 7 segment display (common cathode) with an max7219 driver.
to be more specific I was working on an project that was taking input from an button and then displaying how many times the button was pressed on the 7 segment display. to elaborate I found some code (listed bellow) that dose just that but I was trying to modify the code so it only has one input (it only has one input and only displays that one input) and also I was wanting it to count up to 9999 on all four digits rather than just 99. I have been reluctant to ask for help but I have been trying to work on modifying this code all weekend and IF anyone who is more experienced with the max7219 library can help me with this than that would be an real life saver. thanks in advance to anyone who can help me than that would be really appreciated

the code (not modifyed. grabed from https://www.brainy-bits.com/using-7-segment-display-with-arduino/)

/* Arduino 7 Segment scoreboard

  • Using the MAX7219CNG LED Driver

Created by Yvan / https://Brainy-Bits.com

This code is in the public domain...

You can: copy it, use it, modify it, share it or just plain ignore it!
Thx!

*/

#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 displayone=0;
int displaytwo=0;

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

// Switches pin connection to Arduino UNO
#define switchone 2
#define switchtwo 3

void setup() {
pinMode(switchone,INPUT_PULLUP);
pinMode(switchtwo,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)
lc.setDigit(0,1,0,false);

lc.setDigit(0,2,0,false);
lc.setDigit(0,3,0,false);

}

void loop() {

// If switch 1 is clicked
if (!digitalRead(switchone)) {

displayone++; // Increase score by 1

// convert whole number to single digits
rightdigit=displayone%10;
leftdigit=displayone%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(switchone)) {
}
delay(5); // Small delay to debounce the switch
}

if (!digitalRead(switchtwo)) {

displaytwo++;

rightdigit=displaytwo%10;
leftdigit=displaytwo%100/10;

lc.setDigit(0,2,leftdigit,false);
lc.setDigit(0,3,rightdigit,false);

while (!digitalRead(switchtwo)) {
}
delay(5);
}
}

So, this code is what you found on the net? You haven't changed anything?

Getting rid of second switch is done by removing statements to initialize the variables associated with it like

#define switchtwo 3, int displaytwo=0;

You then delete the second loop that handled the count of the 2nd input

if (!digitalRead(switchtwo)) {

...
...
}

The remaining 1st loop is all you need.
You rename rightdigit to onesdigit, leftdigit to tensdigit and then define
int hunddigit and int thoudigit. Then 1st loop becomes

if (!digitalRead(switchone)) {

displayone++; // Increase score by 1

// convert whole number to single digits
onesdigit=displayone%10;
tensdigit=displayone%100/10;
hunddigit=displayone%1000/100;
thoudigit=displayone%10000/1000;

// Display extracted digits on the display
lc.setDigit(0,0,onesdigit,false);
lc.setDigit(0,1,tensdigit,false);
lc.setDigit(0,2,hunddigit,false);
lc.setDigit(0,3,thoudigit,false);

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

That should do it...

Hey nerd, Dale, would you guys mind using [code] (and [/code]) tags?

thanks so much with helping me out. and I will try using the code tags (Sorry but I am new to this site) everyone that helped me is an life saver. thanks so much and everyone have an good day

I just got done finishing the code and wanted to post the completed code for anyone who was looking to use it. I would once again like to thanks everyone for helping an newbie like me. I also made some modifications to the code to fix the way that the 7 segment display was being addressed. i.e. the ones digit was being addressed in the thousands position making the numbers appear to be backwards. i also changed what digits were being addressed and the order that they would appear.

/* Arduino 7 Segment scoreboard
   Using the MAX7219CNG LED Driver

  Created by Yvan / https://Brainy-Bits.com

  This code is in the public domain...

  You can: copy it, use it, modify it, share it or just plain ignore it!
  Thx!

*/

#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 displayone = 0;

// Variables to split whole number into single digits
int onesdigit;
int tensdigit;
int hunddigit;
int thoudigit;

// Switches pin connection to Arduino UNO
#define switchone 2


void setup() {
  pinMode(switchone, 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, 3, 0, false); // (Max7219 chip #, Digit, value, DP on or off)
  lc.setDigit(0, 2, 0, false);

  lc.setDigit(0, 1, 0, false);
  lc.setDigit(0, 0, 0, false);

}


void loop() {
  if (!digitalRead(switchone)) {

    displayone++;  // Increase score by 1

    // convert whole number to single digits
    onesdigit = displayone % 10;
    tensdigit = displayone % 100 / 10;
    hunddigit = displayone % 1000 / 100;
    thoudigit = displayone % 10000 / 1000;

    // Display extracted digits on the display
    lc.setDigit(0, 3, onesdigit, false);
    lc.setDigit(0, 2, tensdigit, false);
    lc.setDigit(0, 1, hunddigit, false);
    lc.setDigit(0, 0, thoudigit, false);


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