Interesting peice of code - over my head for the moment.

Going back to the pulse following example, here is a piece of code I came up with at about 4am this morning.

Code:
OSCCON = $70 'set internal resonator to 8mhz
DEFINE OSC 8
ADCON0 = %00000001
ADCON1 = %01111100
ADCON2 = %10111110

PORTB = %00000111 
TRISA = %11111111
TRISB = %11110000

loop:
IF PORTA.5 = 0 THEN flash
GOTO loop

FLASH:
PORTB = %00001100          'turns on fets
A = 0                               'resets count to 0

while A <= 5                      'follow status of i/p turn off fets if i/p goes away
PORTB = %00001100           
A = A + 1
IF (PORTA.5 = 1) THen
PORTB = %00000111
WEND
if (A <=4) THEN
GOTO loop
if (A = 5) then                    'if A=5 fets are still on
pauseus 1500                     'set max time for fets to be on
PORTB = %00000111           'turn off fets
IF (PORTA.5 = 0) THEN        'if i/p is still on, wait 2ms then repeat loop
pause 2 
return