need help with programme

Hi,could anyone look at this programme and help me find a code that will allow me to keep the LED flashing until triggered to stop by my IR transmitter.when triggerred the programme will run then stop instead of repeating the programme.
ReceiverLoop:
debug b1
INFRAIN2
pause 1000
high 4
pause 1000
low 4
pause 1000
high 4
pause 1000
low 4
goto ReceiverLoop

thanks !
 

Rickharris

Senior Member
untested

<code><pre><font size=2 face='Courier'>
ReceiverLoop:
INFRAIN2
If infra=x then resetled 'x= number sent to trigger system.
high 4
pause 1000
low 4
pause 1000
goto ReceiverLoop

resetled:
low 4
goto Receiverloop
&lt;/font&gt;&lt;/pre&gt;&lt;/code&gt;



Edited by - rickharris on 04/04/2006 22:14:37 </font></pre></code>
 

hippy

Ex-Staff (retired)
Not easy nor obvious to do because the program will stop in INFRAIN2 until something is received making it hard to run a loop when nothing is being received.

One way is to monitor the IR input pin and branch when any IR is seen then execute an INFRAIN2 to see what was being sent ( relying on the transmitter to send its commands more than once per button push ). This can still lead to program jamming though, but the general idea is ...

- MainLoop:
- IF pin3 = 0 THEN IrReceived
- TOGGLE 4
- PAUSE 1000
- GOTO MainLoop
-
- IrReceived:
- INFRAIN2
- :

One problem with this though is that it only looks for any IR signal once a second so a badly timed or short transmitter button push may get missed. A better solution which checks about every 5mS would be ...

- MainLoop:
- IF pin3 = 0 THEN IrReceived
- PAUSE 5
- b0 = b0 + 1 // 200
- IF b0 &lt;&gt; 0 THEN MainLoop
- TOGGLE 4
- GOTO MainLoop
-
- IrReceived:
- INFRAIN2
- :
 
Hi,RICK HARRIS &amp; Hippy, thanks for your speedy reply and i will try your programmes and will let you know how things go. CHEERS !
 
Top