Hi.
This is the main loop, in PIC Basic Pro:
While true
PORTB = 0x01 ' Led ON
if (led=1) then
Delay_ms(100) 'The led will stay ON for 100ms
end if
PORTB = 0x02 ' Led OFF
if (led=0) then
Delay_ms(100)
end if
TRISB.1 = 1 ' PORTB.1 as input
while (PORTB.1=1)
ti = ti + 1
wend
TRISB.1 = 0 ' PORTB.1 as output
if (ti>1700) then
led=1 ' Turns LED on
else
led=0 ' Turns LED off
end if
Delay_ms(4)
wend
With this count limit (1700) I use a 1k Resistor in the led's anode.
My led is a high brilliant white led.
I'm going to test with different values for the resistor and the count limit.
Thanks