#if defined(__PCM__) #include <16f877.h> #fuses HS,NOWDT,NOPROTECT #device ADC=8 #use delay(clock=4000000) #use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7, parity=N) // void main() { short test; int value; port_b_pullups(TRUE); setup_adc_ports (ALL_ANALOG); // set analog inputs setup_adc (ADC_CLOCK_INTERNAL); // sets analog clock to internal test=TRUE; do { printf("For Next? Press N. Anything else Repeats\r\n"); output_high(PIN_B7); delay_ms(60); do { set_adc_channel(0); // test Cd cell A - AN0 delay_us(10); value=read_adc(); printf( "FrontRight = %u \r", value ); } while (getc()!='N'); printf("\r\n"); output_low(PIN_B7); printf("For Next? Press N. Anything else Repeats\r\n"); output_high(PIN_B7); delay_ms(60); do { set_adc_channel(1); // test Cd cell B - AN1 delay_us(10); value=read_adc(); printf( "FrontLeft = %u \r", value ); } while (getc()!='N'); printf("\r\n"); output_low(PIN_B7); printf("For Next? Press N. Anything else Repeats\r\n"); output_high(PIN_B6); delay_ms(60); do { set_adc_channel(2); // test Cd cell 2 - AN2 delay_us(10); value=read_adc(); printf( "SideRight = %u \r", value ); } while (getc()!='N'); printf("\r\n"); output_low(PIN_B6); printf("For Next? Press N. Anything else Repeats\r\n"); output_high(PIN_B5); delay_ms(60); do { set_adc_channel(3); // test Cd cell 3 - AN3 delay_us(10); value=read_adc(); printf( "SideLeft = %u \r", value ); } while (getc()!='N'); printf("\r\n"); output_low(PIN_B5); printf("For Next? Press N. Anything else Repeats\r\n"); output_high(PIN_B3); delay_ms(60); do { set_adc_channel(5); // test Cd cell D - AN5 delay_us(10); value=read_adc(); printf( "BackLeft = %u \r", value ); } while (getc()!='N'); printf("\r\n"); output_low(PIN_B3); printf("For Next? Press N. Anything else Repeats\r\n"); output_high(PIN_B3); delay_ms(60); do { set_adc_channel(7); // test Cd cell F - AN7 delay_us(10); value=read_adc(); printf( "BackCenter Left = %u \r", value ); } while (getc()!='N'); printf("\r\n"); output_low(PIN_B3); printf("For Next? Press N. Anything else Repeats\r\n"); output_high(PIN_B4); delay_ms(60); do { set_adc_channel(7); // test Cd cell F - AN7 delay_us(10); value=read_adc(); printf( "BackCenter Right = %u \r", value ); } while (getc()!='N'); printf("\r\n"); output_low(PIN_B4); printf("For Next? Press N. Anything else Repeats\r\n"); output_high(PIN_B4); delay_ms(60); do { set_adc_channel(6); // test Cd cell E - AN6 delay_us(10); value=read_adc(); printf( "BackRight = %u \r", value ); } while (getc()!='N'); printf("\r\n"); output_low(PIN_B4); printf("\n Press . Press X to quit.\r\n"); if (getc()=='X') test=FALSE; } while (test); }