ADC in Arduino
ADC in Arduino
Introduction
When we interface sensors to the microcontroller, the output of the sensor many
of the times is analog in nature. But microcontroller processes digital signals.
Hence, we use ADC in between sensor and microcontroller. It converts an analog
signal into digital and gives it to the microcontroller.
There are many applications of ADC like in a biometric application, Environment
monitoring, Gas leakage detection etc.
Arduino Uno has 6 On-board ADC channels which can be used to read analog
signal in the range 0-5V.
It has 10-bit ADC means it will give digital value in the range of 0 – 1023 (2^10).
This is called as resolution which indicates the number of discrete values it can
produce over the range of analog values.
Where,
Vref - The reference voltage is the maximum value that the ADC can convert.
This function is used to read analog value from specified analog pin.
analogReference (type)
This function is used for configuring the reference voltage used for analog input.
void setup() {
Serial.begin(9600);
}
void loop() {
digitalValue = analogRead(sensorPin);// read the value from the analog channel
Note: If nothing is connected to analog input channel then the analogRead () function
return the noisy fluctuating value.
= 2.5 V
void setup() {
Serial.begin(9600);
}
void loop() {
digitalValue = analogRead(sensorPin);// read the value from the analog channel
delay(1000);
}