/********************************************* * Author: Chris @ PyroElectro.com * * Description: This firmware is for the receiver * side of the wireless IR communication tutorial * on PyroElectro.com. The USART serial communication * module receives serial data input and depending on * the received ASCII data value, PORTD is output to a * specific value turning on/off LEDs. * * Date: July 25th, 2011 * * For Full Details On This Firmware Please * Visit: http://www.pyroelectro.com/tutorials/wireless_infrared_communication/ *********************************************/ #include #include #include void main(void) { unsigned char input; TRISC = 0xFF; TRISD = 0x00; PORTD = 0x00; OpenUSART( USART_TX_INT_OFF & USART_RX_INT_OFF & USART_ASYNCH_MODE & USART_EIGHT_BIT & USART_CONT_RX & USART_BRGH_HIGH, 25 ); while(1){ Delay1KTCYx(1); input = getcUSART(); switch(input){ case '1' : PORTD = 0x01; break; case '2' : PORTD = 0x03; break; case '3' : PORTD = 0x07; break; case '4' : PORTD = 0x0F; break; case '5' : PORTD = 0x1F; break; case '6' : PORTD = 0x3F; break; case '7' : PORTD = 0x7F; break; case '8' : PORTD = 0xFF; break; case '0' : PORTD = 0x00; break; } } CloseUSART(); }