Go Down

Topic: Writing To Console (Read 155719 times) previous topic - next topic

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.

Grumpy_Mike

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.

frenzal_dude

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");
...

PaulS

Quote
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.
The art of getting good answers lies in asking good questions.

stutteringp0et

#4
Nov 22, 2014, 01:43 am Last Edit: Nov 24, 2014, 06:50 am by 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.

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?

PaulS


Quote
Wherever you want a newline:
Code: [Select]
Serial.writeln();

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

Quote
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.
The art of getting good answers lies in asking good questions.

stutteringp0et

#6
Nov 24, 2014, 07:12 am Last Edit: Nov 24, 2014, 07:12 am by stutteringp0et
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.

BulldogLowell

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)

Code: [Select]

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()
{
  
}

Robin2

#8
Nov 24, 2014, 09:09 am Last Edit: Nov 24, 2014, 09:13 am by Robin2
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
Two or three hours spent thinking and reading documentation solves most programming problems.

mikehoover

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.

ravisravis

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.

Delta_G

Code: [Select]
Serial.begin(SERIAL,9600);

Should be:

Code: [Select]
Serial.begin(9600);
|| | ||| | || | ||  ~Woodstock

Please do not PM with technical questions or comments.  Keep Arduino stuff out on the boards where it belongs.

ravisravis

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

Delta_G

#13
Jan 21, 2016, 09:51 pm Last Edit: Jan 21, 2016, 09:52 pm by Delta_G
Thanks...I should cut and paste more read the references ...
|| | ||| | || | ||  ~Woodstock

Please do not PM with technical questions or comments.  Keep Arduino stuff out on the boards where it belongs.

tanzz

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:

Code: [Select]
void setup() {
Serial.begin(9600);
}

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


After that click Arduino IDE:
Tools > Serial Monitor


Good Look!

Go Up