Ad Code

Responsive Advertisement

Ticker

6/recent/ticker-posts

ADC Module of Arduino

ADC Module of Arduino

 

Fig: Analog to Digital Conversion


 In this tutorial i will be discussing the ADC module of Arduino UNO. You can also check my previous post on interfacing the Arduino with Relay .

The Arduino has an in-built ADC Module. Analog to Digital Converters are widely used devices for Data acquisition. The physical world is Analog (i.e. Continuous) but Digital Computers use Binary values (i.e. Discrete ) . Physical  quantities such as Temperature, Pressure , Humidity , Velocity etc. are converted to electrical signals (voltage and current) using a device called a transducer. Transducers are also referred to as Sensors. Sensors senses Analog quantities and there is need for an Analogue to Digital converter so that a Microcontroller can process the information gotten from these sensors.

On the Arduino board, these ADC pins have an ‘A’ in front of their label (A0 through A5) to indicate these pins can read analog voltages.

ADCs can vary greatly between microcontroller. The ADC on the Arduino is a 10-bit ADC meaning it has the ability to detect 1,024 (2^10) discrete analog levels. Some microcontrollers have 8-bit ADCs (2^8 = 256 discrete levels) and some have 16-bit ADCs (2^16 = 65,536 discrete levels).

FORMULAR:

since  pow(2,10) = 2^10 = 1024

ADC= (Vin*1024)/Vref

Vin = (Vref/1024)*ADC.

Vref can be 5V depending on you.


The Arduino programming language has a built-in  function called "analogRead()" which is used to read the the value on the ADC pin. To understand more, click here.


In this tutorial we are going to read the analog pin zero (A0) and display the value on an LCD.

you can check out my tutorial on interfacing Arduino with LCD.



CODE:

/*
    Name     : ADC Module of Arduino
    Author   : Daniel Oluwole
                       (C) 2020 Danitronics
                       danieloluwole51@gmail.com, danieloluwole51@yahoo.com
    Mobile:    +234 8188508765.
   
  */

int analogPin = A0;           // potentiometer wiper (middle terminal) connected to analog pin 3

                                         // outside leads to ground and +5V

int val = 0;                        // variable to store the value read


#include <LiquidCrystal.h>


// initialize the library by associating any needed LCD interface pin

// with the arduino pin number it is connected to

const int rs = 12, en = 11, d4 = 5, d5 = 4, d6 = 3, d7 = 2;

LiquidCrystal lcd(rs, en, d4, d5, d6, d7);


void setup() {

          // set up the LCD's number of columns and rows:

  lcd.begin(16, 2);

}


void loop() {

  val = analogRead(analogPin);  // read the input pin

   lcd.setCursor(0,0);

    lcd.print("ADC VAL: ");

     lcd.setCursor(10,0);

  lcd.print(val);    // Print a message to the LCD.

  delay(1000);

}

Post a Comment

0 Comments

Ad Code

Responsive Advertisement