Proper way to toggle an IR input command?
Posted: Sun Mar 07, 2004 9:40 pm
All right. Trying to get things figured out here.... Got my USB-UIRT up and running, but have a question about a task.
I want to have one button on an IR remote control to run a lamp module with a toggled on/off. (press this button once, light comes on, press same button again, light goes off.)
I think I am getting close with the task, but it just isnt quite right, and there are lots of delays in my task.... there must be a better way.
Ok here is what I have for my task:
Condition: Check for IR code #2 to be received
AND: if lamp.power state = on
Then turn lamp.power state = off
Then : Change IR code to 0
Then : delay 2000ms
Else If: Lamp.power state = off
Then : Change Lamp.Power state = On
Then : Delay 2000ms
Then : change IR code to 0
Sometimes it works, sometimes it cyles through once or twice (on/off/on or vice versa)
Thanks in advance for your help!
I want to have one button on an IR remote control to run a lamp module with a toggled on/off. (press this button once, light comes on, press same button again, light goes off.)
I think I am getting close with the task, but it just isnt quite right, and there are lots of delays in my task.... there must be a better way.
Ok here is what I have for my task:
Condition: Check for IR code #2 to be received
AND: if lamp.power state = on
Then turn lamp.power state = off
Then : Change IR code to 0
Then : delay 2000ms
Else If: Lamp.power state = off
Then : Change Lamp.Power state = On
Then : Delay 2000ms
Then : change IR code to 0
Sometimes it works, sometimes it cyles through once or twice (on/off/on or vice versa)
Thanks in advance for your help!