
Parallax, Inc. • IR Buddy Demo Kit (#28016) • 11/2002
Page 6
IR Buddy Application: RC-5 Reception and Display
This application demonstrates the reception and decoding of RC-5 key codes from a (Philips or
compatible) consumer electronics remote control. It is useful for mapping key values from the remote for
use in control projects.
The program puts the IR Buddy into RC-5 receive mode then retrieves buffered key codes for display.
Note that the program checks for and indicates End-of-Buffer and Repeated Key values. A
PAUSE
value
of 1000 milliseconds between IR Buddy access requests simulates normal program activity and will
demonstrate the IR Buddy's ability to buffer multiple key code data.
Connect the IR Buddy to the BASIC Stamp as shown if Figure 1.
' -----[ Title ]----------------------------------------------------------------
'
' IRB RC-5 Monitor.BS2
' {$STAMP BS2}
' -----[ I/O Definitions ]------------------------------------------------------
IRbSIO CON 15 ' IR Buddy serial I/O
' -----[ Constants ]------------------------------------------------------------
IRbRc5Rx CON $72 ' RC-5 protocol RX
IRb96 CON 84 + $8000 ' 9600 baud, open
IRb48 CON 188 + $8000 ' 4800 baud, open
IRb24 CON 396 + $8000 ' 2400 baud, open
IRbBaud CON IRb96
KeyRpt CON 253 ' repeated key
BufEnd CON 254 ' end of buffer
CrsrXY CON 2 ' DEBUG position command
ClrEOL CON 11 ' Clear DEBUG line to right
' -----[ Variables ]------------------------------------------------------------
buffer VAR Byte(8) ' RC-5 RX buffer
idx VAR Byte ' loop counter
' -----[ Initialization ]-------------------------------------------------------
Setup:
GOSUB IR_Buddy_Reset
PAUSE 250 ' let DEBUG window open
DEBUG CLS
DEBUG "IR Buddy RC-5 RX Monitor", CR
DEBUG "------------------------", CR
DEBUG CR
FOR idx = 0 TO 3