Help with project has been received. Thank you

I need assistance from code writer to complete sketch for a LED Clock. I am offering compensation for the effort. (Sketches were found online)
The sketch I would like to use is for a six digit display composed of seven segment modules, has LED to indicate PM (clock runs in 12 hour mode), but there is no code for setting the time. The sketch was originally written by coder 1 for a four digit display clock, blinking LED for seconds and two buttons to set the time.
When the sketch was modified by coder 2, the display was expanded to have digits for the seconds, the blinking led was repurposed to be a PM LED, but for some reason, the buttons were omitted. The RTC module was also changed from a DS3231 to DS1307. I would like to restore the buttons for time-setting. The buttons were assigned as 'Button 1 to set Hours, and Button 2 to set minutes. They only counted forward one digit per button press, but the minute button seemed to reset the seconds count to zero each time it was pressed. I liked that because it made it easier to synchronize the time to another clock.
The original sketch I found is posted here…

#include "SevSeg.h"
#include <DS3231.h>
DS3231  rtc(SDA, SCL);
Time  t;
SevSeg Display;
const int hrs_set = A0;
const int min_set = A1;
const int ledPin =  A3;
unsigned int number = 0;
const long interval = 500;
unsigned long startMillis;
unsigned long currentMillis;
unsigned long previousMillis = 0;
unsigned int Hour = 0;
unsigned int hrs_var = 0;
unsigned int min_var = 0;
int ledState = HIGH;

void setup()
{
  rtc.begin();
  pinMode(ledPin, OUTPUT);
  pinMode(hrs_set, INPUT_PULLUP);
  pinMode(min_set, INPUT_PULLUP);
  byte numDigits = 4;
  byte digitPins[] = {10, 11, 12, 13};
  byte segmentPins[] = {2, 3, 4, 5, 6, 7, 8};
  bool resistorsOnSegments = false;
  bool updateWithDelays = false;
  byte hardwareConfig = COMMON_ANODE;
  bool leadingZeros = false;
  bool disableDecPoint = true;
  Display.begin(hardwareConfig, numDigits, digitPins, segmentPins, resistorsOnSegments, updateWithDelays, disableDecPoint);
  Display.setBrightness(60);
}

void loop()
{
  unsigned long currentMillis = millis();
  if (currentMillis - previousMillis >= interval)
  {
    previousMillis = currentMillis;
    if (ledState == HIGH)
    {
      ledState = LOW;
    }
    else
    {
      ledState = HIGH;
    }
    digitalWrite(ledPin, ledState);
  }
  t = rtc.getTime();
  Hour = t.hour;
  hrs_var = t.hour;
  min_var = t.min;
  if (t.hour > 12)
  {
    if (t.hour == 13) Hour = 1;
    if (t.hour == 14) Hour = 2;
    if (t.hour == 15) Hour = 3;
    if (t.hour == 16) Hour = 4;
    if (t.hour == 17) Hour = 5;
    if (t.hour == 18) Hour = 6;
    if (t.hour == 19) Hour = 7;
    if (t.hour == 20) Hour = 8;
    if (t.hour == 21) Hour = 9;
    if (t.hour == 22) Hour = 10;
    if (t.hour == 23) Hour = 11;
  }
  else
  {
    if (t.hour == 0) Hour = 12;
  }
  number = Hour * 100 + t.min;
  Display.setNumber(number);
  Display.refreshDisplay();
  if (digitalRead(hrs_set) == HIGH)
  {
    hrs_var += 1;
    if (hrs_var > 23) hrs_var = 0;
    rtc.setTime(hrs_var, min_var, 0);
    for (int i = 0; i < 1000; i ++)
    {
      Display.setNumber(number);
      Display.refreshDisplay();
    }
  }
  if (digitalRead(min_set) == HIGH)
  {
    min_var += 1;
    if (min_var >= 60) min_var = 0;
    rtc.setTime(hrs_var, min_var, 0);
    for (int i = 0; i < 1000; i ++)
    {
      Display.setNumber(number);
      Display.refreshDisplay();
    }
  }
}

and here is the modified code…

