7 sement clock help

Hello all, I have been trying to figure this out for a week and man I am lost. I am making a large 7 segment clock and I keep getting compile errors

C:\Users\schin\Downloads\7 Segment Clock files\Clock\Clock\Code\Clock\Clock.ino: In function 'int GetTime()':
C:\Users\schin\Downloads\7 Segment Clock files\Clock\Clock\Code\Clock\Clock.ino:75:3: error: 'RTC' was not declared in this scope
RTC DS3232 .read(Now);
^~~
C:\Users\schin\Downloads\7 Segment Clock files\Clock\Clock\Code\Clock\Clock.ino: In function 'void TempToArray()':
C:\Users\schin\Downloads\7 Segment Clock files\Clock\Clock\Code\Clock\Clock.ino:168:3: error: 'RTC' was not declared in this scope
RTC.read(tm);
^~~
C:\Users\schin\Downloads\7 Segment Clock files\Clock\Clock\Code\Clock\Clock.ino: In function 'void TimeAdjust()':
C:\Users\schin\Downloads\7 Segment Clock files\Clock\Clock\Code\Clock\Clock.ino:262:5: error: 'RTC' was not declared in this scope
RTC.read(Now);
^~~
Multiple libraries were found for "DS3232RTC.h"
Used: C:\Users\schin\OneDrive\Documents\Arduino\libraries\DS3232RTC
Not used: C:\Users\schin\OneDrive\Documents\Arduino\libraries\RtcDS3231
exit status 1

Compilation error: 'RTC' was not declared in this scope

#include <DS3232RTC.h>
#include <TimeLib.h>
#include <Time.h>
#include <Wire.h>
#include <FastLED.h>


#define NUM_LEDS 114 // 4*7*4 +2  Number of LED controlled
#define COLOR_ORDER GRB  // Define color order for your strip
#define LED_PIN 6 // Data pin for led comunication
#define DST_PIN 5  // Define DST adjust button pin
#define MIN_PIN 4  // Define Minutes adjust button pin
#define HUR_PIN 3  // Define Hours adjust button pin

CRGB leds[NUM_LEDS]; // Define LEDs strip
                    // 0,0,0,0
                    // 1,1,1,1
                    //  1 2 3 4 5 6 7 8 9 10111213141516171819202122232425262728
byte digits[12][28] = {{0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1},  // Digit 0
                       {0,0,0,0,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1},   // Digit 1
                       {1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,1,1,1,1,1,1,1,1,0,0,0,0},   // Digit 2
                       {1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1},   // Digit 3
                       {1,1,1,1,1,1,1,1,0,0,0,0,1,1,1,1,0,0,0,0,0,0,0,0,1,1,1,1},   // Digit 4
                       {1,1,1,1,0,0,0,0,1,1,1,1,1,1,1,1,0,0,0,0,1,1,1,1,1,1,1,1},   // Digit 5
                       {1,1,1,1,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1},   // Digit 6
                       {0,0,0,0,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1},   // Digit 7
                       {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1},   // Digit 8
                       {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,1,1,1,1,1,1,1,1},   // Digit 9 | 2D Array for numbers on 7 segment
                       {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0},   // Digit *0
                       {0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0}};  // Digit C
                       
bool Dot = true;  //Dot state
bool DST = false; //DST state
bool TempShow = true;
int last_digit = 0;

// int ledColor = 0x0000FF; // Color used (in hex)
long ledColor = CRGB::DarkOrchid; // Color used (in hex)
//long ledColor = CRGB::MediumVioletRed;
//Random colors i picked up
long ColorTable[16] = {
  CRGB::Amethyst,
  CRGB::Aqua,
  CRGB::Blue,
  CRGB::Chartreuse,
  CRGB::DarkGreen,
  CRGB::DarkMagenta,
  CRGB::DarkOrange,
  CRGB::DeepPink,
  CRGB::Fuchsia,
  CRGB::Gold,
  CRGB::GreenYellow,
  CRGB::LightCoral,
  CRGB::Tomato,
  CRGB::Salmon,
  CRGB::Red,
  CRGB::Orchid
};


void setup(){ 
  Serial.begin(9600); 
  Wire.begin();
  FastLED.addLeds<WS2812B, LED_PIN, RGB>(leds, NUM_LEDS);
  LEDS.setBrightness(75); // Set initial brightness
  pinMode(DST_PIN, INPUT_PULLUP); // Define DST adjust button pin
  pinMode(MIN_PIN, INPUT_PULLUP); // Define Minutes adjust button pin
  pinMode(HUR_PIN, INPUT_PULLUP); // Define Hours adjust button pin
   
} 

// Get time in a single number, if hours will be a single digit then time will be displayed 155 instead of 0155
int GetTime(){
  tmElements_t Now;
  RTC.read(Now);
  //time_t Now = RTC.Now();// Getting the current Time and storing it into a DateTime object 
  int hour=Now.Hour;
  int minute=Now.Minute;
  int second =Now.Second;
  if (second % 2==0) {Dot = false;}
    else {Dot = true;};
  return (hour*100+minute);
  };

  
