IS this an Arduino programming question ?
If so then please post a complete program rather than snippets.