0

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.

Naho
  • 39
  • 6

1 Answers1

2

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!

SMFSW
  • 367
  • 2
  • 7
  • 2
    are you mixing up pinMode constants and digitalWrite, or is this a secret? – dandavis Mar 15 '17 at 05:28
  • this is no secret: link. It may work by writing HIGH instead of INPUT_PULLUP, at least it works when wanting to set the internal pullup resistor for digital input. – SMFSW Mar 15 '17 at 06:13
  • 1
    Either use pinMode(Ax, INPUT_PULLUP); or digitalWrite(Ax, HIGH);. It will work either way, but it's no good programming practice. – Gerben Mar 15 '17 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 Mar 15 '17 at 10:33