using AXE213 Rf Connect Kit

topicaxe

New Member
I'm using the picaxe AXE213 Rf Connect Kit. To the 08M tx I have two momentary switches. For reference, let's call them 'flap switch' and 'door switch'.
I want the output from the Rx 08M to flash an led on and off continuously after flap switch has been switched ON briefly. At the same time, I want to monitor the 08M
Rx output and stop the flashing if Tx door switch has been switched ON briefly. But I want the led flashing again if flap switch is momentary ON again later.
This software doesn't do the job. Your thoughts on solving this would be appreciated. Thank you from Topicaxe.

observe:
serin 2, N2400, ("xyz"), b1

inputchk:
if b1 = 2 then goto observe ;avoid led flashing; b1 = 1 when flap switch briefly ON
; b1 = 2 when door switch briefly ON
posthere: ;led flashing
high c.2
pause 100
low c.2
pause 400
goto inputchk
 

geoff07

Senior Member
Think 'states' as in finite-state machine. Your states might be:

- last event was flap switch: flash while looking for door switch
- last event was door switch: stop flashing while looking for flap switch.

Code separately, the control flips from one part to the other.
 

topicaxe

New Member
The problem I'm having with the programming is keeping the led flashing and at the same time getting out of that loop to check the serin data. Having the led flashing - instead of being permanently ON - is a preferred choice. Easier to program if no flashing required, or implement flashing using electronics. More detailed programming help appreciated.
 

boriz

Senior Member
This might give you some ideas.

Code:
do
   inc flash_counter
   if flash_counter=0 and led_flash>0 then:toggle led_pin:endif
   'check inputs etc
   'do other stuff
loop
Flash_counter is a byte variable and will overflow back to zero after 255. The LED only toggles once every 256 times around the loop, and only when Led_flash is nonzero.

Similarly, another counter could be used to limit the amount of time that Led_flash is nonzero. Led_flash itself could be used as the counter for this.

With an 08M2, it's simpler. You could have a separate parallel process for flashing the LED.
 
Last edited:

topicaxe

New Member
Using a self-flashing led is a neat way to solve this problem. Trying to do it by programming was a challenge I have had to give up on. Necessary gardening jobs has taken me away from the pc for a while.
Can say right now - still some way to go to the completed reliable project.
 
Top