# How to use ADC In Arduino Tutorial

Posted on

ADC Arduino Tutorial – Analog Digital Converter (ADC) is the processes of converting electrical voltage into digital values. The functions of this ADC range from measuring the voltage and displaying it to the LCD, as an Audio recorder, as an interpreter of Analog signals, Rotary encoders and so on.

The precision of an ADC conversion is indicated by resolution. For example, an 8-bit ADC can divide the voltage from 0-5Volt into a value of 0-255. How this happens, consider the following calculation:

```11111111 = (1 × 2⁷) + (1 × 2⁶) + (1 × 2⁵) + (1 × 2⁴) + (1 × 2³) + (1 × 2²) + (1 × 2¹) + (1 × 2⁰) = 255

```

When given a voltage of 0-5volt, the voltage value will be convert into ADC values ​​from 0-255. The higher the resolution of the ADC, the more accurate the results of the readings obtained. At present Texas Instrument has issued an ADC component with a 32-bit solution, meaning that if given a voltage of 0-5volt, the voltage value will be convert in the ADC value from 0 – 4,294,967,295. Very accurate right? What about Arduino, what is the resolution of the ADC?

Arduino has an ADC with 10-bit resolution, meaning that if given a voltage of 0-5V, then the value to be obtained from the ADC is 0-1023. In other words, 5V / 1024 is 0.004Volt per sample. How do we read the voltage and display it with digital data? In this tutorial an example is to read the ADC voltage using a Potentiometer. By adc arduino tutorial look at the following picture:

Program:

```int adc = 0;

void setup()
{
Serial.begin(9600);
}

void loop()
{
}

```
After the above program has been uploaded to Arduino, open the serial monitor and please rotate the potentiometer. You can see the following values:

If you try the program above, the ADC results will be obtained, where the final value sometimes changes like 515, 516, 517, 515, 517 and so on. How do we make this change not too happen? The answer is with the smooting technique. So, the program will be made to read the ADC value for 10 times and from 10 times it will be taken on average. The program is as follows:

```int adc = 0;
int numArray = 0;
int value = 0;

void setup(){
Serial.begin(9600);
}

void loop(){
numArray = numArray + 1;