Search This Blog

Monday, September 27, 2010

Got the IR TV sleep timer setter code working!

Rewrote my code using the libraries from this blog:
http://www.arcfn.com/2009/08/multi-protocol-infrared-remote-library.html

After a little stumble with a == instead of a =, i got the first version running.  Now the IR
receiver doesn't block the code execution and I can run a timer marking when the last IR event
happened.  Also this code seems to see just about any IR activity, not just the Sony.

Feel bad that i haven't taken the time to understand what he did, just borrowed it.

This guy has also a bunch of stuff on IR remotes and interrupts too, didn't use it but wanted to note it.
http://minkbot.blogspot.com/2009/08/arduino-ir-receiver-with-interrupts.html

I wrote the code as a simple state machine (my background as a RTL designer is showing).  There are three states.  TV_OFF, TV_ON, DROWSY.    It stays in TV_OFF unless the IR activity sends it to TV_ON.  It starts a timer and kicks back to TV_ON every time the IR remote is detected.  If the timer times out without any IR activity, it moves to DROWSY.  DROWSY sends the sleep command to the TV and starts a timer.  If the timer expires, it assumes the TV sleep timer turned off the TV and goes to TV_OFF.  Any IR activity moves you back to TV_ON.  DROWSY state isn't absolutely necessary, but it prevents sending sleep again too soon and extending the sleep timer time.

Now to clean up the hardware in a more permanent form and write it up for the next post!

No comments:

Post a Comment