Interfacing ADC in Arduino Uno

by hIOTron IoT in Circuits > Arduino

6 Views, 0 Favorites, 0 Comments

Interfacing ADC in Arduino Uno

Interfacing ADC with arduino.PNG

Arduino board has six ADC channels. Out of those any one or all of them can be utilized as inputs for analog voltage.

Supplies

Hardware Components

Arduino UNO

Power Supply 5V/3.3V

LCD - 16x2

Capacitor 100 µF

Single Turn Potentiometer- 100k ohms

Capacitor 100 µF

Software Components

Arduino IDE

Working of Project

Interfacing ADC in arduino.jpg

Interfacing LCD with Arduino UNO, we should learn about few things

analogRead(pin);analogReference();analogReadResolution(bits);Here we can provide a maximum input voltage of 5V for ADC conversion at any input channel. As some sensors give voltages from 0-2.5V, with a 5V reference hence we gain minor accuracy. By default, we obtain the maximum board ADC resolution which is near about 10bits.

Now if the above conditions are adjusted to default, we can read the value from ADC of channel ‘0’ by straightly calling the function “analogRead(pin);”, here “pin” appears pin where we connected analog signal. First, we require to allow the header file (‘#include ’), this header file has instructions written in it, which allows the user to connect to an LCD to UNO in 4-bit mode.

Second, we require to tell the board which type of LCD we are utilizing here. Once done with all procedures, all there is remain is to transfer data, the data which requires to be displayed in LCD should be written as “ cd.print("Hello, world!");”.

Run a Program

#include // initialize the library with the numbers of the interface pins LiquidCrystal lcd(8, 9, 10, 11, 12, 13); // REGISTER SELECT PIN,ENABLE PIN,D4 PIN,D5 PIN, D6 PIN, D7 PIN char ADCSHOW[5]; //initializing a character of size 5 for showing the ADC result void setup() { // set up the LCD's number of columns and rows: lcd.begin(16, 2); } void loop() { // set the cursor to column 0, line 1 lcd.print(" Hello"); //print name lcd.setCursor(0, 1); // set the cursor to column 0, line lcd.print("ADC RESULT:"); //print name String ADCVALUE = String(analogRead(A0)); //intailizing a string and storing ADC value in it ADCVALUE.toCharArray(ADCSHOW, 5); // convert the reading to a char array lcd.print(ADCSHOW); //showing character of ADCSHOW lcd.print(" "); lcd.setCursor(0, 0); // set the cursor to column 0, line1 }