Please go read the forum sticky post, then edit your post above to fix the code tags and add the other stuff anyone would need to be able to help you, such as some links to components and a schematic. You gave all that detail but forgot simple things like what kind of Arduino!