// Global Variables const unsigned char MSG0[20] = "Trombone.C "; const unsigned char MSG1[20] = "ECE 376 "; // Subroutine Declarations #include // Subroutines #include "lcd_portd.c" unsigned int A2D_Read(unsigned char c) { unsigned int result; unsigned char i; c = c & 0x0F; ADCON0 = (c << 2) + 0x01; // set Channel Select for (i=0; i<10; i++); // wait 2.4us (approx) GODONE = 1; // start the A/D conversion while(GODONE); // wait until complete (approx 8us) return(ADRES); } // Main Routine void main(void) { unsigned int A2D; unsigned int N; unsigned int i; TRISA = 0; TRISB = 0xFF; TRISC = 0; TRISD = 0; TRISE = 0; ADCON1 = 0x0F; // Turn on the LCD display LCD_Init(); // initialize the LCD Wait_ms(10); LCD_Move(0,0); for(i=0; i<20; i++) LCD_Write(MSG0[i]); // Turn on the A/D input TRISA = 0xFF; TRISE = 0x0F; ADCON2 = 0x95; ADCON1 = 0x07; ADCON0 = 0x01; while(1) { A2D = A2D_Read(0); N = 2243 - 1.4809*A2D; if(PORTB) RC0 = !RC0; for(i=0; i