Function Serial: Print in Only One Line

We will teach you that it is possible to write only one Serial.print line to display several messages.

Jun 3, 2019

38004 views

46 respects

Components and supplies

1

USB-A to B Cable

1

Arduino UNO

Project description

Code

Concatenating the Serial.print () Function

arduino

Downloadable files

Connection Arduino with computer

Connection Arduino with computer

Image

Connection Arduino with computer

Connection Arduino with computer

Image

Comments

Only logged in users can leave comments

Image
Image

J-M-L

2 years ago

Dont use the String class on small micro-controllers , there is NOTHING wrong with having evlines of code, it alls ends up in the serial buffer and won’t print faster... you are just using more memory than needed which can come bite you later... stick to 3 print...

Image
Image

sandromesquitamecatronica

2 years ago

Good morning J-M-L, The post does not say it wrong or right, it teaches another way to write the code. Thankyou for your consideration, they are very relevant.

Image
Image

sandromesquitamecatronica

2 years ago

Next post will be using the function Millys().

Image
Image

vikonix

2 years ago

If you compare program size with 3 line (classic output) and 1 line (with String class converting) you will be wonder. Your code add about 900 bytes.

Image
Image

sandromesquitamecatronica

2 years ago

True.

Image
Image

Anonymous user

2 years ago

Very good.

Image
Image

sandromesquitamecatronica

2 years ago

Thankyou.

Image
Image

Anonymous user

2 years ago

you can use: Serial.printf(" Contando : %d Segundos \ ",x); //same line

Image
Image

Anonymous user

2 years ago

Can the x++ also be incorporated into that line?

Image
Image

sandromesquitamecatronica

2 years ago

Friend SECURED4TEP yes, you can to use x++ incorporated in the Serial.print.

Image
Image

sandromesquitamecatronica

2 years ago

Excellent,I'll write it down now, very good, Thankyou.

Image
Image

Anonymous user

2 years ago

Cara como é simples

Image
Image

Anonymous user

2 years ago

Muito didático, parabéns.

Image
Image

sandromesquitamecatronica

2 years ago

Obrigado.

Image
Image

Anonymous user

2 years ago

Thankyou, perfect.

Image
Image

sandromesquitamecatronica

2 years ago

Thankyou.

Image
Image

Anonymous user

2 years ago

well explained article serial plot is also a good way to represent data in graph must check https://electronicsmith.com/arduino-serial-print/

Image
Image

Anonymous user

2 years ago

Lembrando que concatenação de String's consome muita memória de seu Arduino, não aconselho usar este recurso sem um fim especifico como regra geral, tvz por isso não tenha na página de referencias oficial do Arduino.

Image
Image

Anonymous user

2 years ago

Exatamente, já ia comentar isso.

Image
Image

Anonymous user

5 years ago

well explained article serial plot is also a good way to represent data in graph must check https://electronicsmith.com/arduino-serial-print/

Image
Image

Rodrigo_Augusto_Cruz

6 years ago

Cara como é simples

Image
Image

Arduino_Ceara

6 years ago

Lembrando que concatenação de String's consome muita memória de seu Arduino, não aconselho usar este recurso sem um fim especifico como regra geral, tvz por isso não tenha na página de referencias oficial do Arduino.

Image
Image

Rodrigo_Augusto_Cruz

2 years ago

Exatamente, já ia comentar isso.

Image
Image

J-M-L

6 years ago

Dont use the String class on small micro-controllers , there is NOTHING wrong with having evlines of code, it alls ends up in the serial buffer and won’t print faster... you are just using more memory than needed which can come bite you later... stick to 3 print...

Image
Image

sandromesquitamecatronica

2 years ago

Good morning J-M-L, The post does not say it wrong or right, it teaches another way to write the code. Thankyou for your consideration, they are very relevant.

Image
Image

AngelaCosta

6 years ago

Muito didático, parabéns.

Image
Image

sandromesquitamecatronica

2 years ago

Obrigado.

Image
Image

Roboticamente

6 years ago

Thankyou, perfect.

Image
Image

sandromesquitamecatronica

2 years ago

Thankyou.

Image
Image

RodrigoRoger

6 years ago

Very good.

Image
Image

sandromesquitamecatronica

2 years ago

Thankyou.

Image
Image

Anonymous user

6 years ago

you can use: Serial.printf(" Contando : %d Segundos \ ",x); //same line

Image
Image

sandromesquitamecatronica

2 years ago

Friend Rafael, good afternoon, i tested it here, it display this error: 'class HardwareSerial' has no member named 'printf'

Image
Image

sandromesquitamecatronica

2 years ago

Friend SECURED4TEP yes, you can to use x++ incorporated in the Serial.print.

Image
Image

sandromesquitamecatronica

2 years ago

Excellent,I'll write it down now, very good, Thankyou.

Image
Image

Anonymous user

2 years ago

Can the x++ also be incorporated into that line?

Image
Image

sandromesquitamecatronica

6 years ago

Next post will be using the function Millys().

Image
Image

vikonix

2 years ago

If you compare program size with 3 line (classic output) and 1 line (with String class converting) you will be wonder. Your code add about 900 bytes.

Image
Image

sandromesquitamecatronica

2 years ago

True.