Global variable won't update inside void loop arduino
Here is my code


your code ran without setup()?

you are conditionally incrementing "x", and if your condition doesn't hold true, the increment doesn't take place.