ADC module in PIC16F877A microcontroller and MikroC compiler
In this tutorial we will learn how to working ADC in PIC16F877A. PIC16F77A Microcontroller has 8 channel ADC module. I am use this project analog channel 0.
you can watch the video or read the written tutorial below.
ADC module receive analog voltage. The analog voltage can be (0-5)V. ADC module it convert 10 bit digital value corresponding analog signal. PIC ADC module has software selectable high and low voltage reference input and some combination of VDD , VSS , RA2 & RA3.
Mikro C Pro For Pic provide a ADC library with comfortable working with the ADC module.
Circuit Diagram
Project code
unsigned int adc_result;
void main() {
ADCON1 = 0X80;
TRISA0_bit = 1; // RA0 is analog input
Adc_Init(); // Adc module initialize
TRISB = 0X00; // PORTB is output
PORTB = 0X00; // clear PORTB
while(1){
adc_result = adc_read(0) ; // adc read channel 0
PORTB = adc_result;
delay_ms(100);
}
}
Download free source code
Post Comments