Have you checked with Google to see what others have done?
It would help us to help you if you would describe the problems that you are having.
Provide links to any libraries that you use that are not included with the IDE.
If there was one code that came close, post that code. Please format the code with the IDE autoformat tool (ctrl-t or Tools, Auto format) before posting code in a code block.
Please read the how to get the most from the forum post. The post contains information on what we need to know in order to help you.
A schematic of your wiring can be helpful.