We are not just focusing on Serial.read() and Serial.write() etc. We will try to look onto some advance, beyond the basics functions which you may need into your daily embedded system development life with Arduino. Arduino Serial communication is one of the basic thing that every beginner learn but still there are some features you may never looked into them. Today we are covering few of them and try to extend our Arduino skills. Maybe you need one of this technique into your next Arduino Project. So this arduino tutorial is going to help you learn some of the advanced techniques which you should know before you start your next project which heavily based on Serial Communication.
You may already very well aware of the need of the serial communication, which is to communicate between two devices, or even to communicate with your laptop to give you some visual output. Or maybe you have added some GUI built on top of that Serial incoming data. No matter what, you are going to use one or more of functions we are going to talk today.
Very Basic Arduino Serial Communication Program
Before we dive into the advanced features, let’s just talk about the very first and basic serial program and look into the details of the code. Here is the code we presented which start the serial port using Serial.begin()
function and after that prints a string onto the serial terminal using the Serial.println()
method.
void setup(){
Serial.begin(9600);
}
void loop(){
Serial.println("Hello World");
delay(1000);
}
Code language: JavaScript (javascript)
As you may already noticed this code is very basic using only two functions to initialize the serial post and to print a string to the serial terminal. If you write this code on Arduino IDE and compile and upload the code on Arduino, you open the Serial Terminal using the Ctrl+Shift+m
key, you will start seeing the output string “Hello World” on the serial terminal every second. Let’s see how we can improve this code and what kind of functions could add extra beauty to this code.