התחל במצב לא מקוון עם האפליקציה Player FM !
פודקאסטים ששווה להאזין
בחסות


1 Battle Camp: Final 5 Episodes with Dana Moon + Interview with the Winner! 1:03:29
Use Serial.print() to Display Arduino output on your computer monitor: Part 1
Manage episode 269164104 series 2774299
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 Serial.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 Serial.print() function.
This is the first part, of a two part series on the Serial.print() function. Here are the specific topics we will cover in this lesson:
- Why would you want to use the Serial.print() function?
- A brief overview of the Serial library
- The basic use of the Serial.print() function
Why Would You Want to Use the Serial.print() Function?
You may know that a function is a programming tool - it performs a specific task for you. The Serial.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 reason 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, then you can use the Serial.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 to send information to a computer display using the Serial.print() function 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 do. 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.
You can look at the code until your eyes bleed, but actually visualizing the variable being incremented [via the Serial.print() function], to see its values every time through the loop() can help explain what is happening very quickly.
A Brief Overview of the Serial LibraryWe can’t talk about the Serial.print() function, without briefly talking about the Serial library.
Generally speaking, a library is simply a collection of functions that all have something in common.
The print() function is part of a library called the Serial library. Now, it's not cereal like Cheerios or Captain Crunch we're talking about - it's serial as in “one after another”.
The serial library allows us to interface the Arduino with other hardware, like a computer.
In order for us to use the functions of the Serial library, we have to initiate serial communication - to do this we use the Serial.begin() function. Serial.begin() needs to go in the setup().
void setup() { //Initiate Serial communication. Serial.begin(9600); }Now for reasons beyond the scope of this discussion, it is convenient to use the number 9600 in the Serial.begin() function. The value 9600 specifies the baud rate. The baud rate is the rate at which information will pass from the Arduino to the computer, or in the other direction.
The Basic Use of the Serial.print() FunctionLet's talk about how to use the Serial.print() function.
Say we have a sketch. This sketch has a variable called coolFactor.
I want to be able to monitor the value of the coolFactor variable – that is, I want it displayed on my computer screen. A perfect use for the Serial.print() function!
The first thing we must do in the Arduino sketch is begin serial communications. Like we just said, we use the Serial.begin() function and place it within the setup() of the sketch.
//A variable to hold the level of coolness int coolFactor = 3; void setup() { Serial.begin(9600); } void loop() { //Send the value of coolFactor to the the Serial port. //So we can see it in the serial monitor window Serial.print(coolFactor); }Now in the loop(), if I want to display coolFactor’s value with print(), I simply type Serial.print() and in the parenthesis I type the variable name.
If we upload this sketch to the Arduino, the value of coolFactor will be sent to the serial port every time through the loop(). In the Arduino IDE, if you open up the serial monitor window [Tools > Serial Monitor], you will see the values streaming down.
In next week’s episode, we’ll talk about some more intricacies of the Serial.print() function.
If you enjoyed this lesson, I welcome you to join 1000's of students who have enjoyed our free Arduino Crash Course - it's a 19 part video training series on using Arduino (You can sign up below).
61 פרקים
Manage episode 269164104 series 2774299
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 Serial.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 Serial.print() function.
This is the first part, of a two part series on the Serial.print() function. Here are the specific topics we will cover in this lesson:
- Why would you want to use the Serial.print() function?
- A brief overview of the Serial library
- The basic use of the Serial.print() function
Why Would You Want to Use the Serial.print() Function?
You may know that a function is a programming tool - it performs a specific task for you. The Serial.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 reason 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, then you can use the Serial.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 to send information to a computer display using the Serial.print() function 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 do. 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.
You can look at the code until your eyes bleed, but actually visualizing the variable being incremented [via the Serial.print() function], to see its values every time through the loop() can help explain what is happening very quickly.
A Brief Overview of the Serial LibraryWe can’t talk about the Serial.print() function, without briefly talking about the Serial library.
Generally speaking, a library is simply a collection of functions that all have something in common.
The print() function is part of a library called the Serial library. Now, it's not cereal like Cheerios or Captain Crunch we're talking about - it's serial as in “one after another”.
The serial library allows us to interface the Arduino with other hardware, like a computer.
In order for us to use the functions of the Serial library, we have to initiate serial communication - to do this we use the Serial.begin() function. Serial.begin() needs to go in the setup().
void setup() { //Initiate Serial communication. Serial.begin(9600); }Now for reasons beyond the scope of this discussion, it is convenient to use the number 9600 in the Serial.begin() function. The value 9600 specifies the baud rate. The baud rate is the rate at which information will pass from the Arduino to the computer, or in the other direction.
The Basic Use of the Serial.print() FunctionLet's talk about how to use the Serial.print() function.
Say we have a sketch. This sketch has a variable called coolFactor.
I want to be able to monitor the value of the coolFactor variable – that is, I want it displayed on my computer screen. A perfect use for the Serial.print() function!
The first thing we must do in the Arduino sketch is begin serial communications. Like we just said, we use the Serial.begin() function and place it within the setup() of the sketch.
//A variable to hold the level of coolness int coolFactor = 3; void setup() { Serial.begin(9600); } void loop() { //Send the value of coolFactor to the the Serial port. //So we can see it in the serial monitor window Serial.print(coolFactor); }Now in the loop(), if I want to display coolFactor’s value with print(), I simply type Serial.print() and in the parenthesis I type the variable name.
If we upload this sketch to the Arduino, the value of coolFactor will be sent to the serial port every time through the loop(). In the Arduino IDE, if you open up the serial monitor window [Tools > Serial Monitor], you will see the values streaming down.
In next week’s episode, we’ll talk about some more intricacies of the Serial.print() function.
If you enjoyed this lesson, I welcome you to join 1000's of students who have enjoyed our free Arduino Crash Course - it's a 19 part video training series on using Arduino (You can sign up below).
61 פרקים
Toate episoadele
×





1 How to make a secret knock detector to trigger anything with only an Arduino and a few cheap components 12:57

1 Arduino Pseudo Random Non-Consecutive Number Generator 11:13








1 How to Use and Understand the Arduino Reference 12:48

1 Using Red-Green-Blue (RGB) LEDs with Arduino (Common Cathode Type) 14:47

1 Using Random Numbers with Arduino 13:02


1 How to Make One Button Have the Functionality of Two or More with Arduino 15:40

1 Understanding HIGH and LOW Arduino Pin States 12:31

1 Floating Pins, Pull-Up Resistors and Arduino 10:29


1 Throw out your breadboard! Dr. Duino: An Arduino Shield for debugging and developing Arduino projects 11:35

1 Shorthand Arithmetic :: Using Compound Operators (+= , -= , *= , /= ) with Arduino 12:43

1 Understanding Boolean Data Types and Using the Boolean NOT (!) operator to Switch Arduino Pin States 8:11

1 What to do when you just don't know :: Arduino, ADXL345 triple axis accelerometer and an RGB LED 14:04

1 3 Ways to Use Acceleration in an Arduino Sketch 17:37

1 Understanding the Arduino uber functions loop() and setup() 10:26

1 Functions: Let's make programming Arduino as easy as possible 11:00

1 Data Types: One size does not fit all 11:15


1 Syntax; the spelling and grammar of programming 11:32


1 Arduino Board Hardware overview for people like me 10:38

1 Everything you need to know about the Arduino IDE (for now) 11:09








1 How to read voltages with analogRead() 14:44

1 analogRead() and the Serial Port 12:02

1 digitalRead() and the Serial Port 21:22

1 How to Blink an LED with Arduino 14:39






ברוכים הבאים אל Player FM!
Player FM סורק את האינטרנט עבור פודקאסטים באיכות גבוהה בשבילכם כדי שתהנו מהם כרגע. זה יישום הפודקאסט הטוב ביותר והוא עובד על אנדרואיד, iPhone ואינטרנט. הירשמו לסנכרון מנויים במכשירים שונים.