How can I connect an ultrasonic sensor to my Arduino motor driver shield l239D when I don't have any space left?
you might have noticed that there are spaces for analog pins on the shield. All of those are free so you can connect your ultrasonic and IR sensor there. Talking about digital pins, some are free but some are not. So it is better to use the free analog pins instead of bothering about digital pins unless necessary. And your sensors will work fine on those analog pins