check my first code pls

AnalogRead will never return a negative number. If you try and feed -1V into an analog pin you will damage the Arduino.

Secondly, there is always a margin for error with ADC's. The value will not reliably be 1000, for example it may be 997, 999, 1003 - You should allow a range of numbers to be included.

Next, where did 1000 come from? The analogRead value returns a number between 0 and 1023 which represent equal steps between 0v and AREF. If you are using the default reference voltage then 1023=5v, 0=0v, and approximately 204=1v.