If you are connecting the receiver CD pin (pin 3) directly to PORTD.2, CD may not go high enough to be seen as HIGH by PORTD.2. That's why the transistor is needed and why you need to monitor /CD (refer to p6 of the PDF specs for the receiver).
Look at the code I referenced earlier in Code Examples for how to encode/transmit and receive/decode a pulse train. It's all you need for this application. It sends two bytes. Both bytes are followed by their complement so some basic error detection is built in. One can be an ID and the other indicate motion or all clear. All clear is sent when motion is followed by a period with no motion plus every hour or so to indicate "all's well".
Bookmarks