Have you tried printing the value of x ?
It will be incremented each time through loop() not each time the sensor is triggered
You need to detect when the sensor becomes triggered not when it is triggered
Have you tried printing the value of x ?
It will be incremented each time through loop() not each time the sensor is triggered
You need to detect when the sensor becomes triggered not when it is triggered