How to make LED flashing in different states