' ========================================================================= ' ' File....... Doggy_Door_RX.bs2 ' Purpose.... Prototype This: Robo Dog Sitter, Doggy Door RX/Control ' Author..... J. Grand ' ' {$STAMP BS2} ' {$PBASIC 2.5} ' ' ========================================================================= ' -----[ Program Description ]--------------------------------------------- ' ' This program receives an RF signal from the main Robo Dog Sitter circuitry ' and drives two relays depending on if the Doggy Door should open or close. ' Uses Parallax 433.92MHz RF Receiver (#27981). ' -----[ I/O Definitions ]------------------------------------------------- Sys_Ready PIN 0 Relay1_Enable PIN 7 Relay2_Enable PIN 8 RF_Input PIN 15 ' -----[ Constants ]------------------------------------------------------- #SELECT $STAMP #CASE BS2, BS2E, BS2PE T1200 CON 813 T2400 CON 396 T4800 CON 188 T9600 CON 84 T19K2 CON 32 T38K4 CON 6 #CASE BS2SX, BS2P T1200 CON 2063 T2400 CON 1021 T4800 CON 500 T9600 CON 240 T19K2 CON 110 T38K4 CON 45 #ENDSELECT SevenBit CON $2000 Inverted CON $4000 Open CON $8000 RF_Baud CON T2400 ' -----[ Variables ]------------------------------------------------------- cmd VAR BYTE(3) ' -----[ Initialization ]-------------------------------------------------- Init: DEBUG CLS, "Initializing Doggy Door RX/Control System..." LOW Relay1_Enable LOW Relay2_Enable HIGH Sys_Ready DEBUG "Done!", CR ' -----[ Program Code ]---------------------------------------------------- Main: SERIN RF_Input, RF_Baud, [WAIT("!"), STR cmd\3] IF (cmd(2) <> "?") THEN GOTO Main ' if we don't receive the correct footer, then the data transfer is incomplete DEBUG CR, "Doggy Door: Relay 1 " IF (cmd(0) <> 0) THEN HIGH Relay1_Enable DEBUG "CLOSED" ELSE LOW Relay1_Enable DEBUG "OPEN" ENDIF DEBUG ", Relay 2 " IF (cmd(1) <> 0) THEN HIGH Relay2_Enable DEBUG "CLOSED" ELSE LOW Relay2_Enable DEBUG "OPEN" ENDIF DEBUG CR GOTO Main