How to automatically recognize if sensor is attached ?

Hi everyone, I am working on a project that needs multiple digital sensors and I faced a problem related to auto-detection if a sensor is attached to digital pins.
For example: Let suppose there are 3 connected sensors, When I want to connect the fourth one, I want the Arduino to recognize automatically the insertion of the fourth sensors and count up the number of attached sensors. My sensor has 2 input: Vcc, Ground and 1 output: Vout.
it's a touch sensor, I am working with Arduino Uno.
Please if anyone has an idea don't hesitate to help me!
Thanks in advance.

If you are using a digital sensor with a push pull output, run a wire from the digital pin to an analogue pin that is biased to half the supply voltage using a pair of 100k resistors.
With nothing connected, the analogue pin will see a voltage that is about half the supply voltage. With the sensor connected you will see a voltage that is at least 0.5v higher or lower.

My guess is that your supervisor expected you to figure this out on your own, so:

  1. Draw a picture showing how the resistors and sensor are connected to the Arduino.
  2. Draw a picture showing the plot of voltage vs time as you plug in a sensor.
  3. Explain in words how you calibrate the system.
  4. Write pseudo code showing the algorithm that you use to detect when nothing is connected.

Thanks #mikb55,

I try out what you proposed but it fails. Actually, I realize that the output of the sensor is analog, does this is the reason why it failed?