one more thing, (just to make it a bit simpler, base this on button examle) when the button pin goes low there would be a delay of upto 30seconds before the LED goes low, but if the button is only on for a period of 10seconds then the LED will only stay on after the button goes low for 10seconds. hope you understand what i mean there
also the delay time needs to be without a delay like the example blink without delay.
thanks joe