Hello. I'm currently working on my university project. There is "expected primary-expression ')' token . Please help me to solve this

hello. I'm currently working on my university project. I'm working on a digital clock that i received from https://youtu.be/X-TmE2jNSL0 . Right now I'm stuck. There is "expected primary-expression ')' token . Please help me to solve this

#include<Wire.h>
#include<LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x20,16,2);
#define Latch 11
#define Data 9
#define Clock 10
#define up 2
#define down 3
#define set A3
#define menit
#define jam
#define detik

byte lowChar[] ={~B00111111,//0
                 ~B00000110,//1
                 ~B01011011,//2
                 ~B01001111,//3
                 ~B01100110,//4
                 ~B01101101,//5
                 ~B01111101,//6
                 ~B00000111,//7
                 ~B01111111,//8
                 ~B01101111,//9
                 ~B10000000,//titik
                 ~B11111110,//Dig1
                 ~B11111101,//Dig2
                 ~B11111011,//Dig3
                 ~B11110111,//Dig4
                  };
byte m1,m2,j1,j2;
long dmenit,djam,hold;
unsigned long prev;
void setup() {
  lcd.begin();
  pinMode(Latch,OUTPUT);
  pinMode(Data,OUTPUT);
  pinMode(Clock,OUTPUT);
  
  pinMode(up,INPUT_PULLUP);
  pinMode(down,INPUT_PULLUP);
  pinMode(set,INPUT_PULLUP);
}

void loop() {
  main:
  detik();
  menit(dmenit);
  jam(djam);
  if(djam== 11&& dmenit== 26){lcd.setCursor(0,0);lcd.print("Sholat Dzuhur");detik(); menit(dmenit);jam(djam);}
  else if(djam== 14&& dmenit== 51){lcd.setCursor(0,0);lcd.print("Sholat Ashar");detik(); menit(dmenit);jam(djam);}
  else if(djam== 17&& dmenit== 40){lcd.setCursor(0,0);lcd.print("Sholat Maghrib");detik(); menit(dmenit);jam(djam);}
  else if(djam== 18&& dmenit== 56){lcd.setCursor(0,0);lcd.print("Sholat Isya");detik();menit(dmenit);jam(djam);}
  else if(djam== 3&& dmenit== 47){lcd.setCursor(0,0);lcd.print("Sholat Subuh");detik();menit(dmenit);jam(djam);}
  else {lcd.clear();}

  if(digitalRead(set)==LOW){while(digitalRead(set)==LOW){}goto setmenit;}
  goto main;
  
  setmenit:
  menit(dmenit);
  jam(djam);
  if(digitalRead(set)==LOW){while(digitalRead(set)==LOW){}goto setjam;}
  else if(digitalRead(up)==LOW){while(digitalRead(up)==LOW){}dmenit++;}
  else if(digitalRead(down)==LOW){while(digitalRead(down)==LOW){}dmenit--;}
  goto setmenit;

  setjam:
  menit(dmenit);
  jam(djam);
  if(digitalRead(set)==LOW){while(digitalRead(set)==LOW){}goto main;}
  else if(digitalRead(up)==LOW){while(digitalRead(up)==LOW){}djam++;}
  else if(digitalRead(downm)==LOW){while(digitalRead(down)==LOW){}djam--;}
  
}
void detik(){
  if(millis()-prev>60000){
    dmenit++;
    prev=millis();
  }
  if(dmenit>=60){
    dmenit=0;
    djam++;
  }
  if(djam>=24){djam=0;}
}

void jam(byte jm){
  j1=(jm/10)%10;
  j2=jm%10;
  cetak(j1,11);
  cetak(j2,12);
}
void(menit(byte mnt){
  m1=(mnt/10)&10;
  m2=mnt%10;
  cetak(m1,13);
  cetak(m2,14);
}

void shiftData(int nilai) {
  switch (nilai) {
    case 0; shiftOut(Data, Clock, MSBFIRST, lowChar[0]);break;
    case 1; shiftOut(Data, Clock, MSBFIRST, lowChar[1]);break;
    case 2; shiftOut(Data, Clock, MSBFIRST, lowChar[2]);break;
    case 3; shiftOut(Data, Clock, MSBFIRST, lowChar[3]);break;
    case 4; shiftOut(Data, Clock, MSBFIRST, lowChar[4]);break;
    case 5; shiftOut(Data, Clock, MSBFIRST, lowChar[5]);break;
    case 6; shiftOut(Data, Clock, MSBFIRST, lowChar[6]);break;
    case 7; shiftOut(Data, Clock, MSBFIRST, lowChar[7]);break;
    case 8; shiftOut(Data, Clock, MSBFIRST, lowChar[8]);break;
    case 9; shiftOut(Data, Clock, MSBFIRST, lowChar[9]);break;
    case 11; shiftOut(Data, Clock, MSBFIRST, lowChar[11]);break;//digit1
    case 12; shiftOut(Data, Clock, MSBFIRST, lowChar[12]);break;//digit2
    case 13; shiftOut(Data, Clock, MSBFIRST, lowChar[13]);break;//digit3
    case 14; shiftOut(Data, Clock, MSBFIRST, lowChar[14]);break;//digit4
  }
}
void cetak(char xl,char digit){
          digitalWrite(Latch,0);
          shiftData(digit);
          shiftData(xl);
          digitalWrite(Latch,1);
}

This is the problem:

#define detik

delete it.

Oke i will delete, thanks , you save me

While you are at it, menit and jam also do not want to be # defines.

Hope that was obvious.

a7

Hi
There are other errors besides "#define detik", there is "#define jam" and a function named void jam(), there is "#define menit" and a function named void menit() and on line 116 down is written downm.
In this line remaining "(" --- > void(menit(byte mnt)

In switch " switch (nilai) {" all case are finished with ; . The correct is :
RV mineirin

Don't forget the rather more serious issue: the OP is using some strange construct called goto :open_mouth:

Real Programmers aren't afraid to use GOTO's

1 Like

Hi
Yeah, you're right, I saw this program structure with goto and traveled to 1980/90 when I was using basic.
But I didn't even want to comment, as I already had so many mistakes that I was afraid to confuse the OP even more.
RV mineirin

"Real Programmers aren't afraid to use GOTO's "

I think the takeaway key-point there is "real".

Problem is, the unreal ones are too dumb to be afraid

1 Like

Thanks bro, your analyzing made my day. This is 100% work and my project was solved by your comment. Thanks a lot

typical c++-programming avoids using the command goto like the plaque.
there are only very rare cases where using the command goto is an advantage.

I have coded tenthousands of lines of code and never used a single goto.

In most cases the command goto is a dis-advantage of making the code

  • harder to modify,
  • harder to maintain
  • harder to understand

hm very unsual way to code.
Did you learn the programming-language BASIC before you started programming for the arduino?

best regards Stefan

And never mind that the above is EXACTLY equivalent to the much more accetable:

  if ( digitalRead(set) == HIGH )
  {
      return;
  }

Then you must have found and fixed a few other obvious problems.

Did you manage to figure out how to dispense with goto? Of course it will work, just curious. If you got rid of the gotos you code would look prettier and be easier for most of us to read.

Also you have logic to deal with the button or switch scattered all over your code. You could look into switch handling and denouncing debouncing, it would also make you code a bit prettier and easier to read.

Please post your result working sketch.

a7

I'm actually a little surprised that you can have a label called main.

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