As was mentioned in your other (cross) post, no one is likely to give you code for this. We will gladly help you to write the code. We will gladly help you with the hardware. But the work has to be done by you.
Post your attempt at the code. Please read the forum guidelines to see how to properly post code and some information on making a good post.
Use the IDE autoformat tool (ctrl-t or Tools, Auto format) before posting code in a code block.
Post a schematic or wiring diagram. Hand drawn, photographed and posted is fine. Include all pin names/numbers, components, their part numbers and/or values and power supplies.
Post technical data for the components. Data sheets or manuals.
With the proper information and some work from you, we can get your project to work.