0

I am using Arduino ATmega2560. I have defined Serial as CONSOLE. When I am using CONSOLE it shows me error.

#include "Arduino.h"
#define CONSOLE Serial;

void setup()
{
    CONSOLE.begin(9600);
}

void loop()
{
    CONSOLE.println("Hello");
    delay(2000);
} 

enter image description here

3
  • Please do not post images of code or errors, it makes them impossible to search for
    – hardillb
    Jul 16, 2018 at 7:00
  • 3
    I'm voting to close this question as off-topic because the question actually being asked is entirely about C++ and Arduino and not in any way about an IoT usage of an Arduino. Hence this belongs on Stackoverflow or the Arduino site, not here. Jul 16, 2018 at 15:08
  • Lose the semicolon - #define CONSOLE Serial; expands Console.println() to Serial;.println() Jul 19, 2018 at 12:44

1 Answer 1

2

Try changing this:

#define CONSOLE Serial;

To this:

#define CONSOLE Serial

Notice the absence of the ; character in the change.


The preprocessor is expanding CONSOLE to Serial;, which results in, for example, Serial;.begin(9600);, which has 2 ;s in the statement, the first of which is unwanted.

0

Not the answer you're looking for? Browse other questions tagged or ask your own question.