// Convert time to array needet for display 
void TimeToArray(){
  int Now = GetTime();  // Get time
  
  int cursor = 114; // last led number
  
  // Serial.print("Time is: ");Serial.println(Now);
  if (DST){   // if DST is true then add one hour
   Now+=100;
  // Serial.print("DST is ON, time set to : ");Serial.println(Now);
  }; 
  if (Dot){leds[57]=ledColor;
           leds[56]=ledColor;}   
    else  {leds[57]=0x000000;
           leds[56]=0x000000;
    };
    
  for(int i=1;i<=4;i++){
    int digit = Now % 10; // get last digit in time
    if (i==1){
    //  Serial.print("Digit 4 is : ");Serial.print(digit);Serial.print(" ");

      cursor = 86;
      
      for(int k=0; k<=27;k++){ 
        // Serial.print(digits[digit][k]);
        if (digits[digit][k]== 1){leds[cursor]=ledColor;}
         else if (digits[digit][k]==0){leds[cursor]=0x000000;};
         cursor ++;
        };
      // Serial.println();

      if (digit != last_digit)
      {
        cylon();
        ledColor =  ColorTable[random(16)];
      }
      last_digit = digit;
      
      }
    else if (i==2){
      // Serial.print("Digit 3 is : ");Serial.print(digit);Serial.print(" ");

      cursor =58;
      
      for(int k=0; k<=27;k++){ 
        // Serial.print(digits[digit][k]);
        if (digits[digit][k]== 1){leds[cursor]=ledColor;}
         else if (digits[digit][k]==0){leds[cursor]=0x000000;};
         cursor ++;
        };
      // Serial.println();
      }
    else if (i==3){
      // Serial.print("Digit 2 is : ");Serial.print(digit);Serial.print(" ");
      cursor =28;
      for(int k=0; k<=27;k++){ 
        // Serial.print(digits[digit][k]);
        if (digits[digit][k]== 1){leds[cursor]=ledColor;}
         else if (digits[digit][k]==0){leds[cursor]=0x000000;};
         cursor ++;
        };
      // Serial.println();
      }
    else if (i==4){
      // Serial.print("Digit 1 is : ");Serial.print(digit);Serial.print(" ");
      cursor =0;
      for(int k=0; k<=27;k++){ 
        // Serial.print(digits[digit][k]);
        if (digits[digit][k]== 1){leds[cursor]=ledColor;}
         else if (digits[digit][k]==0){leds[cursor]=0x000000;};
         cursor ++;
        };
      // Serial.println();
      }
    Now /= 10;
  }; 
};

// Convert temp to array needet for display 
void TempToArray(){
  tmElements_t tm;
  RTC.read(tm);

  if (tm.Second != 27) {
    TempShow = false;
    return;
  }
  TempShow = true;
  int t = RTC.temperature();
  int celsius = (t / 4.0) * 100;

  Serial.print("Temp is: ");Serial.println(celsius);
  
  int cursor = 114; // last led number
    
    leds[57]=0x000000;
    leds[56]=0x000000;
      
  for(int i=1;i<=4;i++){
    int digit = celsius % 10; // get last digit in time
    if (i==1){
      Serial.print("Digit 4 is : ");Serial.print(digit);Serial.print(" ");

      cursor = 86;
      
      for(int k=0; k<=27;k++){ 
        Serial.print(digits[11][k]);
        if (digits[11][k]== 1){leds[cursor]=ledColor;}
         else if (digits[11][k]==0){leds[cursor]=0x000000;};
         cursor ++;
        };
      Serial.println();
    }
    else if (i==2){
      Serial.print("Digit 3 is : ");Serial.print(digit);Serial.print(" ");

      cursor =58;
      
      for(int k=0; k<=27;k++){ 
        Serial.print(digits[10][k]);
        if (digits[10][k]== 1){leds[cursor]=ledColor;}
         else if (digits[10][k]==0){leds[cursor]=0x000000;};
         cursor ++;
        };
      Serial.println();
      }
    else if (i==3){
      Serial.print("Digit 2 is : ");Serial.print(digit);Serial.print(" ");
      cursor =28;
      for(int k=0; k<=27;k++){ 
        Serial.print(digits[digit][k]);
        if (digits[digit][k]== 1){leds[cursor]=ledColor;}
         else if (digits[digit][k]==0){leds[cursor]=0x000000;};
         cursor ++;
        };
      Serial.println();
      }
    else if (i==4){
      Serial.print("Digit 1 is : ");Serial.print(digit);Serial.print(" ");
      cursor =0;
      for(int k=0; k<=27;k++){ 
        Serial.print(digits[digit][k]);
        if (digits[digit][k]== 1){leds[cursor]=ledColor;}
         else if (digits[digit][k]==0){leds[cursor]=0x000000;};
         cursor ++;
        };
      Serial.println();
      }
    celsius /= 10;
  }; 
};


