May i ask, now i need design 2 circuit , 1 is transmitter and another is receiver.
i used RF-TX-315 and RF-RX-315. when button turn on at tx, LED ,buzzer and USART send address. Rx receive match address and will make LED blinking. Is it my codeword wrong?
Why it cannot function??? i use PIC18F452.
Below is my microc codeword:
For transmitter:
- CODE: SELECT_ALL_CODE
unsigned short i;
void main() {
PORTB = 0;
TRISB = 0x20;
PORTC = 0; // Initialize PORTC
TRISC = 0; // Configure PORTC as output
PORTD = 0;
TRISD = 0;
USART_init(10000); // initialize USART module
// (8 bit, 10000 baud rate, no parity bit...)
while(1)
if (Button(&PORTB,5,1,0) )
{
PORTD = 0x50; // LED and Buzzer turn on
//if (USART_Data_Ready())
//{ // if data is received
i = 0x40;
USART_Write(i); // send data via USART
// }
}
else
{
PORTD = 0x00;
Delay_ms(1000);
}
}
For receiver:
- CODE: SELECT_ALL_CODE
unsigned short i==0x00;
void main() {
PORTC = 0; // Initialize PORTC
TRISC = 0x80; // Configure PORTC as output
PORTD = 0;
TRISD = 0;
Usart_Init(10000);
if (Usart_Data_Ready()) { // If data is received
i = Usart_Read(); // Read the received data
}
if(i==0x40) {
Delay_ms(1000);
PORTD = ~PORTD; // toggle PORTD
}
else
{
PORTD = 0x00;
}
}
Thanks for ur help~~