Might help if we understood the question ?
What exactly are you trying to do ?
the following code might give you a start ?
Assuming that i have your question straight !
The input pin, pin 6 sits and waits for a change of state.
When triggered turns on pin2 and pin4 whilst the input pin is triggered.
Once the input dissapears its waits 4.2 seconds then turns off pin 2 and 4and goes back to monitoring the input.
This is achieved by using an interupt.
You could modify the code to suit your own needs but this should help you on the way.
Best Regards
Neil
Happy New Year !
Code:
Symbol pulsePresent = b0 ' Pulse present flag
SetInt %00000010,%00000010 ' Enable interrupt on Pin6
SetFreq M8 ' Run at 8mhz (fast as possible)
Output 2 ' Pulse present output (pin5)
pulsePresent = 0 ' No pulse seen
Do
Pause 8400 ' Pause for 4.2s 8400 = 4.2 secs at 8mhz
If pulsePresent = 0 Then ' Was pulse seen ?
Low 2 ' No - Clear pulse present output (pin5)
Low 4 ' Output OFF (pin3)
Else
pulsePresent = 0 ' Clear pulse seen
End If
Loop
Interrupt:
pulsePresent = 1 ' Pulse is present
High 2 ' Set pulse present output (pin5)
High 4 ' Output ON (pin3)
SetInt %00000010,%00000010 ' Re-enable interrupt
Return