IR Remote control
Hello,
I downloaded code IR_Remote_NewCog.spin, by Tom Doyle. I tried to modified to simple put a message on the terminal. I posted the code. Can someone help?
Thanks,
Curtis
I downloaded code IR_Remote_NewCog.spin, by Tom Doyle. I tried to modified to simple put a message on the terminal. I posted the code. Can someone help?
{{
IR_Remote_NewCog.spin
Tom Doyle
2 March 2007
The IR_Remote.spin object receives and decodes keycodes from a Sony TV remote control.
The procedure to read and decode is run in a separate cog. This eliminates the big problem
of the mainline program hanging while waiting for a key to be pressed. When a keycode is
received it is written into main memory (IRcode) by the cog. See IR_Remote.spin for
more information.
An LED attached to pin 20 is flashed on and off in the main program loop to demonstrate
that is does not hang waiting for someone to press a key on the remote.
A Parallax LCD display is used to display keycode information.
}}
CON
_CLKMODE = XTAL1 + PLL16X ' 80 Mhz clock
_XINFREQ = 5_000_000
IRdetPin = 0 ' IR Receiver - Propeller Pin
BaudRate = 115200
OBJ
ir : "IR_Remote"
pst : "Parallax Serial Terminal Plus"
num : "simple_numbers"
VAR
byte IRcode ' keycode from IR Receiver
PUB Init | freq, index, cog, lcode
pst.Start(BaudRate)
cog := ir.Start(IRdetPin, @IRcode) ' Propeller pin connected to the IR receiver, address of variable
if cog > 0
repeat
If IRcode <> ir#NoNewCode
lcode := IRcode
ir.Start(IRdetPin, @IRcode) ' set up for next code
case lcode
ir#chUp : pst.str(string("Channel Up"))
ir#chDn : pst.str(string("Channel Down"))
ir#volUp : pst.str(string("Volume Up"))
ir#volDn : pst.str(string("Volume Down"))
ir#power : pst.str(string("Power"))
other : pst.str(string("Other Key Pressed"))
waitcnt((clkfreq / 1000) * 30 + cnt)
pst.dec(lcode)
Thanks,
Curtis

Comments
http://obex.parallax.com/object/291
I assume you're not getting any codes displayed in the terminal? (It's usually a good idea to say what results your getting and what results you expect when asking for help.)
Are you using a Sony remote? What receiver are you using? How is it wired?
-- http://obex.parallax.com/object/321
pst.dec(lcode)
So I'm wondering if you are getting anything through Parallax Serial Terminal.
Maybe review the setup and operation of that?
Have you set the port number and baud rate?
CON _CLKMODE = XTAL1 + PLL16X ' 80 Mhz clock _XINFREQ = 5_000_000 IRdetPin = 0 ' IR Receiver - Propeller Pin BaudRate = 115200 OBJ ir : "irtest" pst : "Parallax Serial Terminal Plus" num : "simple_numbers" VAR byte IRcode ' keycode from IR Receiver PUB Init | freq, index, cog, lcode pst.Start(BaudRate) ir.Start(IRdetPin, @IRcode) ' Propeller pin connected to the IR receiver, address of variable repeat pst.char(1) case IRcode ir#chUp : pst.str(string("Channel Up")) ir#chDn : pst.str(string("Channel Down")) ir#volUp : pst.str(string("Volume Up")) ir#volDn : pst.str(string("Volume Down")) ir#power : pst.str(string("Power")) other : pst.str(string("Other Key Pressed")) pst.chars(32, 12) pst.chars(13, 2) pst.dec(IRcode) pst.chars(32, 2) waitcnt((clkfreq / 1000) * 30 + cnt)Something to be aware of, which I didn't know myself until last night when I downloaded and ran Jon's code, is that some Sony remotes send both 12 bit codes and 20 bit codes.
My Sony AM/FM/CD/cassette audio entertainment center has a 25 button remote, and it seems that about 7 of the 25 buttons send 20 bit codes, while the rest only send 12 bit codes.
Yep. Combo remotes, when in DVD mode, will still send 12-bit TV codes when numbers (and some other buttons) are pressed -- probably because DVDs don't use numeric input.