Working on a routine to make a remote have functionality like the Button command
I am trying to make a IF remote program that acts like the button command. This is for control of a stereo preamp. I want the remote volume control to act like any normal one. A push of less then one second, indexes the digital pot one notch. Holding the control longer will make the digital pot go up one notch every tenth of a second until the key is released.
Before I spend some time doing this, I wonder if someone else has already done this.
Thanks
John
Before I spend some time doing this, I wonder if someone else has already done this.
Thanks
John

Comments
······ DO WHILE IR DECTOR=ACTIVE
·········· CHECK FOR PROPER IR PROTOCOL
·········· ·DECODE IR·PULSE TRAIN ( volume UP or volume DOWN)
····················· IF command =volume UP/DOWN· GOSUB Do_Something
········· LOOP
········Do-Something:
··········· increment or decrement volume accumulator
··········· use acumulator value to set volume
··········· PAUSE to control command decode frequency
··········· wait for IR DETECTOR to become ACTIVE or do someting else (while checking for IR )
··········· RETURN
··· I have implemented a volume control that worked with a VMusic2 module and used the Sony TV IR protocol.· Don't know if this will help.
········
John
'
[noparse][[/noparse] Title ]
' IR for preamp control
' Capture and store button codes sent by a universal remote configured to
' control a SONY TV.
' {$STAMP BS2}
' {$PBASIC 2.5}
'
[noparse][[/noparse] I/O Definitions ]
' SONY TV IR remote declaration - input received from IR detector
IrDet PIN 9
'
[noparse][[/noparse] Variables ]
' SONY TV IR remote variables
irPulse VAR Word
remoteCode VAR Byte
' Button variables
counter VAR Byte
Volume VAR Byte
'
[noparse][[/noparse] Main Routine ]
' Replace this DO...LOOP with your own Code.
' Button setup at startup
LOW 5
FOR counter = 1 TO 127
PULSOUT 6, 1
PAUSE 5
NEXT
Volume = 0
DO
GOSUB Get_Ir_Remote_Code
DEBUG CLS, "Volume = : ", DEC Volume
LOW 5
IF (remoteCode = 19) THEN
PULSOUT 6, 1
PAUSE 20
SELECT volume
CASE 1 TO 127
volume = volume - 1
ENDSELECT
ELSEIF (remoteCode = 18) THEN
HIGH 5
PULSOUT 6, 1
SELECT volume
CASE 0 TO 126
volume = volume + 1
ENDSELECT
PAUSE 20
ELSE
PAUSE 100
ENDIF
LOOP
'
[noparse][[/noparse] Subroutine - Get_Ir_Remote_Code ]
' SONY TV IR remote subroutine loads the remote code into the
' remoteCode variable.
Get_Ir_Remote_Code:
remoteCode = 0 ' Clear all bits in remoteCode
' Wait for resting state between messages to end.
DO
RCTIME IrDet, 1, irPulse
LOOP UNTIL irPulse > 1000
' Measure start pulse. If out of range, then retry at Get_Ir_Remote_Code.
RCTIME 9, 0, irPulse
IF irPulse > 1125 OR irPulse < 675 THEN GOTO Get_Ir_Remote_Code
' Get data bit pulses.
RCTIME IrDet, 0, irPulse ' Measure pulse
IF irPulse > 300 THEN remoteCode.BIT0 = 1 ' Set (or leave clear) bit-0
RCTIME IrDet, 0, irPulse ' Measure next pulse
IF irPulse > 300 THEN remoteCode.BIT1 = 1 ' Set (or leave clear) bit-1
RCTIME IrDet, 0, irPulse ' etc
IF irPulse > 300 THEN remoteCode.BIT2 = 1
RCTIME IrDet, 0, irPulse
IF irPulse > 300 THEN remoteCode.BIT3 = 1
RCTIME IrDet, 0, irPulse
IF irPulse > 300 THEN remoteCode.BIT4 = 1
RCTIME IrDet, 0, irPulse
IF irPulse > 300 THEN remoteCode.BIT5 = 1
RCTIME IrDet, 0, irPulse
IF irPulse > 300 THEN remoteCode.BIT6 = 1
RETURN