Been struggling with this for a few days and I suspect that i have several issues but I cannot find them.

Project: Need a serial count that counts by 5-50 and a button interrupt should trigger a display of the current time and then continue counting.

Issue: Cannot complete compiling because my "void rtcTime()" is saying I am redeclared as different kind of symbol.

Any help the community can provide is greatly appreciated.


// Date and time functions using a DS1307 RTC connected via I2C and Wire lib
#include "RTClib.h"
#include <Wire.h>

RTC_DS1307 rtc;

int count = 5;
int rtcTime = 0;
int pin = 0;

char daysOfTheWeek[7][12] = {"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"};

void setup (){

  pinMode(2, INPUT);


  while (!Serial); // for Leonardo/Micro/Zero


  if (! rtc.begin()) {
   Serial.println("Couldn't find RTC");
   while (1);

  if (! rtc.isrunning()) {
    Serial.println("RTC is NOT running!");
    // following line sets the RTC to the date & time this sketch was compiled
    // rtc.adjust(DateTime(F(__DATE__), F(__TIME__)));
    // This line sets the RTC with an explicit date & time, for example to set
    // January 21, 2014 at 3am you would call:
    // rtc.adjust(DateTime(2014, 1, 21, 3, 0, 0));

     attachInterrupt(pin, rtcTime, RISING);

void loop()
  // Count X5 on Serial Monitor

  if (count > 50)

   else if (count<50)

void rtcTime() {
    DateTime now = rtc.now();

    Serial.print(now.year(), DEC);
    Serial.print(now.month(), DEC);
    Serial.print(now.day(), DEC);
    Serial.print(" (");
    Serial.print(") ");
    Serial.print(now.hour(), DEC);
    Serial.print(now.minute(), DEC);
    Serial.print(now.second(), DEC);


Error Message:

Arduino: 1.8.10 (Mac OS X), Board: "Arduino/Genuino Mega or Mega 2560, ATmega2560 (Mega 2560)"

ds1307_workingCopy_Mod5:60:14: error: 'void rtcTime()' redeclared as different kind of symbol void rtcTime() { ^ /Users/kiko/Documents/Arduino/ds1307_workingCopy_Mod5/ds1307_workingCopy_Mod5.ino:9:5: note: previous declaration 'int rtcTime' int rtcTime = 0; ^~~~~~~ /Users/kiko/Documents/Arduino/ds1307_workingCopy_Mod5/ds1307_workingCopy_Mod5.ino: In function 'void setup()': /Users/kiko/Documents/Arduino/ds1307_workingCopy_Mod5/ds1307_workingCopy_Mod5.ino:38:42: warning: invalid conversion from 'int' to 'void ()()' [-fpermissive] attachInterrupt(pin, rtcTime, RISING); ^ In file included from sketch/ds1307_workingCopy_Mod5.ino.cpp:1:0: /Users/kiko/Desktop/Arduino.app/Contents/Java/hardware/arduino/avr/cores/arduino/Arduino.h:150:6: note: initializing argument 2 of 'void attachInterrupt(uint8_t, void ()(), int)' void attachInterrupt(uint8_t, void (*)(void), int mode); ^~~~~~~~~~~~~~~ /Users/kiko/Documents/Arduino/ds1307_workingCopy_Mod5/ds1307_workingCopy_Mod5.ino: In function 'void rtcTime()': ds1307_workingCopy_Mod5:60:14: error: 'void rtcTime()' redeclared as different kind of symbol void rtcTime() { ^ /Users/kiko/Documents/Arduino/ds1307_workingCopy_Mod5/ds1307_workingCopy_Mod5.ino:9:5: note: previous declaration 'int rtcTime' int rtcTime = 0; ^~~~~~~ Multiple libraries were found for "RTClib.h" Used: /Users/kiko/Documents/Arduino/libraries/RTClib-1.3.3 Not used: /Users/kiko/Documents/Arduino/libraries/RTCLib_by_NeiroN Multiple libraries were found for "Wire.h" Used: /Users/kiko/Desktop/Arduino.app/Contents/Java/hardware/arduino/avr/libraries/Wire exit status 1 'void rtcTime()' redeclared as different kind of symbol

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

  • It's not a good idea to use rtcTime for everything....
    – KIIV
    Mar 15 '20 at 18:42
  • 1
    You gave the same name rtcTime to a variable and a function. Cannot work
    – chrisl
    Mar 15 '20 at 19:05
  • 2
    I'm voting to close this question as off-topic because it's a pure programming problem, a very simple syntax error, not related to Arduino
    – chrisl
    Mar 15 '20 at 19:06
  • KIIV, I have no emotional attachment to "rtcTime", just changed it to "buttonPressed" and changed it also in the declaration at the beginning to "volatile int buttonPressed=0". No change into the results, still error "void buttonPressed() redeclared as different kind of symbol", thanks for the input though, I did feel it to be better to stay away from words that may be commands. Mar 15 '20 at 19:07
  • 1
    @pancho22448 It kinda won't help, if you change both variable and function named rtcTime to buttonPressed... It's still variable and function with the same name buttonPressed after that change. Small hint: Change ONE OF THEM!
    – KIIV
    Mar 15 '20 at 20:05

The Arduino builder doesn't create forward declarations of functions for functions used in code as callbacks. It has something to do with the occurrence of the name without the usual form of function call.

You could move the function rtcTime before setup() so it is visible for the use as parameter in attachInterrupt or you can create a forward declaration for the compiler. Your attempt to make the name of the function valid was to create a variable with this name. This way you created the error of duplicate name.


void rtcTime();

before setup() function and remove int rtcTime = 0;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.