sonicdeejay
Joined: 20 Dec 2005 Posts: 112
|
|
Posted: Sat Jan 14, 2006 1:30 am |
|
|
Guys,,,I can make it works...thanks for help...
Code: |
#include<16f877a.h>
#fuses HS,NOLVP,NOWDT,PUT
#use delay(clock=20000000)
#use rs232(baud=9600,xmit=PIN_C6,rcv=PIN_C7)
void main() {
int i, value, min, max;
printf("Sampling:");
setup_adc_ports( RA0_ANALOG );
setup_adc( ADC_CLOCK_INTERNAL );
set_adc_channel( 0 );
do { //Takes 30 samples from pin A0
min = 255; //and displays the min and max
max = 0; //values for that 100ms period
for(i = 0; i <= 30; ++i) {
delay_ms(100);
value = read_adc();
if(value < min)
min = value;
if(value > max)
max = value;
}
printf("\n\rMin:%x MAX: %x", min, max);
} while (TRUE);
} |
The above ADC sample show that it reads "Input" from Port A0, calculates max, min etc and display via RS232....
|
|