7 segment clock

Morning all, I am trying to make a simple clock with an RTC which displays hrs & mins to a large 7 segment display. I have found this sketch online which seemed to fit the bill, however it does not compile, throwing up the error message "no matching function for call to 'DS3231::DS3231(const uint8_t&, const uint8_t&)' and highlighting the third line. I have tried all sorts to get the sketch to compile but my coding skills are sadly not up to the job. I am using an Arduino Uno and I believe the RTC is I2C enabled. Can anyone point me in the right direction? I have attempted to attach the sketch file code (nov06b) but it is sometime since I posted on here so I am hoping it has gone OK.

I have found this sketch online

No link, no code, no help

The attaching failed, you could have seen that yourself :wink:

If the sketch is less than 9000 characters, post it here betwern [code] and [/code].

Please post the full error message (there is a copy button when an error occurs).

Did you install the correct library; it should be mentioned on the web page where you found the sketch.

@Malc92

Your topic was Moved to it's current location / section as it is more suitable.

Could you also take a few moments to Learn How To Use The Forum.

Other general help and troubleshooting advice can be found here.
It will help you get the best out of the forum in the future.

ballscrewbob, sorry about posting in the wrong area, thanks for moving it. Sterretje, I will attempt to post the code again. The full error message is: **"no matching function for call to 'DS3231::DS3231(const uint8_t&, const uint8_t&) . ** I think I did install the correct web page library, but I will double check. Thanks.

#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 = 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;
    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();
    }
  }
}

Probably, you installed the wrong RTC library.

I have just installed the library from the web page and entered it in the sketch. The sketch still does not compile, but the error message has now changed to:
Arduino: 1.8.13 (Windows 10), Board: "Arduino Uno"

In file included from D:\Arduino\My sketches\sketch_nov06b\sketch_nov06b.ino:2:0:

D:\Arduino\libraries\DS3231/DS3231.h:27:11: fatal error: hardware/avr/HW_AVR_defines.h: No such file or directory

#include "hardware/avr/HW_AVR_defines.h"

^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

compilation terminated.

exit status 1

Error compiling for board Arduino Uno.

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.

Please post your revised code.

This is the latest sketch failing to compile, Thanks.

#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;
    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();
    }
  }
}

Please post a link to the web page where you found the source code.

To be honest, I've never heard of HW_AVR_defines.h, but that might be me. Nit behind a PC to check

Please post the entire error message.

sterretje, here is a link to the web page:

aarg, that is the entire message as displayed when pasting the "Copy error messages" option.

By the way, I am not fixated on that particular circuit / sketch, if either of you know of another clock sketch using a 4 x 7segment display and a D3231 RTC I would be willing to try it. I only want a simple Hrs & Mins display. The object of the exercise is to use the larger 4 x 7 segment display I already have. Thanks

#include "hardware/avr/HW_AVR_defines.h"

Looks to be part of the Teensy

Sounds like you have selected the wrong Arduino board.

The board used in the web page project is a Uno, mine is also a Uno (R3) so I am assuming it is suitable ??

Malc92:
The object of the exercise is to use the larger 4 x 7 segment display I already have. Thanks

What display is that? It would be useful to know in order to give you targeted advice.

Hi aarg, I bought the display from Proto-pic, No. COM-11405. It is common cathode and has the same pinout as the (smaller) SH5461 display I already had. Thanks.

Can you look here on the PC where the Arduino IDE is installed and look at this path in the file manager:

D:\Arduino\libraries\DS3231

Do you see the following subdirectory: hardware\avr ?
which should contains the files:
HW_AVR.h
HW_AVR_defines.h

These are part of the library the tutorial, which you have used, asked you to install. The library has this author: http://www.RinkyDinkElectronics.com/

If that sub directory is missing, you have probably installed a different library or the library has not been correctly installed.

The library author's home page has this uninspiring notice about their DS3231 library:

Important
The library has not been tested in combination with the Wire library and I have no idea if they can share pins. Do not send me any questions about this. If you experience problems with pin-sharing you can move the DS3231/DS3232 SDA and SCL pins to any available pins on your development board. This library will in this case fall back to a software-based, TWI-/I2C-like protocol which will require exclusive access to the pins used.

Thanks 6v6gt, I will look into that tomorrow. Had a quick look down those files earlier and I don’t think those sub directories were there. However I will check tomorrow. Thanks again.

The board used in the web page project is a Uno, mine is also a Uno (R3) so I am assuming it is suitable ??

Sure, but have you selected the Uno in the Arduino IDE, board selection menu?