Go Down

Topic: expected primary-expression before ')' token (Read 140 times) previous topic - next topic

AaronC

Hi I am trying to compile the attached code to an arduino with Bluetooth but continually get the same error and can not see the issue. The IDE highlights line 298 but can not see an issue with it.  >:(  If anyone could help it would be greatly appreciated

pert

#1
Mar 17, 2019, 03:55 pm Last Edit: Mar 17, 2019, 03:55 pm by pert
Things can get confusing when you use macros. What you need to remember is that a macro just does a text replacement.

Your code:
Code: [Select]
#define MONITORING
#ifdef MONITORING
//if you want to use other Serial port then adapt line bellow
#define BT_BEGIN(x)      //Serial1.begin(x);while (!Serial1) {}
#define BT_AVAILABLE    //Serial1.available
#define BT_READ       //Serial1.read

means that, after going through the c++ preprocessor, BT_AVAILABLE and BT_READ will be replaced with nothing. So now let's see how the following code is translated:

Before the preprocessor:
Code: [Select]
  while(!BT_AVAILABLE()){
    eegManager();
    lightManager();
    servoManager();
   
  };

  ByteRead = BT_READ();


After the preprocessor:
Code: [Select]
  while(!()){
    eegManager();
    lightManager();
    servoManager();
   
  };

  ByteRead = ();


Now do you see the problem?

I recommend against using preprocessor directives unless absolutely necessary because they can make code very difficult to debug. In this case, I don't think there is a lot of benefit from the use of the preprocessor.

AaronC

Hi thanks, what would you propose I do to rectify the issue? I am new to this and found a project that I wanted to demonstrate and though it would be a matter of simply uploading the code.... obviously not....

pert

Which Arduino board are you using?

How do you have the Bluetooth module wired to the Arduino board?

AaronC

Was using arduino Uno but have changed to Leonardo.

Was using a HC-05 as a freetronics shield.

pert

Please post a link to where you bought the Freetronics Shield from. I need to know which pins it connects the HC-05's RX and TX lines to in order to answer your question.

Go Up