unsigned char uart_rd,i; void main() { TRISB.F0 = 0; UART1_Init(9600); //UART module at 9600 bps Delay_ms(100); // Wait for UART module to stabilize while (1) { // Endless loop if (UART1_Data_Ready()) { // If data is received, uart_rd = UART1_Read(); UART1_Write(uart_rd); } if ( uart_rd == 'x') { PORTB.F0 = 1; //LED Off } if (uart_rd == 'a') { PORTB.F0 = 0; //LED on } } }