Expected primary-expression before ')' token Help

#include <RTClib.h>    // RTC Library
#include <Wire.h>      // I2C Library
#define HOUR 19       // Wake-Up Time (hour)
#define MINUTE 42    // Wake-Up Time (minutes) //  i.e. Wake up at 5:40 (24hr clock)
#define SECONDS
#include <Servo.h>  

int pos=0 ;
int ServoPin=5; // the pin where the servo is connected
int position_target= 0;
int position_last_set= 0;
int rs=7;
int en=8;
int d4=9;
int d5=10;
int d6=11;
int d7=12;
bool wake_up_now = false;
Servo myservo;  // create servo object to control a servo
// twelve servo objects can be created on most board
RTC_DS3231 rtc;
LiquidCrystal lcd(rs,en,d4,d5,d6,d7);
void setup() {
  // put your lcdsetup code here, to run once:
 Serial.begin(115200);           // Start Serial Monitor
 myservo.attach(ServoPin); // attaches servo on pin 10 to servo object
 Wire.begin();
 rtc.begin();

  if (!rtc.begin())
  {
    Serial.println("Couldn't find RTC"); // Error Message!
    while (1);  
  }
 
                                           rtc.adjust(DateTime(F(__DATE__), F(__TIME__))); // Uncomment – Compile – Upload)
}
void loop()
{
 static int lastSECOND = 0;
 lcd.setCursor(0, 0);
 DateTime now = rtc.now();

//has seconds changed ?  
if (lastSECOND != now.second())
 {
   //update to the new second
   lastSECOND = now.second();

   Serial.print(now.hour(), DEC);
   Serial.print(':');
   Serial.print(now.minute(), DEC);
   Serial.print(':');
   Serial.print(now.second(), DEC);
   Serial.println();
   
   //is it time to operate the servo ?
   if ((now.minute() == MINUTE) && (now.hour() == HOUR) && (now.second() == SECONDS))
   {
     //*****************
     for (pos = 0; pos <= 120; pos += 1)   //goes from 0 degrees to 120 degrees
     {
       myservo.write(pos);                 //tell servo to go to position in variable 'pos'
       delay(3);                           //waits 3ms for the servo to reach the position
     }

     //*****************
     for (pos = 120; pos >= 0; pos -= 1)   //goes from 120 degrees to 0 degrees
     {
       myservo.write(pos);                 //tell servo to go to position in variable 'pos'
       delay(3);                           //waits 3ms for the servo to reach the position
     }

     //*****************
     for (pos = 0; pos <= 120; pos += 1)   //goes from 0 degrees to 120 degrees
     {
       myservo.write(pos);                 //tell servo to go to position in variable 'pos'
       delay(3);                           //waits 3ms for the servo to reach the position
     }

     //*****************
     for (pos = 120; pos >= 0; pos -= 1)   //goes from 120 degrees to 0 degrees
     {
       myservo.write(pos);                 //tell servo to go to position in variable 'pos'
       delay(3);                           //waits 3ms for the servo to reach the position

     }
     
             myservo.write(0);                   //moves forward
             delay (1000);                       //waits 1 second
             myservo.write(90);                  //stops
   
   } //END of  if ((now.minute() == MINUTE) && (now.hour() == HOUR) && (now.second() == SECOND))

 } //END of if (lastSECOND != now.second())

} //END of loop()

This is the error

expected primary-expression before ')' token

 //is it time to operate the servo ?
   if ((now.minute() == MINUTE) && (now.hour() == HOUR) && (now.second() == SECONDS))

I've been debugging for days and once i fixed a problem this came up by the way this is just a part of the code if any of you could help it would be appreciated

Your code is incomplete.
The compiler is telling you it is incorrect.

where is declaration for pos variable, compiler doesn’t know what type it is

We're not mind readers.

post your complete code as requested in Read this before posting a programming question ...

Also post your error using code tags.

i have edited my post please have a look and tell me whats wrong

could you post full error? it usually shows exactly where it errors

the code i pasted is where the Arduino shows the problem is

Oops

what do u mean???

there you haven’t defined it it replaced SECONDS with nothing

Sp. "you"

2 Likes

thanks for making it clear

Thank you, in future, for posting in an appropriate forum section, and posting all of your code, and all of your error messages.

I try im beginner so this was my first time using a the forum

You are welcome. Don't hesitate to ask.
Asking a question in a good way is almost as hard as solving the problem.

Please read the link in reply #4.

Typical problems on this forum are:

  • The famous problem is "it does not work" and then someone refuses to show the sketch or tell what the result was and how that is different from what was expected.
  • Sometimes I start talking about looking into my crystal ball. With that I mean that I have to guess what the hardware and software is.
  • We like to see the whole sketch, there is even a website for that: https://snippets-r-us.com/.
  • We like to know what the project is about. Strange questions might be this: https://xyproblem.info/.
  • If you want to share what a compiler says, then copy it. The compiler will tell the line number and more.

Your post was MOVED to its current location as it is more suitable.

Could you also take a few moments to Learn How To Use The Forum.

Other general help and troubleshooting advice can be found here.
It will help you get the best out of the forum in the future.

After substitution you get:

   if ((now.minute() == 42) && 
       (now.hour() == 19) && 
       (now.second() == ))

That (now.second() == ) is your problem.

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.