0 ratings0% found this document useful (0 votes) 103 views9 pagesArduino Serial Monitor
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content,
claim it here.
Available Formats
Download as PDF or read online on Scribd
Arduino OLED Display Tutorial
Hardware Required
1x Arduino UNO or Genuine UNO *
1x (Recommended) Screw Terminal Block Shield for Arduino Uno ®
Or you can buy the following sensor kit:
1* DIYables Sensor Kit 30 types, 89 units ®
Please note: These are Amazon affiliate links. you buy the components through
these links, We will get a commission at no extra cost to you. We appreciate itAbout Serial Monitor
Serial Monitor is one of the tools in Arduino IDE. It is used for two purposes:
‘@ Arduino > PC: Receives data from Arduino and display data on screen. This is
Usually used for debugging and monitoring
@ PC — Arduino: Sends data (command) from PC to Arduino.
Data is exchanged between Serial Monitor and Arduino via USB cable, which
is also used to upload the code to Arduino. Therefore, To use Serial Monitor,
we MUST connect Arduino and PC via this cable.
How To Use Serial Monitor
Open Serial Monitor
Click the Serial Monitor icon
© Hetotons Arno 128 CO = ax
Fle Eat sketch Tools He _ on
1evoid setup() {
a ke
Items on Serial Monitor
1. Output console: display data recelved from Arduino.
come‘Autoscroll Show timestamp Newine ¥600 baud Clear output
1. Autoscroll checkbox option to select between automatically scroll and not scroll
icome,
[Autoscroll] Show timestamp Newiine 9600 baud YClear output
1. Show timestamp checkbox: option to show timestamp prior to data displayed on
Serial Monitor.
|COME, 1)
‘Astoscro [Show tmestamg] Newine 42600 baud Jotear outpu
1. Clear output button: clear all text on the output console.
come,
ATT Revine spe00 baud Garand
1. Baud rate selection: select communication speed (baud rate) between Arduino
fand PC. This value MUST be the same as the value used in Arduino code (in
Serial. besin() function).
icone]
eras Rewino 00 baud Joa out
SELL
When we select baud rate (even the value is not changed), Arduino is
reset. Therefore, this is one way to reset Arduino.
1. Textbox user can type characters to send to Arduino,
|COM6, |
‘Aitosora Show timestamp Newine “2600 baue Joearoutpu
1. Ending selection: select the ending characters appended to data sent to Arduino.
Selection includes:
= No line ending: eppend nothing
"= Newline: append nowine (or '|») cheracter
1 Carriage return: append carriage return (CR or ‘|r) character
[= Both NL ond CR: append both newline and carriage rotuen (CRU, or ‘Ir n} charactors
icome
[toserl Show timestamp [eawine ‘800 baud Sctear output
1. Send button: when the button is pressed, Serial Monitor sends data in textbox plus
the ending characters to Arduino
come,
“Autosoral Show timestamp Newine “2600 pave JoearoutpuArduino To PC
To send data from Arduino to PC, we need to use the following Arduino code:
‘¢- Sot baud rate and begin Serial port by using Serialbegin() function
Bw sctminie: o
‘@Send data to Serial Monitor using one of the following functions: Serialprint),
Serial.printin(), Serialwrite(), For example, send “Hello Worfd!”to Serial Monitor
[ries siscinirmtio rect o
Example Use
In this example, we will send the “ArduinoGetstarted.com” from Arduino to
Serial Monitor every second
roid setup) (
Serial begin(9600)
0
roid Loop) {
Serial printin("ArdsinecetStarted. com
| lelay(1000)
Quick steps
‘@- Copy the above code and open with Arduino IDE
‘¢ Click Upload button on Arduino IDE to upload code to Arduino
‘@- open Serial Monitor
@ Select baurate 9600
‘#= See the output on &:
[COM6|AFduinocetstarted.com
lArduinoGetstarted.com
lArduinoGetstarted. com
IarduinoGetstarted.com
1 Monitor
Autoscroll Show timestamp
‘@— Ty changing Serial.srintin() function to Serial. print () functionPC To Arduino
How to send data from PC to Aduino and read it on Arduino
You will type text on Serial Monitor and then click Send button.
Arduino reads data and process it. To read data, we need to use the following
Arduino code:
‘¢- Set baud rate and begin Serial port
[BB sass in tnt oOo
‘@— Check whether data is available or not
is tseriat.svatianieg) a
i
17-3000
i
‘@-Read data from Serial port using one of the following functions: Serialreaci(),
Serial readBytes(), SeriolreadBytesuntil(), Seriatreadstring(),
Serial readStringUnti(). For example:
Example Use
In this example, we will send the commands from Serial Monitor to Arduino to
turn on/off a built-in LED. The commands include:
@= “ON turn on LED
@— “OFF*Stum off LED
How Arduino can receive a complete command? For example, when we send
“OFF” command, how Arduino can know the command is “0”, “OF” or
OFF"?
= When sending a command, we will append a newline character ('|) by
selecting “newline” option on Serial Monitor. Arduino will read data until itmeets the newline character. In this case, the newline character is called
delimiter,
By sic sets) 6
Serial begin(9600)
q
BB voc Looe) 1
BER) (soriat.avaiiario()) // if there is data comming
fe
BEM) eiviode (LED BUTLTTN, OUTPUT); // ant the digital pin ax cutpst:
HEM) string cormand = Serdal.readstringUntii("\n"); // read string until moet
B= (commana
oa
- Aigitalweite (ieD BUILTIN, aIGH)} // tuen on 22D
Serial.printin ("LD is turned ON"); // send accion te Serisl Honstor
,
4 (command = OFF")
‘
digitalmeite (AED BUILTIN, LOW) // turn off LED ie
Quick steps
‘¢ Copy the above code and open with Arduino IDE
‘= Click Upload button on Arduino IDE to upload code to Arduino
‘¢ Open Serial Monitor
‘#- Select baurate 8600 and newline option
Type “ON or “OFF” and click Send button
icome,
ony
‘Autoscroll Show timestamp Newline 9600 baud YClear output
4 See the built
respectively.
= We also see LED's state on Serial Monitor
LED's state on Arduino board. We will see LED's state is ON or OFF,
[COM6 [LED ie tarnea on
[Autoscroll ‘Show timestamp lewiine Ja600 baud Clear output
Try typing “ON” or “OFF” command some times.leo Tutorial
We are considering to make the video tutorials, f you think the video tutorials
are essential, please subscribe to our YouTube channel » to give us
motivation for making the videos.
Function References© Serial.availabie()
© serial.begin()
© serial print()
© serial printin()
© Serial,read()
4 Serial readBytes()
Serial eadaytesuntil()
© Serial readstring()
¢ Serial eadstringuntl()
© Serial.write()
The Best Arduino Starter Kit
‘4 See the best Arduino kit for beginner
See Also
4 Arduino Software Installization
4 Arduino - Hardware Preparation
4 Arduino - Hello World
4 Arduino - Code structure
= Arduino - Serial Plotter
eta
MINA ae ac)
Te Rn nm
SO aN eee AM Oe)
De an ea ar nae tga)
Ce eae nC Rae en og
rndDISCLOSURE
ArduinoGetStarted.com is a participant in the Amazon Services LLC Associates
Dea ee eee a a eC ace
Set ea ae ea ae ce
Pa eee eee eee era
‘Amazon.pl and Amazonse
ee ey