Tuesday, April 25, 2017

Setup Arduino Print Line / Debug Print / Console Log Messaging

It took me a few extra minutes to figure out why any Serial.println() statements weren't appearing in my Arduino IDE's Serial Monitor. I'm brand new to Arduino coding, but it seemed like if you click the Serial Monitor icon your debug/print line messages should show up there.

For this basic example, I set the Arduino Uno's onboard LED on Pin 13 to blink twice per second, with a println() statement running just after each change of the LED's state. Esssentially:

  • Turn on the LED
  • Write me a message that says On
  • Turn it off
  • Write Off
  • Etc.


It turns out that I needed to set the channel to communicate with the IDE in code.

Inside void setup(){} add the line Serial.begin(9600); where the value 9600 matches the baud rate in the Serial Monitor.






That's it. It begins writing to the monitor as soon as you upload the sketch and the device resets itself.

There's some more information about the begin() method on the Arduino Language Reference

No comments: