using keypad codes sequence

hi i have a question about keypad code sequences, how do i write a sequence code for keypad. as in if i key in 201 and press # key the arduino will turn on say output pin 2 and if i key in 004 and press # key it will turn on pins 5 and 6

That very much depends on the keypad your using. If it's just a simple keypad where every key is an individual digital output you can wire each individual key to your arduino's digital inputs. Unfortunately a lot of keyboards and keypads today are not wired like this, so it is very likely you will have to research your particular keypad.

yes its a simple keypad like you say. but im interested in how to write the sequence code instead of just making each key turn on and output, i want to have a code for a certain out eg., 001# or 358#. any help?

Are you using the Keypad library? If not, why not? If so, what have you accomplished?

Collecting the chars that correspond to the keys pressed is simple. A char array and an index are all you need. Store a char, and increment the index. One key should be the enter key, which doesn’t get stored, and one should be a clear key that resets index.

After each index change, store a NULL at the location pointed to by index. Make sure that the array is large enough to hold the NULL, too.