Function Serial: Print in Only One Line

Function Serial: Print in Only One Line © GPL3+

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

  • 2,989 views
  • 16 comments
  • 38 respects

Components and supplies

About this project

Most Arduino IDE users use various Serial.print() functions to print on the Serial monitor screen a one line sentence. In the image below, wes how you what traditional programming would look like.

The logic of this program is to print a count of every 1second and for this we use two string and an integer variable. Note what will beprinted on the serial monitor in the image below.

You have noticed that for me to print a sentence in only oneline I used three lines with the function Serial.print (), in the image below Ipresent a way to get the same result but only writing one line of theSerial.print () function.

And the result is the same.

I hope I have helped, any questions we are willing to help.

Project by John Arthur.

School: Pixels Escola

Teacher: Sandro Mesquita

Code

Concatenating the Serial.print () FunctionArduino
int x=0;
void setup() {
  /*Inicializa a comunicao serial a uma 
  taxa de 9600 baunds por segundo*/
  Serial.begin(9600);
}

void loop() {
  /*Serial.print("Contando: ");   //Imprime a palavra "Contando"
  Serial.print(x);              //Imprime o valor da variavel x
  Serial.println(" segundos."); //Imprime a palavra " segundos."*/
  Serial.println("Contando: "+(String)x+" segundos.");
  delay(1000);                  //Espera 1 segundo
  x++;                          //Soma x+1
}

Schematics

Connection Arduino with computer
Conexcaoarduinonote z4adl2bkps

Comments

Similar projects you might like

Using Serial Monitor to Control Servo Motor

Project tutorial by Kub_Luk

  • 9,442 views
  • 9 comments
  • 36 respects

Displaying Key Pressed on Serial Monitor

Project tutorial by ejshea

  • 868 views
  • 1 comment
  • 6 respects

View Serial Monitor Over Bluetooth

by millerman4487

  • 5,882 views
  • 9 comments
  • 32 respects

Serial Pong

Project showcase by Cody Brooks

  • 3,098 views
  • 2 comments
  • 12 respects

Serial Communication between NodeMCU and Arduino

Project showcase by Pawan Kumar

  • 34,275 views
  • 6 comments
  • 23 respects
Add projectSign up / Login