I designed something similar a few years ago but it never reached the prototyping stage. It used a PIC12F683, you are welcome to the source code if you want it.
My design worked the other way around, the light was turned on by a momentary push-button and while the bike was in motion it ran the light at full brightness in the assumption that a dynamo/generator was keeping the battery topped up and full brightness was best while cycling anyway. If the bike stopped, after a delay (traffic junctions etc) it started to dim the lights in stages using PWM until eventually shutting down altogether. The theory was that it was impossible to leave the bike for more than a few minutes with the lights left on so it preserved the battery while at the same time it gave best brightness when it was needed. Also, when stationary there was a danger that the lack of air flow around the LED would allow it to overheat if left for too long so gradually reducing the LED power protected it.
Brian.