How to display on my number of free parking on 4 digit 7segment using IR obstacl

Copy/paste fiasco strikes again. ANY time you feel the need to copy/paste code, STOP. THINK.

Can I create a function, instead. The answer, in your case, is YES. So get rid of 2/3rds of your code. Write a function to determine if a parking space is available, or not. Call that function INSTEAD of replicating the code.

I'll leave it to you to determine what you did wrong with the copy/paste fail.