You are not accurate enough.
What do you mean by LED patterns?
- A single LED that blinks with 16 different patterns (like the tail light of bicycles that you
can by a single press change from OFF / Blink / Continuous?
- A row of LEDs that you want to change with a single press?
- A combination from both?
Supposing your LEDs are connected to an output port via a LED driver,
each bit of the port can lit one led. The lighting pattern of your led row can be described
with a single byte. If we represent one lit LED by * and one off led by -, then, for example:
0 -> --------
1 -> -------*
2 -> ------*-
Etc...
You just have to define your led patterns:
Code:
#define NUM_STATES 16
char Pattern[NUM_STATES] = {
// Enter your predefined patterns
};
Then you create an interrupt function for the button.
And in the interrupt service routine:
Code:
void ButtonISR(void) {
static uint8 index = 0;
index++;
if(index == NUM_STATES) index = 0;
LedPortOut = Pattern[index];
}