Traffic Light with ultrasonic sensor

These are called arrays. They let you shrink code by grouping like variables under a single name and access them by number.

So the same function or loop can serve them all, no need to have a special code for each one,

I remember ultrasonic sensor on traffic lights from test sites in the 70's. They never got wide use, just trials. By the 80's and since it's all magnetic detection. Are you about reinvent the square wheel?