cant be used as a function

when using the code below I get a compiler error “totaltime cant be used as a function”

I am trying to set totaltime to the number of mins since midnight by using
totaltime = (hours()*60)+minute());

then compare totaltime to a predefined time (sunrise , 420mins) to do a set feature at 07:00 (420mins since midnight)

if (totaltime >= sunrise)

#include <Time.h>  
#include <Wire.h>  
#include <DS1307RTC.h>  // a basic DS1307 library that returns time as a time_t
#define BETWEEN 2579
#define DURATION 43 
#define TIMES 7
#define whiteled 10
#define blueled 11
#define stormswitch 2
unsigned long lastTime = 0;
int waitTime = 0;
int Val = 0;
int burst; //short burst of light
int big;
int srumble;
int brumble;
int mixer;
int diming;
int delaymix;
int dark;
int lightningtimer;
int lightningtime;

byte sunrise = 420;
byte daytime = 450;
byte sunset = 1260;
byte night = 1350;
byte totaltime = (hour()*60)+ minute(); 

void setup()  {

  pinMode(stormswitch, INPUT);
  digitalWrite(stormswitch, HIGH);
  pinMode(whiteled, OUTPUT);
  pinMode(blueled, OUTPUT);
//  while (!Serial) ; // wait until Arduino Serial Monitor opens
  setSyncProvider(RTC.get);   // the function to get the time from the RTC
  if(timeStatus()!= timeSet) 
     Serial.println("Unable to sync with the RTC");
     Serial.println("RTC has set the system time");      

void loop()
  if (timeStatus() == timeSet) {
  } else {
    Serial.println("The time has not been set.  Please run the Time");
    Serial.println("TimeRTCSet example, or DS1307RTC SetTime example.");

void digitalClockDisplay()
  // digital clock display of the time
  Serial.print(" "); 
  totaltime = (hour()*60) + minute();
  if (digitalRead (stormswitch) == LOW)

void printDigits(int digits)
  // utility function for digital clock display: prints preceding colon and leading 0
  if(digits < 10)

void storm ()
    digitalWrite(blueled, LOW);
    if (millis() - waitTime > lastTime)  // time for a new flash
      // adjust timing params
      lastTime += waitTime;
      waitTime = random(BETWEEN);

      for (int i=0; i< random(TIMES); i++)
        digitalWrite(whiteled, HIGH);
        delay(20 + random(DURATION));
        digitalWrite(whiteled, LOW);

void timer ()
  Serial.println ("timer");
   if (totaltime() >= night())
     Serial.println ("night");
     analogWrite (whiteled, 0);
     analogWrite (blueled, 0);
  else if (summins() >= sunset())
    // fade out from max to min in increments of 5 points:
    Serial.println ("sunset");
    for(int fadeValue = 255 ; fadeValue >= 0; fadeValue -=5) 
      // sets the value (range from 0 to 255):
      analogWrite(whiteled, fadeValue); 
      analogWrite(blueled, fadeValue);         
      // wait for 30 milliseconds to see the dimming effect    
   else if (summins() >= daytime)
      Serial.println ("Daytime");
      analogWrite(whiteled, 255);
      analogWrite(blueled, 255);
  else if (summins() >= sunrise)
     //30 Min sunrise
     Serial.println ("sunrise");
     for(int fadeValue = 0; fadeValue < 191; fadeValue +=1)
      analogWrite(whiteled, fadeValue);
      analogWrite(blueled, fadeValue);

I'm sure its something stupid that I have missed but I cant see it.

In the timer function you have:

   if (totaltime() >= night())

You have declared both totaltime and night as variables but you are trying to use them both as functions.


I have defined night at the top of the code as 1350.

byte night = 1350;

sorry I'm a bit new to this (or a bit dumb:-) ) but I cant see the wrong bit.

You defined a variable night not a function. If you want a function then declare a function. Google up C++ function and there are tons of tutorials that will teach you the difference. Just putting parenthesis does not a function make.

byte getNight(){
return night;

When you put parenthesis after a name, it indicates that the name is a function and you're calling it.

night is the value of the variable night. night() is the value returned by calling the function night.

Since night is not a function, you can't call it.