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.
In the above figure, pin10(AN7) of PIC16F877 is being used as ADC input pin. 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
Current Project / Post can also be found using:
- temperature sensor with pic16f877a with hi tech c code pdf
- pic16f877a lcd mikroc code pdf
- display adc value on lcd PROGRAMMING PDF
- pic16f877 adc