Hi,

you also must add in your program the condition for the led to be off ...

as outputs are bistable kind ... they will stay on the last programmed state, otherwise stated ...

Alain