I really hope I can get guidance in the code
Then post ALL the code, using code tags.
And where is that wiring diagram?