{"id":223,"date":"2015-07-16T11:43:44","date_gmt":"2015-07-16T11:43:44","guid":{"rendered":"https:\/\/arduino-developer.com\/arduino\/?p=223"},"modified":"2026-04-01T12:44:14","modified_gmt":"2026-04-01T11:44:14","slug":"printing-to-the-console-serial-monitor","status":"publish","type":"post","link":"https:\/\/arduino-developer.com\/arduino\/programming\/console\/printing-to-the-console-serial-monitor","title":{"rendered":"Printing to the console \/ serial monitor"},"content":{"rendered":"\n<p>Use the UART &#8211; <a href=\"https:\/\/arduino-developer.com\/arduino\/programming\/uart\/serial-port-uart\">see here<\/a>.&nbsp; <\/p>\n\n\n\n<p>Menu &gt; Tools &gt; Serial Monitor sop see its output <\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Enable the serial port<\/h4>\n\n\n\n<pre class=\"wp-block-code\"><code>  \/\/Serial.begin(9600);    \/\/May as well run it at fast speed of 115200\n  Serial.begin(115200);\n  while(!Serial)\n    ;<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">Strings<\/h4>\n\n\n\n<h5 class=\"wp-block-heading\">Print const string<br><\/h5>\n\n\n\n<pre class=\"wp-block-code\"><code>  Serial.println(F(\"Hello\"));<\/code><\/pre>\n\n\n\n<p>Note the &#8220;F( )&#8221; avoids the compiler storing the string in RAM (dynamic) memory by default <\/p>\n\n\n\n<h5 class=\"wp-block-heading\">Print array as char string <\/h5>\n\n\n\n<pre class=\"wp-block-code\"><code>  Serial.println((char*)buffer);<\/code><\/pre>\n\n\n\n<h5 class=\"wp-block-heading\">Printing Multiple Strings<\/h5>\n\n\n\n<pre class=\"wp-block-code\"><code>  Serial.println(\"Hello \" + MyStringName);<\/code><\/pre>\n\n\n\n<h5 class=\"wp-block-heading\">Print A Character<\/h5>\n\n\n\n<pre class=\"wp-block-code\"><code>  Serial.print((char)c);<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">Specific variable types<\/h4>\n\n\n\n<h5 class=\"wp-block-heading\">Integer<\/h5>\n\n\n\n<pre class=\"wp-block-code\"><code>  Serial.print(variable1, DEC);<\/code><\/pre>\n\n\n\n<h5 class=\"wp-block-heading\">Hex<\/h5>\n\n\n\n<pre class=\"wp-block-code\"><code>  Serial.print(variable2, HEX);<\/code><\/pre>\n\n\n\n<h5 class=\"wp-block-heading\">Binary<\/h5>\n\n\n\n<pre class=\"wp-block-code\"><code>  Serial.println(variable3, BIN);<\/code><\/pre>\n\n\n\n<h5 class=\"wp-block-heading\">Float<\/h5>\n\n\n\n<pre class=\"wp-block-code\"><code>  Serial.println(my_float_value, 3);<\/code><\/pre>\n\n\n\n<p>Will print to 3 decimal places<\/p>\n\n\n\n<h5 class=\"wp-block-heading\">64bit value<\/h5>\n\n\n\n<pre class=\"wp-block-code\"><code>\/\/Serial.print does not support 64bit, so we use this\nvoid SerialPrintUint64 (uint64_t value)\n{\n  char rev&#91;22]; \n  char *p = rev + 1;\n\n  while (value &gt; 0)\n  {\n    *p++ = '0' + ( value % 10);\n    value \/= 10;\n  }\n  p--;\n  \/\/Print the number which is now in reverse\n  while (p &gt; rev)\n    Serial.print(*p--);\n}<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">Examples<\/h4>\n\n\n\n<pre class=\"wp-block-code\"><code>  Serial.print(F(\"Received: \"));\n  Serial.print(variable1, DEC);\n  Serial.print(F(\", \"));\n  Serial.print(variable2, HEX);\n  Serial.print(F(\", \"));\n  Serial.println(variable3, BIN);<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>  Serial.println(tx_data&#91;0], HEX);\n  Serial.println(tx_data&#91;1], HEX);\n  Serial.println(tx_data&#91;2], HEX);\n  Serial.println(tx_data&#91;3], HEX);\n  Serial.println(tx_data&#91;4], HEX);\n  Serial.println((p_buffer - tx_data), DEC);<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Use the UART &#8211; see here.&nbsp; Menu &gt; Tools &gt; Serial Monitor sop see its output Enable the serial port Strings Print const string Note the &#8220;F( )&#8221; avoids the compiler storing the string in RAM (dynamic) memory by default Print array as char string Printing Multiple Strings Print A Character Specific variable types Integer [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[28],"tags":[],"class_list":["post-223","post","type-post","status-publish","format-standard","hentry","category-console"],"_links":{"self":[{"href":"https:\/\/arduino-developer.com\/arduino\/wp-json\/wp\/v2\/posts\/223","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/arduino-developer.com\/arduino\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/arduino-developer.com\/arduino\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/arduino-developer.com\/arduino\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/arduino-developer.com\/arduino\/wp-json\/wp\/v2\/comments?post=223"}],"version-history":[{"count":14,"href":"https:\/\/arduino-developer.com\/arduino\/wp-json\/wp\/v2\/posts\/223\/revisions"}],"predecessor-version":[{"id":906,"href":"https:\/\/arduino-developer.com\/arduino\/wp-json\/wp\/v2\/posts\/223\/revisions\/906"}],"wp:attachment":[{"href":"https:\/\/arduino-developer.com\/arduino\/wp-json\/wp\/v2\/media?parent=223"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/arduino-developer.com\/arduino\/wp-json\/wp\/v2\/categories?post=223"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/arduino-developer.com\/arduino\/wp-json\/wp\/v2\/tags?post=223"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}