The command Serial.begin(9600) plays a very important role in understanding the arduino projects. We give this command when we want to initialize serial monitor.
Serial monitor:-
The Serial Monitor provides a way to send/receive information to/from your Arduino code. You can use it to view error, see the messages printed by your program, or to send commands that control your program.
Serial.begin()
The command ‘Serial. begin(9600)’ starts serial communication, so that the Arduino can send out commands through the USB connection. This tells the Arduino to get ready to exchange messages with the Serial Monitor at a data rate of 9600 bits per second. That’s 9600 binary ones or zeros per second, and is commonly called a baud rate.
Serial.print()
It is another command related to serial monitor. This command is used when we want to print some value in serial monitor. By printing values in serial monitor, we can better understand the codes , their workings and sometimes also help in finding errors in project.