Writing To Console

Hi,
how can I write text to the black error output section at the bottom of the Arduino IDE? is it possible?
I just want to be able to view the state of my variables etc.
I read about Serial.print etc but it doesn't explain much about where you can see the text.

Thanks in advance.

1 Like

Serial.print output will appere in the monitor window, click the rightmost icon on the window bar of the arduino window.
You can't get the arduino to write in that other place.

1 Like

I tried this just for a test but nothing came up in the window, what am I doing wrong?

Cheers again.

void setup() {
Serial.print("test");
...

what am I doing wrong?

Posting snippets, instead of all of your code.
Failing to use Serial.begin() to specify a baud rate and initiate the serial port.
Who knows what else.

I ran into this topic because I had the same question. The vague sort-of answer at the end left me to explore the example code to find the answer.

In setup(), start serial and choose your speed:

Serial.begin(9600);

Wherever you want to write to serial:

Serial.write("write this");

Wherever you want a newline:

Serial.println();

Everyone learns somewhere, why not make this a friendly place?

10 Likes

Wherever you want a newline:

Serial.writeln();

Which will produce a compiler error, since there is no writeln() method in the HardwareSerial class or in anything it derives from.

why not make this a friendly place?

We do, if people follow some simple guidelines, like reading the How to post in this forum sticky and posting ALL of their code.

We don't, especially, given just an incorrectly posted two line snippet.

How incredibly thoughtful of you to point out that I made a mistake and to NOT give the correct method name. It would've been unfortunate for anyone to have learned an actual answer from this thread.

Fixed my mistake, sorry I wrote the wrong method name - Serial.writeln() vs Serial.println() is a small error in the grand scheme of what I was trying to do, which was give an actual answer where only snark had existed before.

4 Likes

PaulS:
We don't, especially, given just an incorrectly posted two line snippet.

I guess he's referring to the Royal "we"

make sure you are setting the baud rate in the Serial Monitor to the same number in your sketch (here 115200)

int myInt = 20;
unsigned long myTimeStamp = 1416813706;
const char *myCharArray = { "This is myCharArray"};
float myFloat = 3.14159265359;

void setup()
{
  Serial.begin(115200);
  Serial.print(myInt);
  Serial.print(myTimeStamp);
  Serial.print(myCharArray);
  Serial.print(myFloat, 6); //prints to six places right of the decimal
}
void loop()
{
  
}
2 Likes

stutteringp0et:
I ran into this topic because I had the same question. The vague sort-of answer at the end left me to explore the example code to find the answer.

Reply #1 had a complete answer to the original question which, as far as I can see, was different from yours.

Your code does not address the original question.

And I think Serial.print() and .println() are adequately covered in the Reference pages.
I think it is reasonable to expect people to read them before posting questions.

...R

In the Arduino environment, choose: "Tools -> Serial Monitor" from the menu and a console window will open and your output should display there. It did not output to the black status area at the bottom of the sketch window.

2 Likes

void setup() {
// put your setup code here, to run once:
Serial.begin(SERIAL,9600);
Serial.println("Hello World");
}

void loop() {
// put your main code here, to run repeatedly:
Serial.println(" Hello World ");
delay(2000);

}

I fire up the serial monitor (already set to 9600) but don't see anything printed there. But I see the scroll tab move, so I guess something is happening.

Thanks...I should cut and paste more ...

frenzal_dude:
Hi,
how can I write text to the black error output section at the bottom of the Arduino IDE? is it possible?
I just want to be able to view the state of my variables etc.
I read about Serial.print etc but it doesn't explain much about where you can see the text.

Thanks in advance.

Write and build code below:

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

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

After that click Arduino IDE:
Tools > Serial Monitor

Good Look!

@tanzz, you need to check dates before you reply. Your Post is 5 years too late.

...R

Robin2:
@tanzz, you need to check dates before you reply. Your Post is 5 years too late.

...R

Seeing as this is the very first Google result that appears when searching out how to write debug messages to the console, the last post previous to the one I quoted was perfect. It explained what code to write, and how to see it in the IDE. Thank you tanzz, BulldogLowell and stutteringp0et for helpful responses to get me going.

Unfortunately, it's a wonder I made it to the good stuff, because the first responses (from PaulS) were very off-putting and disheartening to read. Thought this all was supposed to be fun, but then there's some a*& giving a novice a hard time. I'm an experienced programmer in C#, C++, etc but new to the Arduino. I hope the community is a lot nicer in general than PaulS!

Oh, and btw I'm a engineer/software developer by career and no one reads the official documentation :slight_smile:

2 Likes

Gunn317:
I hope the community is a lot nicer in general than PaulS!

I believe he is no longer contributing. But I think that if you can ignore his style you will find that his advice was accurate.

Oh, and btw I'm a engineer/software developer by career and no one reads the official documentation :slight_smile:

I'm quite sure you have not become a professional developer without becoming a regular "looker-up" of technical details - whether in the official documentation or elsewhere. And I'm also quite sure that you would find it irritating for people to ask you routine questions about your products to which they could easily have got the answer by reading the documentation you wrote.

...R

1 Like