This is a special Arduino tutorial with no parallel in my related Pascal tutorials.
It addresses the problem of getting text (be it letters or digits) output from an Arduino without buying an LCD panel to display that text.
The good news is that you already have what you need, if you have a working Arduino. There is an answer that comes with the basic system.
The bad news is that the text you can display will be displayed on the big PC you have attached to the Arduino for "feeding" the program into the Arduino. You can't display text on the big PC once it is disconnected, and for most of the jobs I want to program my Arduinos for, the big PC won't be part of the deployed "answer". But that "bad news" isn't as bad as it seems. You don't have to do anything to "turn off" the text output when you disconnect the big PC after the development phase is complete. And the text can be very useful during the development phase.
The Arduino is not as feature rich as my $1000 Linux box! In particular, it would have quite a bit of trouble displaying this page of text, even if it could harvest it from the internet.
But that's okay! It is great for lots of jobs.... especially if they don't require a lot of text to be output. (Letters, digits, punctuation marks, etc.)
However, when you are developing a program, it is a great help if you can put bits of code in which cause little messages to pop up from time to time. Consider the following....
void loop(); { delay(1000); delay(2000); }
"Pretty pointless", I hear you say, and yes, it is... but it is simple, and will not distract you from the point I'm about to make.
If you were working on that "program", and you set it running, how would you know what was going on?
You could add lines to turn various LEDs on and off as the program passed various stages in the execution of your instructions. But typically, the LEDs attached to your Arduino would be busy with other messages. It would be nice to be able to get "I've got to here" messages without interfering with the things you're trying to get working, get doing something else. And there's an answer....
With a little bit of other stuff, the following will work....
void loop() { delay(1000); Serial.println("Just finished delay 1000"); delay(2000); Serial.println("Just finished delay 2000"); }
.... and when you set the program running, you'll eventually get a screen filled with lots and lots of....
Just finished delay 1000 Just finished delay 2000 Just finished delay 1000 Just finished delay 2000 Just finished delay 1000 Just finished delay 2000 Just finished delay 1000 Just finished delay 2000 Just finished delay 1000 Just finished delay 2000.....
.... lines. They will pop up at the times I hope you would expect.
So! What do you have to do to "turn on" the feature, and where will that text appear?
To turn it on, you only need to add....
Serial.begin(9600);
... to your "setup" function.
(By the way: When you run the program, you may find that the system takes longer than you would expect... say up to 10 seconds from when you think the upload is complete... before it enters the "loop" function.)
So. That's how you arrange for messages from your program, and how you turn them on. Where do they appear?
When the Arduino Development Environment program is running in your big computer, it shows as a window with a menu across the top consisting of "File.. Edit.. Sketch.. (etc)". Below that is a row of icons... a triangle to verify the code, a square to stop it, etc. At the right hand end of that line of icons is a rectangle with a little circle above it. Hover your mouse pointer over it, and you will see "Serial Monitor".
After you have written your program and saved it, and "upload to I/O board"ed it, and seen the "Binary sketch size..." message in the panel at the bottom of the Arduino Development Environment program's window, click on the Serial Monitor icon. Once the Arduino has finished the "setup" function, then you will see the messages you asked for where you once had the "Binary sketch size..." message. Pretty cool! And when you gain the relevant skills, those messages can help you a lot with debugging (I mean feature extending!) your programs.
You are not restricted to simple text. Try the following....
int iCounter = 0; void setup() { Serial.begin(9600); iCounter = 0; // not really needed, I'm just careful} } void loop() { Serial.println(iCounter); delay(500); iCounter=iCounter+1; //Yes, I know there's a "clever" way to do that. }
So. There you have a useful tool. You can also use your big PC and its keyboard to send stuff into the Arduino while a program is running in the Arduino, but that's a story for another day!
|
Page WILL BE tested for compliance with INDUSTRY (not MS-only) standards, using the free, publicly accessible validator at validator.w3.org
....... P a g e . . . E n d s .....