I am sorry that changing the pins did not work out for you.
With the requirements that you have posted and the bit that I have had to glean from the code that you posted and with few decisions to make, this code should practically write itself.
Unfortunately, I have some other priorities that I must attend to, so it may be about two days before I get back to this. I hope to try at that time.