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

Hello ,

I'm having problems to write a program for my Parking prototype to show the number of free parking available;

  1. There are 10 IR Obstacle sensors, 10 RG LEDs and a 4 digit 7 segment display

2.The sensors are positions at each parking slot (10 parking) see in picture attached

3.As a car enters the slot the LEDs turn from GREEN to RED indicating parking slot is not available. As a car leave the slot the LED turn from RED to GREEN indicating it is available.

  1. Using : Arduino MEGA : sensor : IR Obstacle sensor FC-51 LED : RG LEDs

My problem is that i want to generate a program that indicate number of free parking slots available on a 4 digit segment. That is when parking is empty completely it display 10 and when full completely it displays 0. and when there is two car in the parking it display 8 that is parking available.

Note: LED are working fine when there is presence of a car and when no car.

In attachment : circuit connection for (sensors only) , parking design and programming file.

Can someone help me out for this programming. Thank you

Sketch_1.ino (10.3 KB)