Unexpected 2v on LM741 output
A LM741 is not suitable for use with 5V supply.

It is not rail-to-rail input or output, you are violating many of its requirements. You need to provide it with both a negative and positive supply to operate as shown. 

A single supply device such as LM358 will work better but even then the output will not go to 5V and it also is not rail-to rail input so will not function with the input tie to its own positive supply rail.

As mentioned in the comments, a better solution would be a comparator. the LM393 would be a good fit for this task. It would also need a slightly different circuit with the reference input fed from a voltage within the common mode range (ie not the positive supply rail). As simple divider from the 5V rail would suffice.