what input pin is it using?

You started with a sketch that did more or less what you wanted, in a fairly simple way - no messing with hardware registers and so on.

Why have you thrown that away and started again with a more complex approach?