char input[20];volatile bit rx_event;void interrupt(){if(PIR1.RCIF){
UART1_Read_Text(input,"\r",20);
rx_event=1;}}void main(){short Start_up=0;short i;
OSCCON.b6=1;
OSCCON.b5=1;
OSCCON.b4=0;
OSCCON.b1=1;
UART1_Init(38400);
ANSELH.ANS11=0;
IOCB.IOCB7=0;
TRISB.TRISB7=0;
TRISB.TRISB5=1;
Soft_UART_Init(&PORTC,7,6,38400,0);
INTCON.PEIE=1;//peripheral interrupt enable
PIE1.RCIE=1;//Receive char Interrupt Enable bit
PIR1.RCIF=0;//Receive char Interrupt flag- reset to 0
INTCON.GIE=1;//global interrupt enable
rx_event=0;//initialize rx_evnet to = 0
delay_ms(1000);//wait one sec for the stamp to stabilizeif(Start_up==0){//when the program firsts starts it willfor(I =1; I<=3;i++){//flash on / off the stamps led
uart1_write_text("L0");//"L0" = led's off
uart1_write(13);//<CR>
delay_ms(1000);//wait one sec
uart1_write_text("L1");//"L1" = led's on
uart1_write(13);//<CR>
delay_ms(1000);//wait one sec}
Start_up =1;//by setting Start_up to 1, we stop the leds from flashing on/off}
delay_ms(1000);//wait one sec for the stamp to stabilize after the led flashing
uart1_write_text("c");//the command "c" will tell the stamp to take continues readings
uart1_write(13);//<CR>
delay_ms(500);while(1){short len=0;if(rx_event){
rx_event=0;
len =strlen(input);for(i=0;i<len;i++){
Soft_UART_Write(input[i]);}
Soft_UART_Write(13);}}}