Changing variable value depending onsensor.

i have made an infrared counter. when the sensor is blocked x =0 . when sensor isnt blocked x=1 .
how can i use this info to increase a variable called "number" by 1 when x goes from 1 to 0 and to 1 again without distrubing other program. by other program means i display the number on 7 segments.

This should help: https://www.arduino.cc/en/Reference/If

if (blocked x =0) number ++;
if (blocked x =1) number ++;

johnnygueggu:
This should help: https://www.arduino.cc/en/Reference/If

if (blocked x =0) number ++;
if (blocked x =1) number ++;

That is not sufficient. The approach suggested by @Delta_G is required.

...R