Wich programing language to learn

You're comparing two analog values, which could fluctuate by some units. If the test is done "fast", you can have flickering.
In fact your 1s delay between each run prevents this from happening even if you haven't any hysteresis

OK, thanks.. I agree that Hysteresis is the right practical approach here, I thought there was some other problem with the basic code construct...