Although, i haven't tested codes practically, the enclosed IR Tx and Rx O8M codes might do the trick. For just one shot application, you may remove the STAY_ON and STAY_OFF subroutines.
If button is depressed for less than 3S, a 1 will be transmitted to turn on LED on Receiver and if still depressed after 3s or release, a zero will be transmitted to turn off LED in Receiver.
IR Transmitter:
Code:
Symbol Switch_OFF = b0
Symbol Switch_ON = b1
Symbol Counter = b2
Let Counter = 0
Let Switch_OFF = 0
Let Switch_ON = 1
Main:
toggle 0
if pin1 = 1 then: gosub Transmit endif; read input pin1 when push button is depressed (u have to connect pin1 to Vcc via a 4k7 pull up resistor)
debug
goto main
Transmit:
Let Counter=0;Let Counter=0 ;initialize counter after loop is over
do while Counter<5 ;process loop as long as b0 value is less than 3
inc Counter; increase b0 by 1
wait 1
if Counter<3 then: gosub Transmit_1 elseif Counter>3 then gosub Transmit_0 endif
loop ;repeat do condition
return ;return from this subroutine to stack
Transmit_1:
high 0
serout 0, T2400,("PRESS",#Switch_ON)
pause 50
return
Transmit_0:
low 1
serout 0, T2400, ("PRESS",#Switch_OFF)
return
IR Receiver:
Code:
Symbol Power_OFF = b0
Symbol Power_ON = b1
Symbol Request = b2
Let Power_OFF =0
Let Power_ON = 1
Transmit:
toggle 1
serin 3,T2400,("PRESS"),Request
if Request=1 then: gosub Transmit_1 elseif Request=0 then gosub Transmit_0 endif
debug
goto Transmit
Transmit_1:
high 1; If LED is connectted to pin 1, it will light
wait 1; adjust delay for how long you want it high
if Request=1 then: gosub Stay_ON endif
return
Transmit_0:
low 1; turn LED off
wait 1; adjust delay for how long you want it high
if Request=0 then: gosub Stay_OFF endif
return
Stay_ON:
high 1
return
Stay_OFF:
low 1
return
If the enclosed TX and Rx codes doesn't do what you wanted (from my understandings, you want the receiver 08M chip outpin to stay on all the time upon receiving a high instruction (logic 1) from the TX and vice versa) then play around with the code a bit.
And if that doesn't still, consider using a 20x2 or 18M2 chips that support latch actions or google and invest in a Latch chip or Flip-Flip IC. If done properly both code wise and hardware connections, it should work all the time.
Tip: Connect the output pin of the Rx Picaxe to the input of the Latch device and the output from the Latch device will acts based on the input pin transition. (i.e if input pin is high, output will stay high (thus high latch) and vice versa). If input pin is low, output will stay low (thus low latch) as hence flip-flop. Note, Latch and Flip-flop devices does the same things but operate differently. You may google for detail operations if interested.
You're welcome for further questions.