How to do this task?

This may be working for now, but it contains a lot of magic numbers and it won't scale well when you put in 3 extra LEDs. Consider refactoring it.