Hi, I have been experimenting with the analogRead() function trying to determine whether a sensor is plugged in or not. If I call analogRead(0) when there is no sensor plugged in to port A0, analogRead(0) still returns a value.
Is there any way to determine whether or not a sensor is plugged in to a specific port?
Hi Dan,
Unfortunately there is no way to find which sensor is connected to which pin through the software. This is because most sensors are connected via Digital or analog pins and you cannot differentiate them on the basis of the data coming in (Refer to http://arduino.cc/en/Reference/analogRead and http://arduino.cc/en/Reference/digitalRead). It might be possible to detect I2C sensors such as accelerometers.