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
We recommend EasyEDA for electronic circuit design.
From Schematic Drawing to PCB Production, Just Need One Tool
Cheap PCB Prototype: 10 pcs 2 layers only $10, quick delivery, 100% E-test
Current Project / Post can also be found using:
- PIC16F88 dtmf code and Proteus simulation
- adc proteus sample
- adc driver for pic pic16f877a
- c program to build ADC simulation using pic 16f877a