Moving the turn off LED statement into an else clause gives the desired
behaviour. Need to now experiment with the delta function to see if we
can tune effectively.