Code that works - It differentiates "0" from any other command:

Code:
UIDEDA:

if pulsi=0 then
FOR N=0 TO 300     'main loop duration
IF PULSI=0 THEN
A=A+c                                 'count positive edges
c=0   'stop increasing  1 after first loop
d=1    'set increase for 0
ELSE
B=B+d         'count 0 volt
d=0     'stop increasing 0 after first loop
c=1      'set increase for 1
ENDIF
NEXT
IF A<>0 AND B<>0 THEN
lcdout $FE,2, "A=",#A, "    "
lcdout $FE,$C0,"B=",#B, "    "
ENDIF
if a=7 and b=8 then high natura    'on
if a=6 and b=7 then low natura   'off
A=0
B=0
endif
GOTO UIDEDA