int() Vs intln() | Arduino FAQs

Serial.print() vs Serial.println()

What are differences between Serial.print() and Serial.println()?

Answer

Both Serial.print() and Serial.println() prints number, string to Serial Monitor. However, Serial.println() prints more two characters prints Carriage Return '\r' and new line '\n' characters at the end.

What is Carriage Return '\r' and New Line '\n' characters ⇒ Simply, When you press Enter key on your keyboard, the Carriage Return '\r' and New Line '\n' characters is included in your text editor. It means after using Serial.println(), Next numbers or String will be displayed in a new line.

Let's see two examples to know the difference:

Example with Serial.print()

void setup() { Serial.begin(9600); Serial.print("Arduino"); Serial.print("Get"); Serial.print("Started"); Serial.print(".com"); } void loop() { }

The result on Serial Monitor

COM6 Send ArduinoGetStarted.com Autoscroll Show timestamp Clear output 9600 baud   Newline  

Example with Serial.println()

void setup() { Serial.begin(9600); Serial.println("Arduino"); Serial.println("Get"); Serial.println("Started"); Serial.println(".com"); } void loop() { }

The result on Serial Monitor

COM6 Send Arduino Get Started .com Autoscroll Show timestamp Clear output 9600 baud   Newline  

※ NOTE THAT:

The below code:

Serial.print("Arduino\r\n");

Is equivalent to

Serial.println("Arduino");

Buy Arduino

1 × Arduino UNO Buy on Amazon
1 × USB 2.0 cable type A/B Buy on Amazon
1 × Jumper Wires Buy on Amazon
Disclosure: Some links in this section are Amazon affiliate links. If you make a purchase through these links, we may earn a commission at no extra cost to you.Additionally, some links direct to products from our own brand, DIYables .

The Best Arduino Starter Kit

  • See the best Arduino kit for beginner

See Also

  • DS3231 vs DS1307
  • How to delete code on Arduino board
  • Servo motor does not work
  • How to install library on Arduino IDE
  • How to uninstall library on Arduino IDE

※ OUR MESSAGES

  • We are AVAILABLE for HIRE. See how to hire us to build your project
  • If this tutorial is useful for you, please give us motivation to make more tutorials.
DISCLOSURE ArduinoGetStarted.com is a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for sites to earn advertising fees by advertising and linking to Amazon.com, Amazon.it, Amazon.fr, Amazon.co.uk, Amazon.ca, Amazon.de, Amazon.es, Amazon.nl, Amazon.pl and Amazon.se Copyright © 2018 - 2025 ArduinoGetStarted.com. All rights reserved. Terms and Conditions | Privacy Policy Email: [email protected]

Tag » Arduino Print R N