- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Print plain text in Arduino
To print plain text on the Serial Monitor, the Serial.print() function can be used.
In order to use this function, Serial needs to be initialized first (in the setup preferably). A typical implementation is shown below −
Example
void setup() { // put your setup code here, to run once: Serial.begin(9600); } void loop() { // put your main code here, to run repeatedly: Serial.print("Hello!"); delay(100); }
Note that the argument of Serial.begin() indicates the baud rate. You need to set the baud rate of your serial monitor to this value in order to read the printed messages properly. Often, the difference between the baud rate at which your microcontroller is transmitting and the baud rate at which the Serial Monitor is listening, leads to garbage values getting printed on the Serial Monitor.
The output of the above program, on the serial monitor, will be −
If you want to end the line after printing your message (or, in other words, make sure that the next message gets printed on a new line), you can use the Serial.println() function instead of Serial.print().
If you replace Serial.print() with Serial.println() in the above program, the output will be −