#include<16f877a.h>
#device ADC = 10 // Need to tell compiler ADC is configured for 10-bit reading
#fuses HS,NOWDT
#use delay(clock=12000000)
#include<stdio.h>
#include<STDLIB.H>
#use standard_io(A)
#use standard_io(B)
#use standard_io(D)
#define PORTB
#DEFINE PORTC
#define PORTA
//byte const digit[]={0xC0,0xF9,0xA4,0xB0,0x99,0x92,0x82,0xF8,0x80,0x90};
//char display[3];
int value;
//unsigned long volt;
//unsigned int value2;
void main(){
set_tris_A(0xFF);
set_tris_B(0X00);
set_tris_D(0x00);
output_b(0);
output_d(0);
setup_comparator(NC_NC_NC_NC);
setup_adc(ADC_CLOCK_INTERNAL);
setup_adc_ports(AN0);
set_adc_channel(0);
setup_vref(FALSE);
setup_ccp1(CCP_PWM);
setup_timer_2(T2_DIV_BY_1, 25, 1);
set_pwm1_duty(volt);
while(TRUE)
{
delay_us(100);
//value=read_adc(); //Not required
read_adc(ADC_START_ONLY);
delay_us(100);
value=read_adc(ADC_READ_ONLY);
volt=(value*5)/1023;
}
}