I need to turn ON 4 LEDs one by one using switch. If I press switch one time first LED is turn ON and then I want to press switch two times and then I want to turn ON 3rd LED. How can I do this?
The state change detection example shows you how to count the number of times that a switch has become pressed. Seems like just what you want to do.
Please don't double post, it wastes time.
Too many unknown variables.
Do you want only one led on at a time or do you want every possible combination?
One LED at a time; You can easily cycle from OFF, LED1, LED2, LED3 LED4. Just use a counter. When you reach 5 set counter to zero. If you want to go straight to any LED with a single push, double push, triple push and quad push, you need both counter and keep track of interval between pushes. Perhaps a long push to turn all off?
Any possible LED combination; It is 16 combinations, and there I recommend a counter. It is pure binary translation b0000, b0001, b0010... all the way up to b1111. Push to count up, push and hold to step backward.