I am using LM324 as comparator. I wanted to make output voltage 5V when I receive signal greater than 4V but in fact I just got 3,7 V. My Vcc is 5 V. Whats the problem?
A LM339 comparator is a better choice usually. You
might add a pullup resistor to give you higher VOH
from the op amp (same as you'd need for the '339).
The answer is in the circuit. If you don't see it, just try. When pulling the output voltage above regular Vcc-1.1V saturation level, you are working against a 50 µA current source.