I have hall sensors connected to an arduino, because of mechanical movements there is some possibility that the input wire may accidentally slip out of the arduino analogin sockets. Is there any way I can detect if the wire is still connected to hall sensor ? I don't want to solder the cables yet.
-
1Schematic and datasheet where?Ignacio Vazquez-Abrams– Ignacio Vazquez-Abrams2017年03月14日 20:45:49 +00:00Commented Mar 14, 2017 at 20:45
-
if the read values don't make sense, or fluctuate wildly, they've become unplugged.dandavis– dandavis2017年03月14日 21:18:52 +00:00Commented Mar 14, 2017 at 21:18
-
Solder the cables to headers so they don't slip out?Majenko– Majenko2017年03月14日 22:17:24 +00:00Commented Mar 14, 2017 at 22:17
1 Answer 1
You can maybe try to see if the value on analog pins when sensors are connected (while not sensing anything) is different when not connected.
Depending on your sensors and schematic, if analog input is fluctuating, you can use this command to use pull resistor to avoid this fluctuation.
digitalWrite(Ax, INPUT_PULLUP);
If the above gets true, then you can set up a threshold for detection. Below or beside threshold value, sensor is unplugged.
Otherwise, use some vinyl duct tape.... this would securize the thing a bit!
-
2are you mixing up
pinMode
constants anddigitalWrite
, or is this a secret?dandavis– dandavis2017年03月15日 05:28:29 +00:00Commented Mar 15, 2017 at 5:28 -
-
1Either use
pinMode(Ax, INPUT_PULLUP);
ordigitalWrite(Ax, HIGH);
. It will work either way, but it's no good programming practice.Gerben– Gerben2017年03月15日 10:15:41 +00:00Commented Mar 15, 2017 at 10:15 -
What would be the best programming practice to enable an input pull-up on arduino? Other than accessing the proper register directly?SMFSW– SMFSW2017年03月15日 10:33:21 +00:00Commented Mar 15, 2017 at 10:33