void DSTcheck(){
   int buttonDST = digitalRead(2);
   // Serial.print("DST is: ");Serial.println(DST);
   if (buttonDST == LOW){
    if (DST){
      DST=false;
      // Serial.print("Switching DST to: ");Serial.println(DST);
      }
      else if (!DST){
        DST=true;
        // Serial.print("Switching DST to: ");Serial.println(DST);
      };
   delay(500);   
   };
  }

void TimeAdjust(){
  int buttonH = digitalRead(HUR_PIN);
  int buttonM = digitalRead(MIN_PIN);
  if (buttonH == LOW || buttonM == LOW){
    delay(500);
    tmElements_t Now;
    RTC.read(Now);
    int hour=Now.Hour;
    int minutes=Now.Minute;
    int second =Now.Second;
      if (buttonH == LOW){
        if (Now.Hour== 23){Now.Hour=0;}
          else {Now.Hour += 1;};
        }else {
          if (Now.Minute== 59){Now.Minute=0;}
          else {Now.Minute += 1;};
          };
    RTC.write(Now); 
    }
  }

/* coool effect function*/
void fadeall() { for(int i = 0; i < NUM_LEDS; i++) { leds[i].nscale8(250); } }


void cylon () {
  static uint8_t hue = 0;
  Serial.print("x");
  // First slide the led in one direction
  for(int i = 0; i < NUM_LEDS; i++) {
    // Set the i'th led to red 
    leds[i] = CHSV(hue++, 255, 255);
    // Show the leds
    FastLED.show(); 
    // now that we've shown the leds, reset the i'th led to black
    // leds[i] = CRGB::Black;
    fadeall();
    // Wait a little bit before we loop around and do it again
    delay(10);
  }
  Serial.print("x");

  // Now go in the other direction.  
  for(int i = (NUM_LEDS)-1; i >= 0; i--) {
    // Set the i'th led to red 
    leds[i] = CHSV(hue++, 255, 255);
    // Show the leds
    FastLED.show();
    // now that we've shown the leds, reset the i'th led to black
    // leds[i] = CRGB::Black;
    fadeall();
    // Wait a little bit before we loop around and do it again
    delay(10);
  }
}
  
void loop()  // Main loop
{ 
  DSTcheck(); // Check DST
  TimeAdjust(); // Check to se if time is geting modified
  TimeToArray(); // Get leds array with required configuration
  TempToArray();
  FastLED.show(); // Display leds array
  if (TempShow == true) delay (8000);
}

I am VERY new to Arduino but have used IDE before for SimHub. I tried to read through forum posts and dont see what is going on/understand, mostly understand. I know this is prob a mess and could not figure out how to tag it properly. I am sorry for that. I know you most likely hate seeing posts like this, again sorry. Any help would be greatly appreciated

If you look at the error message, this is saying that the compiler encountered a reference to 'RTC' in the function 'int GetTime()'.

If you look at the function, sure enough there is is:

Although the library has been correctly included at the top of the sketch, the compiler doesn't know what the reference to 'RTC' it is, because it hasn't been declared anywhere yet. You need to declare the DS3232 object before setup():

DS3232RTC RTC;

Now that we have an 'RTC' object, it then needs to be initialised, which can be done in void setup() with:

RTC.begin();

Now the RTC object has been set up, the compiler will know what to do when it encounters calls to its methods such as RTC.read() when it encounters them*

Error messages can be a helpful guide to pinpointing the problem and it is worthwhile to take time to understand and interpret them. Of course that also comes with time and experience.

Also, have a look at the provided RTC examples within the Arduino IDE via
File -> Examples -> DS3231RTC ->
From this example it can be seen that this DS3232RTC library has a method called .get() rather than .read(). You may need to use the DS3232 library by Rob Tilaart. If you are following online examples, then it is important to ascertain exactly which library has been used and then use exactly the same library by the same author and with the same version. Often there is more than one library available and the names tend to be similar. Confusion can be avoided by following the examples installed with the library within the IDE.

1 Like

It seems that this function you want to use does not exist in the library: DS3232RTC.h,
Ibut it does exist in the library: DS1307RTC.h.
IBut the function: RTC.temperature(); does not exist in the library DS1307RTC.h.

See simulation at:

Some DS3231/DS1307 libraries, of which there are a huge number, already instantiate an object RTC so it could simply be that the OP has chosen a library other than the one intended by the creator of all that code.

The normal development path is that individual elements, in this case the interface to the RTC module, are tested in isolation before being incorporated into a huge application, so problems like this show up much earlier.

1 Like

You might start with the example in the library package and get it working first. Use print statements to display the data on the monitor, When that is correct then add the external hardware, this helps reduce the amount of debugging required and the time.

Man thank you so much EIL5, because really, that is where I am at. I was really struggling and struggling as to whether I was going to post this. I just dont know what I dont know or were to really start half the time. As you have shown me homework without context is nearly useless. Thank you again for your time in answering me.

Thank you so much, bookmarked. Thank you for taking the time to help me.

Thank you, for taking the time to help. It is appreciated.

I know this sounds incredibly ignorant but I had no idea I had no idea what that was for. Thanks for helping me, it is appreciated.