#include "SevSeg.h"
#include <Wire.h>
#include <TimeLib.h>
#include <DS1307RTC.h>
SevSeg Display;
// const int hrs_set = A0;  /hour setting button
// const int min_set = A1;  /minute setting button
const int ledPin =  A3;
unsigned long timeDisplay;
unsigned long currentMillis;
unsigned int Hour;
int ledState = LOW;
unsigned long previousMillis = 0;
const long interval = 500;
void setup()
{
  pinMode(ledPin, OUTPUT);
  byte numDigits = 6;
  byte digitPins[] = {9, 10, 11, 12, 13, A2};
  byte segmentPins[] = {2, 3, 4, 5, 6, 7, 8};
  bool resistorsOnSegments = false; // false = resistors are on digit pins
  bool updateWithDelaysIn = true;
  byte hardwareConfig = COMMON_ANODE;
  Display.begin(hardwareConfig, numDigits, digitPins, segmentPins, resistorsOnSegments);
  Display.setBrightness(60);
}
void loop()
{
  tmElements_t tm;
  if (RTC.read(tm))
  {
    Hour = tm.Hour;
    if (tm.Hour >= 12)
    {
    if (tm.Hour == 13) Hour = 1;
    if (tm.Hour == 14) Hour = 2;
    if (tm.Hour == 15) Hour = 3;
    if (tm.Hour == 16) Hour = 4;
    if (tm.Hour == 17) Hour = 5;
    if (tm.Hour == 18) Hour = 6;
    if (tm.Hour == 19) Hour = 7;
    if (tm.Hour == 20) Hour = 8;
    if (tm.Hour == 21) Hour = 9;
    if (tm.Hour == 22) Hour = 10;
    if (tm.Hour == 23) Hour = 11;
    ledState = HIGH; // PM
    }
    else
    {
    if (tm.Hour == 0) Hour = 12;
    ledState = LOW; // AM 
    }       
    digitalWrite(ledPin, ledState);
    timeDisplay = (Hour * 100 + tm.Minute) * 100L + tm.Second;
    }
    else 
    {  
    timeDisplay = 888888; // error
  }
  Display.setNumber(timeDisplay);
  Display.refreshDisplay();
}

Since the two sketches used different RTC modules, I couldn’t figure out how to change the time-setting code in the first sketch to add to the second sketch. I also have the wiring diagram for the original clock shown here…

and the diagram for the clock I wish to complete…

This is a one-time project involving Arduino, and any help would be greatly appreciated.

Hello, I do not have the necessary hardware to test it, try it yourself in case I have erred in the programming.

include "SevSeg.h"
#include <Wire.h>
#include <TimeLib.h>
#include <DS1307RTC.h>
SevSeg Display;
const int hrs_set = A0;  //hour setting button
const int min_set = A1;  //minute setting button
const int ledPin =  A3;
unsigned long timeDisplay;
unsigned long currentMillis;
unsigned int Hour;
int ledState = LOW;
unsigned long previousMillis = 0;
const long interval = 500;
void setup()
{
  pinMode(ledPin, OUTPUT);
  byte numDigits = 6;
  byte digitPins[] = {9, 10, 11, 12, 13, A2};
  byte segmentPins[] = {2, 3, 4, 5, 6, 7, 8};
  bool resistorsOnSegments = false; // false = resistors are on digit pins
  bool updateWithDelaysIn = true;
  byte hardwareConfig = COMMON_ANODE;
  Display.begin(hardwareConfig, numDigits, digitPins, segmentPins, resistorsOnSegments);
  Display.setBrightness(60);
}
void loop()
{
  tmElements_t tm;
  if (RTC.read(tm))
  {
    Hour = tm.Hour;
    if (tm.Hour >= 12)
    {
    if (tm.Hour == 13) Hour = 1;
    if (tm.Hour == 14) Hour = 2;
    if (tm.Hour == 15) Hour = 3;
    if (tm.Hour == 16) Hour = 4;
    if (tm.Hour == 17) Hour = 5;
    if (tm.Hour == 18) Hour = 6;
    if (tm.Hour == 19) Hour = 7;
    if (tm.Hour == 20) Hour = 8;
    if (tm.Hour == 21) Hour = 9;
    if (tm.Hour == 22) Hour = 10;
    if (tm.Hour == 23) Hour = 11;
    ledState = HIGH; // PM
    }
    else
    {
    if (tm.Hour == 0) Hour = 12;
    ledState = LOW; // AM 
    }       
    digitalWrite(ledPin, ledState);
    timeDisplay = (Hour * 100 + tm.Minute) * 100L + tm.Second;
    }
    else 
    {  
    timeDisplay = 888888; // error
  }
  Display.setNumber(timeDisplay);
  Display.refreshDisplay();
  if (digitalRead(hrs_set) == HIGH)
  {
    tm.Hour += 1;
    if (tm.Hour > 23) tm.Hour = 0;
    RTC.set(tm.Minute);
    for (int i = 0; i < 1000; i ++)
    {
      Display.setNumber(timeDisplay);
      Display.refreshDisplay();
    }
  }
  if (digitalRead(min_set) == HIGH)
  {
    tm.Minute += 1;
    if (tm.Minute >= 60) tm.Minute = 0;
    RTC.set(tm.Hour);
    for (int i = 0; i < 1000; i ++)
    {
      Display.setNumber(timeDisplay);
      Display.refreshDisplay();
    }
  }
}

