Devide 12v square wave signal and output 5v squarewave

if (gear_in == LOW) {

Yup.