Devide 12v square wave signal and output 5v squarewave

You're still missing the digitalRead