Use IC LM339
When input voltage is in between the upper threshold voltage an lower threshold voltage the output is always high,
When input voltage crosses any threshold voltage the output becomes (zero ideally )square wave
Always Vut at Inverting terminal an Vlt at Non Inverting terminal
Change the input sine wave voltage to change output