Hi all,
I am trying to interface pic to pic via uart. i have created code so that when the pushbutton is pressed, the pic would send signal to the other pic and turn the led but its not working. i have tried using the rf modules but i have heard that in order to make it easy. i must just connec the tx with the rx and its good to go.
im using pic16f877a and programming on mikroc
here is the transmitter code:
this is recieved code:
Moderator edit: added code tags
I am trying to interface pic to pic via uart. i have created code so that when the pushbutton is pressed, the pic would send signal to the other pic and turn the led but its not working. i have tried using the rf modules but i have heard that in order to make it easy. i must just connec the tx with the rx and its good to go.
im using pic16f877a and programming on mikroc
here is the transmitter code:
Code:
void main() {
char txt = 'A';
TRISA.F0 = 1;
PORTA.F0 = 0;
UART1_Init(2400);
Delay_ms(200);
while (1){
if(PORTA.F0 == 1){
delay_ms(100);
if (UART1_Tx_Idle() == 1) {
UART1_Write('A');
}
}
}
}
Code:
void main() {
char output;
TRISB.F0 = 0;
PORTB.F0 = 0;
UART1_Init(2400);
Delay_ms(200);
while (1){
if (UART1_Data_Ready() == 1) { // if data is received
output = UART1_Read();
if (output == 'A'){
PORTB.F0 = 1;
}
}
}
}