IR help

I have a simple IR receiver that operates output c.2. The circuit below works to either toggle or flash an output depending on which button is pressed.

The response to "0" is always the flashing routine that is correct, and only "0" operates this routine.
"96" should toggle the output which it does, but lots of other buttons also toggle the output. Watching b1 on the debug different values, 5, 17, 33 etc all toggle the output when I wanted just "96" to work it.

Can you see what is wrong in the program to make it so free and easy with its toggling?

main:        '08m2 switches relay on/off THEATRE button on remote (96)

'pin 1 = out, 2 = 5v 3= 0v. look at RX left pin is 1
irin c.1, b1    'IR connected to c.1 with 4.7k to +. number stored in B1
pause 400    ' to make press more stable


if b1 = 96 then goto switchs  'toggle c.2 led & relay

if b1 = 0 then goto flash

switchs:    'latch led and relay at press of theatre
toggle c.2
goto main

flash:        ' flash led relay on button 0
for b2 = 1 to 5

    high c.2
    pause 500
    low c.2
    pause 500
next b2

goto main


Senior Member

If b0 is neither 0 nor 96, then the program "Falls Through" both IF instructions into switchs: which executes the toggle. You probanly want another "Goto main" in the line before the switchs: label.

Cheers, Alan.