Too Few Arguments Error

You guys like context to here you go: I am working on an individual project for my robotics class and I decided to design and build an automatic dog feeder using an arduino. However I have run into a bit of a wall since I am newer to the arduino, I keep getting a “too few arguments error: void drawTime(int, int)” and I am wondering what I am doing wrong. This is a work in progress so feel free to scour the code for any more errors I may run into. Thanks for your input. :smiley:

Code:

#include <Servo.h>
#include <Time.h>
#include <LiquidCrystal.h>

int servoPin = 9;
Servo servo;
int angle = 0;
time_t t = now();
LiquidCrystal lcd(7, 8, 9, 10, 11, 12); 

void setup()
{
   servo.attach(servoPin);
   setTime(9,25,55,16,4,2015);
   Serial.begin(9600);
   lcd.begin(16, 2);
   lcd.print("Please set time");
   pinMode(13, INPUT_PULLUP);
   pinMode(4, INPUT_PULLUP);
   pinMode(2, INPUT_PULLUP);
   setNewTime();
}

void drawTime(int myMinute, int myHour)   <---- Line with error
{
   lcd.setCursor(0,0);
   lcd.print("H:");
   lcd.print(myHour);
   lcd.print(" M:");
   lcd.print(myMinute);
   lcd.print("  "); 
}

void setNewTime()
{
   int myMinute = minute(t);
   int myHour = hour(t);

           if(digitalRead(2) == 1)
           {
                 myMinute+=1; 
             if(myMinute >= 60)
             {
               myMinute = 0;
             }
           }
             else
             {
             }
           if(digitalRead(13) == 1)
           {
                  myHour+=1;  
             if(myHour >= 24)
             {
               myHour = 0;
             }
           }
             else
             {
             }
           if (digitalRead(4) ==1)
           {
             setTime(myHour,myMinute,0,16,4,2015);
           }
           else
             {
             }
}

void setAlarm()
{
}
void loop()
{
   t = now();
   servo.write(0);
   
   drawTime()(minute(t), hour(t));
}

Moderator edit:
</mark> <mark>[code]</mark> <mark>

</mark> <mark>[/code]</mark> <mark>
tags added.

No, the error’s in the line that calls that function, namely this line in loop…

drawTime()(minute(t), hour(t));

That empty pair of brackets here: drawTime**()**(minute(t), hour(t)); means you’re not giving the function any arguments, hence the error.

It compiles if you lose them:

 drawTime(minute(t), hour(t));

Thanks for the quick reply!

I just pointed out the line that the environment highlighted for me, but that makes complete sense.
Again, if there is anything else anyone can find, feel free to post them.

There are instances in the program where you have used an int variable where a byte would do. This will not stop the program from working but you would normally use a variable whose size is appropriate to the maximum value expected. A couple of examples

  int myMinute = minute(t);
  int myHour = hour(t);

You have named servoPin so why not name other pins to make lines like these more readable ?

  pinMode(13, INPUT_PULLUP);
  pinMode(4, INPUT_PULLUP);
  pinMode(2, INPUT_PULLUP);

and

  if (digitalRead(2) == 1)

etc

The empty else clauses are not needed

int servoPin = 9; //<-------------9 You are not supposed to use pin 9 for the servo and the lcd display right?
Servo servo;
int angle = 0;
time_t t = now();
LiquidCrystal lcd(7, 8, 9, 10, 11, 12); //<-----  9