Analog to Digital Conversion(ADC) with Arduino

Analog to Digital Conversion(ADC) is a very useful feature in microcontrollers to interface sensors. The main purpose of this features is to interface analog sensor with the Arduino UNO or any microcontroller. There are different physical quantities in nature like pressure, temperature, humidity and light intensity etc. Sometimes we develop the system that using these properties. While working on this property we first convert it in the digital so microcontroller can understand. For doing this we need Analog to Digital Conversion. Arduino UNO has 6 ADC channel from A0 to A5. For enabling this ADC feature we use the function analogRead().

Arduino UNO has 10-bit(210) ADC. Whatever analog value from 0-5V it reads it converts in the range from 0 to 1023 in digital. Based on this digital value we do some programming code and controlling the devices accordingly.

For the ADC interfacing we are connecting one preset to the analog pin A0, read the ADC value and display to the serial monitor.

Hardware Required

  • Arduino UNO
  • Preset
  • Breadboard

Arduino Analog to Digital Conversion

Here we are connecting a preset to the arduino uno analog pin A0. Preset has a three-terminal one is connected to Vcc second to the GND and middle pin to the analog pin A0.

Arduino A to D Conversion Circuit using Preset

Arduino ADC Code using Potentiometer

We are using the function foranalogRead(A0) converting any analog value to digital. Instead of using preset we can use any sensor here. If input voltage from the sensor is from 0-5V then after conversion value will be from 0-1023.

/*  In this program we are reading the analog value from
  analog pin A0 converting it and send/print it to the serial monitor.   
 Connection:
 Center Pin of Preset : Arduino Analog Pin A0 >
 Outside Pin : Vcc/+5V >
 Outside Pin : GND 
*/

void setup() {
  int ADCvalue = 0;
  // initialize serial communication at 9600 baud rate
  Serial.begin(9600);
}
void loop() {
  // Read the analog value from pin A0
  int ADCvalue = analogRead(A0);
  // print the value at serial monitor
  Serial.println(ADCvalue);
  delay(100);       // delay in between reads for stability
}