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

  • Please do not post images of code or errors, it makes them impossible to search for – hardillb Jul 16 '18 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. – Chris Stratton Jul 16 '18 at 15:08
  • Lose the semicolon - #define CONSOLE Serial; expands Console.println() to Serial;.println() – Mawg says reinstate Monica Jul 19 '18 at 12:44
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.

| improve this answer | |

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