Return to site

Arduino Serial Port Monitor

broken image


Jan 20, 2017 Arduino Serial Monitor is a simple tool available in Arduino software. Arduino Serial Monitor is used in Serial communication and it prints data, whatever you send through the serial port of Arduino will also be view able on this Serial Monitor.

/* * Created by ArduinoGetStarted.com * * This example code is in the public domain * * Tutorial page: https://arduinogetstarted.com/tutorials/arduino-serial-monitor */voidsetup() {Serial.begin(9600);pinMode(LED_BUILTIN, OUTPUT); // set the digital pin as output:}voidloop() {if(Serial.available()) // if there is data comming {Stringcommand = Serial.readStringUntil('n'); // read string until meet newline characterif(command'ON') {digitalWrite(LED_BUILTIN, HIGH); // turn on LEDSerial.println('LED is turned ON'); // send action to Serial Monitor }elseif(command'OFF') {digitalWrite(LED_BUILTIN, LOW); // turn off LEDSerial.println('LED is turned OFF'); // send action to Serial Monitor } }}

Arduino Serial Monitor Port Busy

HOME - - - - - - - - Table of contents, my Arduino 'How To' articles
Other material for programmers

A resource for debugging and more

A computer has provision for input and output, and a way to store the programs which process the input and determine the output.

The text you see in the serial monitor window, the one shown enlarged, at the right, is just a sample. That text was specified in the code being put into the Arduino under development. And what if, later, nothing is connected to the relevant pins? Nothing! The Arduino won't 'care' if you aren't 'listening' when it 'speaks'.

(If you already know about this use of the Serial Monitor, what about using it to send data to the connected Arduino? I also have notes for you on using the Arduino IDE Serial Monitor to send data to the Arduino from the development machine.

An Arduino with one push button and one LED is a computer.. but even your friends may ask you what that's good for.

You can make a quantum leap on the output front without buying anything beyond the basic Arduino. This How To tells you about using the output half of the serial stream.

Before we start: A WARNING!! ..

'Serial' and 'RS-232' are NOT just two ways of saying the same thing. RS-232 comms do use serial data, so you might think that you can just hook up the serial 'stuff' I'm going to talk about.. including your Arduino.. to RS-232 devices. Or to the RS-232 port of a big PC. NOT SO!! (They can be connected.. but there are a few details to get right.)

All the ins and outs of that are beyond the scope of this tutorial. I've inserted this warning just in case someone is tempted to 'extend' the ideas here, hook an Arduino directly to something RS-232.. and fry their Arduino! (If you want to connect to RS-232, search on 'Arduino MAX323'.)


The serial monitor lets you..

The serial monitor lets you see anything the Arduino sends to its serial port. (When I speak here of 'its port', I mean one built into most (all?) Arduinos (and clones), used for programming the devices. On traditional Arduinos (Uno, Pro Mini, etc), it uses pins 0 and 1.

As I just said: These pins are also connected to the electronics which the Arduino development environment uses for programming the Arduino. Don't worry.. you can use them both for the programming task, and for the serial monitor at (almost) the same time. (With care, they can even be used for more things, but that's a story for another page.)

Operating System Concepts Exercise Solutions Inc Operating System Concepts Silberschatz Purposes of an operating system: To supervise the execution of user programs to restrain the occurrence of errors and to avoid the misusage of computer and its resources is one important purpose of an operating system. Operating System Concepts Tenth Edition Avi Silberschatz Peter Baer Galvin Greg Gagne. We provide solutions to the Practice Exercises of the Tenth Edition of Operating System Concepts, by Silberschatz, Galvin and Gagne. These practice exercises are different from the exercises provided in the text. Operating system concepts exercise solutions.

Before I go on.. this page is about the relatively simple.. and broadly useful.. use of the serial monitor. Other 'stuff' can be sent to and from other hardware, including big PCs, over a serial channel, to a program running in the other hardware. That is all a bit beyond just using the serial monitor, but I mention it in passing, in case you wondered. I have pages for you on serial communications between Arduinos and other hardware. (anywhere you see 'Delphi' there, you can probably substitute 'Lazarus'.)

As I said, this page is about using the serial monitor to watch 'stuff' going to the development PC from the Arduino.

Enter the following and run it. We'll do something more useful in a moment, don't worry.

Wait until the usual 'Binary sketch size..' message comes up in the pane at the bottom of the Arduino integrated development environment ('IDE'). Then click on the 'Serial Monitor' button, the 'magnifying glass' I marked '6' in the diagram below. (It shows the top of the Arduino IDE window.)

(And, just in case, below: The old interface. The 'Serial Monitor' button was the right hand icon, the one like an upside down window shade.)

After you click on the right icon, the bottom pane of the Arduino development environment will clear, and after a short wait.. 6 seconds on my BBB just now.. you should see 'Hello world'. Two seconds later you should see 0, then 1, then 2, then 3.. each on their own line. The Arduino will count to 5, and then start again at zero.

Why should I care?

The example above counts from 1 to 5. Most of us, on a good day, can do that without the computer! The example was just to get you started with serial monitor.

You should care because the serial monitor can be very helpful when debugging things.

Imagine that you are working on a large Arduino program, and it isn't doing what you want. Say the program looks like...

.. and you're not able to figure out how many of the 'for' loops it is completing, not able to deduce if the loop function is executing at all? More than once? What!?

Add...

.. to the setup function, and then alter the loop function, making it..

Now as the program executes, you'll get messages, on the serial monitor, which will tell you how far it has progressed.

Not only can you output simple text messages like 'First loop done', but you can tell the program to output the values in variables which you are interested in.

Hindu temple website templates free download. Having established and filled a variable called 'iTmp', you can do..

(Contrary to my usual policy, that snippet wasn't checked. Do please get in touch if you discover a typo or 'gotcha'.)


'And another thing'.. data from development PC..

We've seen how data can be sent from the Arduino to the development PC.. the 'big computer' where the code is written, compiled, etc.

It is also possible to send data the other way. Let's say you are building a system to control a fan. The system will 'watch' a temperature sensor, and turn the fan on when the temperature rises above some value.

Download game sepak bola manager di laptop windows 7. Download Game Bola Gratis Untuk Windows Phone 6 Related Softwares Download. Game pc download Fairy Godmother Tycoon. Jan 18, 2015  Download.

While building this project, you could program everything so that things typed on the development PC while the Arduino program was running would pass to the Arduino via the serial monitor, and be seen, acted upon, by the Arduino program.

Arduino serial monitor port busy

Look at the image at the top of the page, the screenshot at the right of that. See the edit box at the top of the dialog, the one to the left of the 'Send' button? That's where you put the stuff you want sent.


Bonus- internal documentation..

Once you get into the habit of using the serial monitor, consider seriously including something like the following in your code, right after the serial stream is set up..

To support that, elegantly, someplace else, near top of program code is good place, you maintain..

Arduino Serial Port Monitor Software

Or, not as elegant, just make the first bit of code..

The reason I call this more 'direct' solution inelegant is that the relevant lines will be buried deep within your code, and when it is time to change the version ID, laziness may win. By using the strings, as long as you fill them near the top of the code, it is easy to find them when it is time for a change.

No, of course, you won't always have the Arduino connected to a big PC and the serial monitor turned on. But the code above does no harm in those circumstances. (Unless you want to use the pins associated with it for other things.) And when you DO have the serial monitor connected, the program and version information can be very useful.

(You can, however, connect something simpler in it's place, if all you need is to see internal documentation messages.)

I hope this tool proves useful to you in your development work. There may even be times when you find it useful in a finished project, but of course that would only be a project where your PC remained connected to the Arduino while the Arduino did whatever you set it up to do. Perhaps not a scenario which is going to arise often, but there's no reason it couldn't ever arise.


Site MapWhat's NewSearch
The search engine is not intelligent. It merely seeks the words you specify. It will not do anything sensible with 'What does the 'could not compile' error mean?' It will just return references to pages with 'what', 'does', 'could', 'not'.. etc.In addition to the tutorials for which this page serves as Table of Contents, I have other sites with material you might find useful...
Sequenced set of tutorials on Arduino programming and electronics interfacing.
Tutorials about the free database supplied with Open Office version 2. (If you experienced Adabas with Star Office, ooBase is nothing like it!)
Some pages for programmers.
Using the parallel port of a Windows computer.

If you visit 1&1's site from here, it helps me. They host my website, and I wouldn't put this link up for them if I wasn't happy with their service.


Ad from page's editor: Yes. I do enjoycompiling these things for you.. hope they are helpful. However.this doesn't pay my bills!!! If you find this stuff useful, (and yourun an MS-DOS or Windows PC) please visit my freeware and sharewarepage, download something, and circulate it for me? Links on your pageto this page would also be appreciated! And if you liked that, or want different things, here are some more pages from the editor of these tutorials..

Click hereto visit the homepage of Sheepdogsoftware.co.uk. Apologies if the '?FrmAht' I added to that link causes your browser problems. Please let me know, if so?

To email this page's editor, Tom Boyd..Editor's email address. Suggestions welcomed!

Why does this page cause a script to run? Because of the Google panels, and the code for the search button. Why do I mention the script? Be sure you know all you need to about spyware.

Page has been tested for compliance with INDUSTRY (not MS-only) standards, using the free, publicly accessible validator at validator.w3.org. Mostly passes.

AND (almost!) passes..

.... P a g e . . . E n d s ...





broken image