This is pretty old, but should work if you have a standard 12-bit type Sony IR transmitter. It's one of the simplest routines I have for decoding Sony IR.
It's easy to change to pretty much any I/O-pin you want.Code:DEFINE OSC 4 IR_PULSE VAR BYTE(12) ' IR data received INDEX VAR BYTE ' Index pointer DBYTE VAR BYTE ' IR data received Main: PULSIN PORTC.3,0,IR_PULSE '// Read-in start pulse IF (IR_PULSE < 200) OR (IR_PULSE = 0) THEN Main Verify: '// Read, Decode, then verify data FOR Index = 0 TO 11 '// Setup to read-in 12 pulses PULSIN PORTC.3,0,IR_PULSE[Index] '// Read 12 low-going pulses on C3 NEXT Index '// Loop x times DBYTE = $7F '// Start with all 1's and find each 0 FOR Index = 0 TO 6 '// Get 7 "data" bits IF IR_PULSE[Index] < 100 THEN DBYTE.0[Index]=0 '// Less than 1mS = 0 NEXT Index DBYTE = DBYTE + 1 '// Button code #1 = 0, Button #2 = 1, so add 1 '// for actual button pressed for display HSEROUT ["Button #",#DBYTE," was pressed",13,10] GOTO Main END




Bookmarks