If You format the code and post it i code tags it will be much more easy to read. All according to: How to get the best out of this forum - Using Arduino / Project Guidance - Arduino Forum
Due to the art of the problem You are advised to post schematics especially covering the powering of the build.