Mr. @Grumpy_Mike is correct.
In order to help you, we first need to understand the project.
And to understand the project well, we need to understand the code, the schematic,
pictures of the wiring, which Arduino is used and everything else that can be used in the project.
Since the problem with your project may be in a small detail,
and you posted the code, it is important that we understand the schematic used.
Assuming that we can imagine the schematic used, with our experience, we will certainly imagine a correct schematic.
But it seems that this is not the case with your project.
If you read the topic
"How to get the best out of this forum", when you register on the forum, you will find a paragraph that says:
" [Schematics or circuit diagrams](How to get the best out of this forum diagrams) The language of electronics is a schematic or circuit diagram. Long descriptions of what is connected to what are generally useless. like to try either Eagle or KiCad .
More about creating a schematic of your project including how to upload an image. "