Interfacing 8051 with ADC 0808

In This project 8051(AT89S52) Microcontroller is interfaced with ADC 0808 IC to show the output value of ADC on LCD Screen ,for a given variable input voltage of 5Volts at ADC0808 Channel 0. Its code is written in C language using Keil uvision 4 compiler and circuit simulation is done using Proteus7.7,Using which you can verify this ADC code and can be changed it according to your needs.

In the circuit below, 8 bit data bus of ADC0808 is attached with 8051 on Port 0. And control signals of ADC0808 are attached on Port 2 of 8051 microcontroller. LCD is attached on Port  1, LCD is used here just to show the output value of ADC.


ADC0808 has 8 input channels. You can use any channel for ADC purposes in the code. A potentiometer (i-e variable 10k resistor) is attached on IN1 of ADC0808 just to demonstrate how to use this code. Input voltage at IN1 is read in the code and displayed on the LCD. Since, ADC0808 gives an output of 8bit value, so a voltage value of 0v at IN1 will mean ADC value of 0 and a voltage of 5v at IN1 pin means ADC value of 255. In the above figure, it is clear that a when voltage of 2.5v is applied on IN1 pin and ADC value of 127 (i-e half of 255) is displayed on the LCD correctly.

A crystal of 12MHz value is used in this circuit, which makes this 8051 (i-e AT89C51) run at a speed of 1MIPS (Million of instructions per second). You can use any other value of crystal ( From 3 to 24 MHz value only) with 8051 as well.



In the main function, firstly pins attached with ADC0808 are initialized using InitADC(); statement, then LCD is initialized using InitLCD() function. Then “Starting…” is displayed on the LCD for one second. After that LCD screen is cleared.

In the while(1) loop, ADC_Value = ReadADC(AN1); statement reads value from IN1 pin of ADC0808 and assigns this value to ADC_Value variable. Next 3 statements are converting ADC_Value in to digits, which will be displayed on the LCD screen. After that, LCD screen is cleared and ADC value is displayed on the LCD.

The code was compiled in Keil micro-vision4(Portable) and simulation was made in Proteus v7.7 


Comments are closed