Preparing Our Uno and PC
For this and subsequent articles, we’re going to use an
Arduino Uno as the reference microcontroller. To make
things more interesting, we’re going to add a 10K
potentiometer wiper pin to the A0 analog input pin and
connect the other two pins to + 5 volts and ground on the
Uno. This will demonstrate how a varying voltage level
from the pot gets translated into an A2D (analog to digital)
value for our analog scaling example. Figure 1 illustrates
the 10K pot hookup.
We’re using the Uno because it comes complete with
an FTDI serial-to-USB chip, along with a standard USB-B
connector that makes it easy to create a serial connection
to a PC using a standard A-B USB cable. Of course, you
can use any micro you have that can output serial A2D
data like the PICAXE, Raspberry Pi, or even one of the kits
you may have built from a Nuts & Volts article.
Since we’re using a USB connection, you’ll also need
to install a suitable USB driver on the PC side. For the
FTDI chip, this is easily done by going to their website at
www.ftdichip.com/Drivers/VCP.htm and selecting the
proper driver. Make sure that the USB driver is installed
before going any further or else things will probably not
work unless your PC already has the driver installed.
Creating a Sketch
Next comes creating a simple Arduino sketch to
configure and send the potentiometer’s A2D data from
the Uno to the PC. Figure 2 shows the sketch code listing.
It begins by defining a variable called AnalogInPin that
represents the A0 pin and configures the comm port with
the Arduino’s Serial.Begin(9600) instruction. For the Loop,
it reads the A2D value at A0 and does a Serial.Println that
outputs the ASCII value of the reading via the serial port.
Note that the Serial.Println instruction also appends a
carriage return after the ASCII A2D value which tells
MakerPlot that this is the end of the data string for this
data set. Finally, we delay 100 milliseconds and repeat.
Be sure to first verify then compile the sketch, then
upload it to your Uno and check it against the Arduino
The DIY Software Kit
By John Gavlik and
Post comments on this article and find any associated files
and/or downloads at www.nutsvolts.com/
In this article, we'll show you how to
connect your micro to MakerPlot in
order to plot a single channel of analog
data. Plus, we'll show you how you can
scale the raw analog-to-digital converter
(ADC) data into corresponding voltage
levels. This means you don't have to do
any math inside your micro's code;
MakerPlot handles everything for you.
Let's get going.
52 December 2013
Figure 1. Arduino