I built an automatic bike light for GCSE electronics.
However, as far as I am aware, automatic lights are not popular for one reason, and that is if the battery is dead or the light is faulty you will not know until it is dark when you are cycling, and by then it is too late.