Digital and binary clock from Project Hub

I'm building the digital and binary clock from the project hub. I have the circuit wired according to the fritzing schematic provided. I first verified the code before uploading it to Arduino Uno. I get an error message saying 'setSyncProvider was not declared in this scope'. I searched the forums and Googled a solution to no avail. One solution suggests moving DS1307RTC, Time and Time Alarms to the library folder after downloading from the site library. I also opened library manager and made sure all relevant libraries were installed by doing a search for timing in the library manager as was suggested in the replies. They should have been recognized after closing the IDE and re-opening it but they weren't. I'm using the Max7219 seven segment display with the DS1307RTC module. What I'm not understanding is what it means when it say not declared in this scope. I've include a screenshot of the IDE with the sketch loaded. If I've left anything out please don't hesitate to say so. Thanks in advance.

So I finally got the sketch to recognize DS1307RTC and it is included as DS1307.h. Now I still have 'RTC.get in the setSyncProvider and it is still not declared in this scope. can I fix this. I need a clock. Dollar store clocks are fubar.

I found out how to copy the error messages. Here's the one I'm trying to fix. Thanks

Digital-Binary clock.txt (10.6 KB)

You haven't shown the full sketch, but it appears that you didn't include the Time library header file in y0our sketch.
Because of this, the IDE isn't building the Time library and the sketch will fail to compile with the error you are seeing since setSyncProvider() is in the Time library and the prototype for that function is in the Time library header so the sketch won't know about it when the header file is not included.

You need to include <Time.h>
or if you happen to be using windows <TimeLib.h>

--- bill

I tried TimeLib.h and it returned the same error message, see screenshot attached. I then tried Time.h and it returned a problem compiling for Arduino, also a screenshot for that. I attached both the error message and the .ino file I renamed If and When. Thanks for responding. I think getting the hang of it.

If_And_When.ino (4.79 KB)

Error message If and When.txt (10.3 KB)

Details really matter when it comes to programming.

You included time.h not Time.h
time.h is NOT the same as Time.h
time.h is an AVR libC system header file for unix compatible functions while Time.h is a header file for the Arduino Time library.
However, Windows does not honor case in filenames.
Windows will treat Time.h as the same as time.h same even though they are NOT the same file.
You appear to be using Windows since I see the drive letter stuff.
So given you are using Windows you can't just fix the wrong filename to be Time.h instead of time.h
(That would work on linux and MAC)

Because of Windows, you must use TimeLib.h
It is an additional header file provided in the Time library to work-around/accommodate this Windows issue.

You did not post the full error message output from the compile when you used TimeLib.h
so we have no idea what happened there. A screen shot of the IDE just showing the last line of the error messages is not helpful.

When using TimeLib.h the error messages will definitely not be the same set of errors as before nor will it be the same as when using time.h

It is usually pretty obvious what the issue is, but you have to look at the very first error message not the last message of the output.

-- bill


Please read the first post in any forum entitled how to use this forum.,148850.0.html then look down to item #7 about how to post your code.
It will be formatted in a scrolling window that makes it easier to read.

Thanks.. Tom.. :slight_smile:

#include <LedControl.h>                 // Library for LED Display - MAX72XX
#include <Wire.h>                       // Library for DS1307RTC - Pins of Arduino UNO: A4 (SDA), A5 (SCL)
#include <DS1307.h>                     // Library for Real Time Clock
#include <TimeLib.h>

#define DS1307_I2C_ADDRESS 0x68         // This is the I2C address (RTC)

// Global Variables
byte hora, minuto, segundo, diaSemana;
byte timeMode, pmStatus;
byte unidadeHora, unidadeMinuto, dezenaHora, dezenaMinuto;

  Pin numbers do Arduino para conexao com o MAX72XX (matriz de LED com controlador MAX72XX)
  pin 2 is connected to the DataIn (DIN)
  pin 3 is connected to LOAD (CS)
  pin 4 is connected to the CLK (CLK)

LedControl lc = LedControl(2, 4, 3, 1);   // LedControl(int dataPin, int clkPin, int csPin, int numDevices)

// Display 7-Segments Standard:
//      A
//     ----
//  F |    | B
//     - G-
//  E |    | C
//     ----
//      D

