check my first code pls

You may want to check the values you are using for analog in.

If you assume a reference of 5V, and 1024 possible analog values, then you get:

value= 1024 * voltage / 5

If you allow around a +/-200mV from those points you get the following value ranges for your if statements:

2V = 408 ----->   368 to 451
3V = 614 ----->   573 to 656
4V = 819 ----->   778 to 860