Arduino programming guide series
Focus on the type parameter in "println()"
We use the println() function to print a string to the serial monitor. The same function is overloaded with a second parameter that allows us to designate the type of data we want to display.

"Serial.println()" is one of the most useful functions in the Arduino language. It will print a string or a number to the serial monitor. It is an easy way to get data out of a sketch.
The most common way to use "println()" is like this:
Serial.println("This will print this message to the Serial monitor");
In this example, the single parameter of the function contains a String.
But, did you know that this function is overloaded, and can accept a second parameter?
The second parameter gives you the opportunity to specify the type of the data you specify in the first parameter.
Here's two examples:
- Serial.println(21, DEC) will print "21" in the serial monitor.
- Serial.println(21, BIN) will print "00010101 " in the serial monitor.
The "println()" function accepts the following types:
- DEC for decimals
- HEX for hexadecimals
- OCT for octals
- BIN for binary numbers
The type parameter is optional, so you can choose to not include one in your println instruction. In that case the output will default to decimal (DEC).
More details about this parameter are available in the documentation.
New to the Arduino?
Arduino Step by Step Getting Started is our most popular course for beginners.
This course is packed with high-quality video, mini-projects, and everything you need to learn Arduino from the ground up. We'll help you get started and at every step with top-notch instruction and our super-helpful course discussion space.
Jump to another article
3. Focus on the type parameter in "println()"
4. "0" or "A0" when used with analogRead()?
5. What is the "_t" in "uint8_t"?
6. Save SRAM with the F() macro
7. What is the gibberish in the Telnet output?
9. Confusing keywords? follow the source code trail
10. The interrupt service routine and volatile variables
11. The problem with delay() and how to fix it
12. How to deal with the millis rollover
13. Can you use delay() inside Interrupt Service Routine?
15. A closer look at line feeds and carriage returns
16. Understanding references and pointers
17. Simple multitasking on the Arduino
19. Concurrency with the Scheduler library on the Arduino Due and Zero
20. Bitshift and bitwise OR operators
21. What is a "static" variable and how to use it
22. Understanding the volatile modifier