*Click Below to Sign up for the free Arduino Video Course:*
*Click Below to Check Out the Premium Arduino Video Course:*
*Click Below to Read About This Topic on Our Website*
In many cases while using an Arduino, you will want to see the data being generated by the Arduino. One common method of doing this is using the print() function from the Serial library to display information to your computer’s monitor.
In this week’s episode we will talk about the intricacies of the print() function.
This is the first part, of a two part series on the print() function. Here are the specific topics we will cover in this lesson:
Why would you want to use the print() function?
A brief overview of the Serial library
The basic use of the print() function
*Why would you want to use the print() function?*
You may know that a function is a programming tool - it performs a specific task for you. The print() function’s task is to send information from your Arduino to your computer so you can see the value displayed on your computer’s monitor.
There are an endless number of reasons you may want to send information from the Arduino to a computer display, but two reasons really stand out to me:
The first is being able to see information that you are generating with your Arduino.
For example, if you have a temperature sensor hooked up to your Arduino, and you want to see the value that the temperature sensor is recording - you can use the print() function to send the data to a computer monitor via the USB cable. If you open up the serial monitor window (Tools - Serial Monitor), you will see the values streaming in from the Arduino.
The other big reason is for developing and debugging Arduino sketches.
Very often, when you are developing an Arduino sketch, what you end up coding does something differently than what you expected it to. Maybe you have a variable that gets incremented every so often and blinks an LED when it reaches a threshold. When you upload the code to the Arduino you notice that the LED is blinking more often than it should be.
You can look at the code until your eyes bleed, but actually visualizing the variable being incremented [via the print() function], to see its values every time through the loop() can help explain what is happening very quickly.
This Arduino tutorial was created by Open Source Hardware Group. We are an education company who seek to help people learn about electronics and programming through the ubiquitous Arduino development board.