| 
  • If you are citizen of an European Union member nation, you may not use this service unless you are at least 16 years old.

  • Stop wasting time looking for files and revisions. Connect your Gmail, DriveDropbox, and Slack accounts and in less than 2 minutes, Dokkio will automatically organize all your file attachments. Learn more and claim your free account.

View
 

BlinkyPotAndSerialMon

Page history last edited by WikiAdmin 5 years, 5 months ago

This challenge starts with the ingredients of Blinky with a Potentiometer. But we are going to add something to it.

 

That something will give you what you need to use a very valuable took that is built in to the Arduino programming software. The tool is the serial monitor. (I have an external page with more detail about ther sereial monitor, which you may want to visit, if what you see here isn't enough for your needs.)

 

The challenge is "boring", but short... and along the way you learn about the serial monitor... a very useful tool.

 

If your Arduino doesn't already have a pot plugged into the lower right hand daughter board input socket... the second socket down... from doing BlinkyPot, plug one in there now.

 

Once that's available, enter the following program....

 


#include <NovGrdCore.h>

NovGrdCore NGC;

void setup()
{
//yes, you have to have this... even though it is empty
Serial.begin(9600);
Serial.println('Hi');
delay(800);
}

void loop()
{
int iAnVal;

iAnVal=analogRead(inPLR);

Serial.println(iAnVal);

NGC.makeOuUR(1);
delay(iAnVal);
NGC.makeOuUR(0);
delay(iAnVal);
}

 

It is pretty much still the basic Blinky pot... but with something extra!

 

In setup, we have two lines which "turn the serial monitor on", and send "Hi" to it, so we know when it starts.

 

And then, at the right place in loop(), we've added Serial.println(iAnVal); which causes the number in iAnVal to appear on the serial monitor. Very useful for making sure "things" are "working".

 

Where IS this "serial monitor", where we can see things??

 

Once your program uploads, click on the magnifying glass icon at the upper right of the Arduino development software's page. It isnt' a "search" button... it is a way to "look inside" your program while it is running... but you will only see things that you have asked to see with lines like Serial.println(iAnVal);.

 

NovGrdCore version

 

Inside NovGrdCore, there is a subroutine to send the version of the library installed on your computer to the serial monitor. (The monitor must have been started before NGC.reportVers() is called.)

 

It is a good idea to put....

 

NGC.reportVers();

Serial.println();

delay(800);

 

... right after the Serial.begin(9600); in every program you write that uses NovGrdCore.

Comments (0)

You don't have permission to comment on this page.