PIC16F877 ADC code and Proteus simulation

This post provides the ADC code using PIC16F877 microcontroller. This code is written in C language using MPLAB with HI-TECH C compiler. You can download this code from the ‘Downloads‘ section at the bottom of this page.


It is assumed that you know how to interface LCD with PIC16F877 microcontroller. If you don’t then please read this page first, before proceeding with this article.

The result of simulating the code in Proteus is shown below.

PIC16F877 ADC code and Proteus simulation schematic

In the above figure, pin10(AN7) of PIC16F877 is being used as ADC input pin[1]. The result of ADC conversion is shown on the LCD screen. If you attach pin10 of PIC16F877 to ground, then a value of 0000 will be displayed on the LCD screen and if you attach pin10 with 5v power supply, then a value of 1023 will be displayed on the LCD screen. In other words, ADC resolution is 10bits and value of ADC result varies from 0(0v) to 1023(5v). Because there is a variable resistor of 50% value attached on pin10 of PIC16F877 in Figure1, that is why it has 2.5v on it. As a result, a value of 511(Half of 1023) is being displayed on the LCD.


The main function code is shown below.


ADC code using PIC16F877 was compiled in MPLAB v8.85 with HI-TECH C v9.83 compiler and simulation was made in Proteus v7.10. To download code and Proteus simulation click here.


For more detail: PIC16F877 ADC code and Proteus simulation

JLCPCB – Prototype 10 PCBs for $2 + 2 days Lead Time
China’s Largest PCB Prototype Enterprise, 300,000+ Customers & 10,000+ Online Orders Per Day
Inside a huge PCB factory: https://www.youtube.com/watch?v=_XCznQFV-Mw

READ  Interfacing DS1307 to PIC Microcontroller with C code and Circuit Diagram

Current Project / Post can also be found using:

  • temperature sensor with pic16f877a with hi tech c code pdf
  • pic16f877a lcd mikroc code pdf
  • simulation pic 16F88 protéus
  • adc interfacing with pic16f877a using ptoteus

Leave a Comment

= 5 + 0

Read previous post:
PIC16F877 stop watch
PIC16F877 stop watch code and Proteus simulation

This PIC16F877 microcontroller tutorial answers the question, " How to implement a stop watch using PIC16F877 ? " Using PIC16...

Scroll to top