You are on page 1of 4

Analog Input

The real world is not digital. Considering temperature fluctuation as an example, it changes
within some range of values and generally does not make abrupt changes over time. We
often measure environmental parameters like temperature, light intensity, or whatever
using analog sensors. These resulting signals are stored as sequential digital data.

Analog Signals

An example would be to measure and record room temperature every minute. One could
watch a thermometer and write down the readings. The sequence of data would look like
(in Celsius): 20.3, 20, 20.5, 21, 20.8 ...

We face a number of issues here. First of all Arduino cannot understand temperature as
such, it needs to be translated into an electrical value. Second that electrical value has to be
translated into a number that can be processed within Arduino.

As said, microprocessors cannot handle temperature values as humans do. We need to


translate that to something the microchip can read. In order to do so, we can use sensors
that will transform, in this case, temperature into a voltage value between 0 and 5 volts.
This values are different from the HIGH and LOW that characterize digital signals, because
they can take any value between 0 and 5 volts. 0.3 volts, 3.27 volts, 4.99 volts are possible
values.

This is what we call an analog signal. It differs from the digital ones in being able of taking
many more than just two values. The amount of possibilities depends only in the
capabilities of the processor/microcontroller you are working with in each case. As we will
see later, Arduino can only distinguish 1024 different levels between 0 and 5 volts.

Bringing Analog Signals into Arduino

Each sensor can translate a range of physical world values into electrical values. Let's
imagine that our temperature sensor reads between 0C and 100C. Typically it should then
assign 0 volts to 0C and 5 volts to 100C. Thanks to this we can easily translate levels of
voltage into temperature and viceversa.

The next issue has to do with the finite resolution of digital technology. Arduino has the
possibility of reading values from the real world, which have been translated into electrical
values between 0 and 5 volts. Try now to answer this question for a second: how many
voltage values are there between 0 and 5 volts? The answer is simple: endless. Imagine two
voltage values in the range we are working with, that are as close as possible, e.g. 3.4 and
3.41 volts. It is possible to have endless values inbetween those two: 3.401, 3.403,
3.402539 ...

This means that we would need a processor with the ability to represent endless numbers,
but Arduino cannot. Therefore, we speak about different levels. In particular Arduino
divides the range of 0 to 5 volts into 1024 different voltage levels or intervals. 0 volts is in
the interval 0, and 5 volts in the interval 1023. In this way, 2.5 volts would be in the interval
511 as well as 2.52 volts or 2.5103.

This operation of translating an analog voltage value into different levels is what we call
Analog to Digital Conversion. One small hardware part inside the microprocessor that
comes with the Arduino I/O board is dedicated to translate analog voltages into these
values, it is the Analog to Digital Converter also called ADC.
Why 1024 values?

You could ask then, why 1024 values? This is a choice by the Numeric Conversion
microprocessor's manufacturer, who decided to create a 10-bit Binary Decimal
ADC. Numbers inside microprocessors are represented as
0 0
sequences of digital values. But this needs a more in depth
1 1
explanation.
10 2
Humans represent numbers in the decimal scale. We have a 11 3
series fo ten differen symbols: 0, 1, 2, 3, 4, 5, 6, 7, 8, and 9. And 100 4
we can represent any amount using those. When we count, we
101 5
start in the same order we wrote them and, once we reach the
110 6
last number, we start to make combinations of symbols. After
111 7
number 9 comes 10 which is a combination of two symbols.
After 453 comes 454 which just takes the next number ... 1000 8

1001 9
Within digital machines, there are only two symbols: 1 which
1010 10
represents HIGH or 5 volts, and 0 which represents LOW or 0
...
volts. This means that after number 1, we get numer 10. But 10
for the microcontroller is only 2 for a human!! We call this way 1111111110 1022

of counting Binary and it is used by most of the state-of-the-art 1111111111 1023


computers and microprocessors. The table on the right will help you to understand this
better.

Each one of the 1's and 0's in the binary numbers is what we call a bit. A group of four is a
nibble and a group of eight is a byte. Other groupings are called words and they can be of
many different lengths. Arduino's ADC represents the data readings in words of 10 bits. As
you see in the table, with 10 bits the maximum number we can represent is 1023.

The use of the same type of symbols to represent numbers as in the human language, can
be misunderstood. This is why when writing binary numbers we usually write all the
zeroes on the left hand side. E.g. in a 10 bits number, the decimal 3 would be the binary
0000000011.

You might also like