// Display Segments for MAX72XX:
//      64
//     ----
//  2 |    | 32
//     - 1-
//  4 |    | 16
//     ---- . 128
//      8

void setup() {


  // Read datum of Time Mode (24hs or AM-PM)stored in RTC
  Wire.beginTransmission(DS1307_I2C_ADDRESS);               // Open I2C line in write mode
  Wire.write((byte)0x08);                                   // Set the register pointer to (0x08)
  Wire.endTransmission();                                   // End Write Transmission
  Wire.requestFrom(DS1307_I2C_ADDRESS, 1);                  // In this case read only 1 byte

  timeMode =;                                   // Read the Time Mode and Font Type stored at RTC memory

  timeMode = !timeMode;                                     // Change the Time Mode (24hs = 0 / AM-PM = 1) when Arduino is restarted

  // Write data of Clock Mode (Decimal or Binary) in RTC
  Wire.beginTransmission(DS1307_I2C_ADDRESS);               // Open I2C line in write mode
  Wire.write((byte)0x08);                                   // Set the register pointer to (0x08)
  Wire.write(timeMode);                                     // Record at RTC memory the Mode of Time
  Wire.endTransmission();                                   // End Write Transmission

  // Setup of Display "0"
  lc.shutdown(0, false);                                    // Wakeup Display "0"
  lc.setIntensity(0, 4);                                    // Set the Brightness of Display ( 0 to 15)
  lc.clearDisplay(0);                                       // Clear Display "0"

  if (timeMode == 0) {                                      // Char "24HS"
    lc.setChar(0, 7, '2', false);
    lc.setChar(0, 6, '4', false);
    lc.setChar(0, 5, 'H', false);
    lc.setDigit(0, 4, 5, false);

  if (timeMode == 1) {                                      // Char "A-P"
    lc.setChar(0, 7, 'A', false);
    lc.setChar(0, 6, '-', false);
    lc.setChar(0, 5, 'P', false);


  setSyncProvider(RTC.get);                                 // Function to read RTC (Real Time Clock)
  //setSyncInterval(18000);                                   // Set the number of seconds between re-sync
  //setTime(16, 56, 0, 14, 01, 2018);                         // Set the Time and Date


void loop() {

  // Plot Time

  hora = hour();
  minuto = minute();
  segundo = second();

  diaSemana = weekday();

  if (diaSemana == 0) {
    diaSemana = 7;

  if (timeMode == 1) {

    if (hora > 11) {                  // Set PM status
      pmStatus = 1;

    hora = hora % 12;
    if (hora == 0) {
      hora = 12;

  // Digital Plot - Time

  unidadeHora = hora % 10;
  dezenaHora = hora / 10;
  unidadeMinuto = minuto % 10;
  dezenaMinuto = minuto / 10;

  lc.setDigit(0, 7, dezenaHora, false);     // setDigit(int addr, int digit, byte value, boolean dp)
  lc.setDigit(0, 6, unidadeHora, true);
  lc.setDigit(0, 5, dezenaMinuto, false);
  lc.setDigit(0, 4, unidadeMinuto, false);

  if (pmStatus == 1) {
    lc.setDigit(0, 4, unidadeMinuto, true);

  // Binary Plot - Time

  if (pmStatus == 1) {
    lc.setRow(0, 3, plotBin(hora) + 1);     // Set PM indicator blinking
  } else {
    lc.setRow(0, 3, plotBin(hora));         // Set dot seconds blinking

  lc.setRow(0, 2, plotBin(minuto));
  lc.setRow(0, 1, plotBin(segundo));
  lc.setRow(0, 0, 128 >> diaSemana);

  // Blinking Seconds
  lc.setDigit(0, 6, unidadeHora, false);
  lc.setRow(0, 3, plotBin(hora));


// Binary Conversion to 7-Segments

byte plotBin(byte bin) {

  bin = bin << 1;

  byte res = 0;

  for (byte k = 0; k <= 6; k++) {
    res = bitWrite(res, (6 - k), bitRead(bin, k));

  if (bin == 0) {
    res = 64;

  return res ;


Why did you create a new thread? This information is useless in its own thread. I have requested the moderators to merge it.

I posted a new thread because I didn't see a way to post the code in the reply. Apologies for that.