I just tried to compile the sketch, and received an error

include “SevSeg.h” "Include’ does not name a type.

Just spotted the problem. The # was missing from the beginning of the line that displayed the error.
The sketch compiled without any errors, and uploaded to the Uno. The buttons are not working properly. When I press the hour button, the display resets to 12:00:00, then starts counting normally. When I press the minutes button, the same thing happens.
So reinstalled the previous version of the sketch, and display is working normally, but no button function like before.

What clock module are you using exactly? and, Could you also give me the links where you got those schematics and codes?

Those buttons are tied to ground so you need to enable the internal pull-up resistors in setup(). You should also look at the State Change Detection example in the ide to see how to detect when a button CHANGES state, not just detect its current state

#include "SevSeg.h"
#include <Wire.h>
#include <TimeLib.h>
#include <DS1307RTC.h>
SevSeg Display;
const int hrs_set = A0;  //hour setting button
const int min_set = A1;  //minute setting button
const int ledPin =  A3;

int prevHourButtonState, prevMinButtonState;

void setup()
{
  pinMode(ledPin, OUTPUT);
  byte numDigits = 6;
  byte digitPins[] = {9, 10, 11, 12, 13, A2};
  byte segmentPins[] = {2, 3, 4, 5, 6, 7, 8};
  bool resistorsOnSegments = false; // false = resistors are on digit pins
  bool updateWithDelaysIn = true;
  byte hardwareConfig = COMMON_ANODE;
  Display.begin(hardwareConfig, numDigits, digitPins, segmentPins, resistorsOnSegments);
  Display.setBrightness(60);
  pinMode(hrs_set, INPUT_PULLUP);
  pinMode(min_set, INPUT_PULLUP);
}

void loop()
{
  unsigned long timeDisplay;
  int ledState;
  int Hour;
  tmElements_t tm;

  if (RTC.read(tm))
  {
    Hour = tm.Hour;
    if (tm.Hour >= 12)
    {
      Hour -= 12;
      ledState = HIGH;
      /*
        if (tm.Hour == 13) Hour = 1;
        if (tm.Hour == 14) Hour = 2;
        if (tm.Hour == 15) Hour = 3;
        if (tm.Hour == 16) Hour = 4;
        if (tm.Hour == 17) Hour = 5;
        if (tm.Hour == 18) Hour = 6;
        if (tm.Hour == 19) Hour = 7;
        if (tm.Hour == 20) Hour = 8;
        if (tm.Hour == 21) Hour = 9;
        if (tm.Hour == 22) Hour = 10;
        if (tm.Hour == 23) Hour = 11;
        ledState = HIGH; // PM
      */
    }
    else
    {
      if (tm.Hour == 0) Hour = 12;
      ledState = LOW; // AM
    }
    digitalWrite(ledPin, ledState);
    timeDisplay = (Hour * 100 + tm.Minute) * 100L + tm.Second;
  }
  else
  {
    timeDisplay = 888888; // error
  }
  Display.setNumber(timeDisplay);
  Display.refreshDisplay();

  int hourButtonState = digitalRead(hrs_set);
  if (hourButtonState != prevHourButtonState)
  {
    if ( hourButtonState == LOW )
    {
      // button pressed

      tm.Hour += 1;
      if (tm.Hour > 23) tm.Hour = 0;
      RTC.write(tm);
      delay(50);
    }
  }
  prevHourButtonState = hourButtonState;

  int minButtonState = digitalRead(min_set);
  if (minButtonState != prevMinButtonState)
  {
    if ( minButtonState == LOW )
    {
      // button pressed

      tm.Minute += 1;
      if (tm.Minute >= 60) tm.Minute = 0;
      tm.Second = 0;
      RTC.write(tm);
      delay(50);
    }
  }
  prevMinButtonState = minButtonState;
}

I am using a DS3231 RTC even though the modified sketch used a DS1307. I found that if the DS3231 is preset with the current time before connecting it to the circuit, it will work with the DS1307 library.

As for the links to the sites where the sketches and schematics came from here they are

https://www.antimath.info/electro/arduino-uno-6-digit-clock/#comment-315811

The schematic I used for the final circuit combined elements from both schematics.

I want to thank everyone who responded to my post, and to let you know that I have received a working sketch from poster ‘vlc0617’ that only took them one try to nail it. I am now closing this
thread (hope that is the right term) so no more submissions are required. Best wishes and thanks again.

Tried the sketch with my clock setup, but the PM LED doesn’t light when cycling through 12 hours with the hour set button. I have received a sketch from poster ‘vlc0617’ that has everything working. I appreciate the effort, but it isn’t necessary to spend any more time on the sketch. Thank you.