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

closed as off-topic by Bence Kaulics, Chris Stratton, Sean Houlihane, MatsK, Mawg Jul 19 '18 at 12:47

  • This question does not appear to be about Internet of Things, within the scope defined in the help center.
If this question can be reworded to fit the rules in the help center, please edit the question.

  • 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 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.

  • Oops. Typing mistake. Thank you. – Iqbal Hossain Jul 16 '18 at 8:52
  • 1
    @IqbalHossain If it really answered your question, please mark this answer as accepted by clicking on the tick beside it. :) – Bence Kaulics Jul 24 '18 at 20:09

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