7 segment clock

Morning all, 6v6gt, I have looked at the D3231 files and there is not a sub directory hardware\avr. There are 4 sub directories: License, D3231 (CPP file), D3231 (H file), keywords (Text file). I have looked into both of the D3231 files and the CPP file contains the code line #include "hardware/avr/HW_AVR.h", and the H file contains the code line #include "hardware/avr/HW_AVR_defines.h". Both are Rinky Dink libraries. Hope that helps.

jremington, I have checked the tools\boards\board manager and the Uno is the board selected.

Thanks to all.

Thinking about this RTC, I have used it in the past to display to the serial monitor and looking back at that sketch there does not seem to be a line to include the D3231, instead it seems to have been included with the lines:
#include "Wire.h"
#define DS3232_I2C_ADDRESS 0x68
Does this give anyone a clue or am I just muddying the waters?
Thanks.

Malc92:
Morning all, 6v6gt, I have looked at the D3231 files and there is not a sub directory hardware\avr. There are 4 sub directories: License, D3231 (CPP file), D3231 (H file), keywords (Text file). I have looked into both of the D3231 files and the CPP file contains the code line #include "hardware/avr/HW_AVR.h", and the H file contains the code line #include "hardware/avr/HW_AVR_defines.h". Both are Rinky Dink libraries. Hope that helps.

jremington, I have checked the tools\boards\board manager and the Uno is the board selected.

Thanks to all.

I simply downloaded the zip file from the tutorial you suggested and opened it up and saw the contents, including say hardware/avr/HW_AVR_defines.h. If these do not appear in your libraries directory, then the question is how did you install that library from the zip file ? Or did you use some other method ?
Maybe clean out the DS3231 path from the libraries directory and repeat the installation of that library.

Unfortunately for you, and many users, there is a huge proliferation of "libraries" for DS3231 device, with various states of usability, documentation etc. often with conflicting parameters. If you follow some of the tutorials, you are dragged into this world of half tested, unprofessionally thrown together bits of software.
Even the Arduino Library Manager presents the user with a confusing variety of "DS3231" libraries.

The only alternative to tolerating this mess it, sadly, to pay the price for a professional development system.

Malc92:
Thinking about this RTC, I have used it in the past to display to the serial monitor and looking back at that sketch there does not seem to be a line to include the D3231, instead it seems to have been included with the lines:
#include "Wire.h"
#define DS3232_I2C_ADDRESS 0x68
Does this give anyone a clue or am I just muddying the waters?
Thanks.

That more than likely indicates that the programmer used low level code directly accessing the registers in the DS3231.

If you can find that code back, you can use it as a base for your project and merge it with some display code.

sterretge, that's what I was doing originally, I planned to use that part of the previous sketch to include the D3231 then add the SevSeg library and code in place of the LCD library and code Unfortunately my coding skills (or lack of) are so poor that I got into a complete mess and decided to return to the web page sketch - the rest you know! Thanks.

An update fellas! I went back to the website sketch, downloaded and installed the D3231 library again and tried to compile the sketch. This time it did not complain about the D3231 but threw up an error about the SevSeg. So I downloaded and installed another SevSeg library. Lo and behold the sketch compiled OK! Having reached that stage I will now build the circuit up on the breadboard and see what happens. So you are all safe for a while but don't go away, I may well be back! Many thanks to all of you for your help and interest.
Malc.

Just to finish this saga, the sketch is now working OK. It keeps good time and the RTC battery back up saves the time when the power is off. The decimal points do not function but I didn't want them anyway so I never persued that problem. The only other failure was the Hour setting button did not work, after comparing it's section of code to the section on the minutes setting code I found a slight difference between the two. I altered the line of code and that cured the problem. My coding ability is poor but with 2 sections of code performing a similar function I was able to compare them and make an educated guess . In other words, I don't know what I did, but it worked. I am including the code here with a comment against the line I altered in case it is of use to someone. Once again, thanks to all who helped for your time and interest.

//mods to sketch nov06b. Clock with RTC displaying to 4x7 segment display (COM-11405). (Decimal points do not work.)

#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;
unsigned long startMillis;
const long interval = 500;
unsigned long currentMillis;
unsigned long previousMillis = 0;
unsigned int Hour = 0;
unsigned int hrs_var = 0;
unsigned int min_var = 0;
int ledState = LOW;

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, 9};
  bool resistorsOnSegments = false;
  bool updateWithDelays = false;
  byte hardwareConfig = COMMON_CATHODE;
  bool leadingZeros = true;
  bool disableDecPoint = true;
  Display.begin(hardwareConfig, numDigits, digitPins, segmentPins, resistorsOnSegments, updateWithDelays, leadingZeros, disableDecPoint);
  Display.setBrightness(100);
}

void loop()
{
  unsigned long currentMillis = millis();
  if (currentMillis - previousMillis >= interval)
  {
    previousMillis = currentMillis;
    if (ledState == LOW)
    {
      ledState = HIGH;
    }
    else
    {
      ledState = LOW;
    }
    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) == LOW)
  {
    hrs_var += 1;
    if (hrs_var > 23) hrs_var = 0;  //this line changed, was previously:   if (hrs_var > 23) hrs_var == 0;   preventing the hrs set buton from working.
    rtc.setTime(hrs_var, min_var, 0);
    for (int i = 0; i < 1000; i ++)
    {
      Display.setNumber(number);
      Display.refreshDisplay();
    }
  }
  if (digitalRead(min_set) == LOW)
  {
    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();
    }
  }
}