Torque

Forums

Forums

Guest  

Show or hide header
Welcome Guest, posting in this forum require registration.




Torque » Torque OBD ECU Scanner » Torque Discussion / Ideas » Digital Inputs using Arduino?

Pages: [1]
Author Topic: Digital Inputs using Arduino?
nkemp
Member
Posts: 33
Post Digital Inputs using Arduino?
on: April 4, 2017 (GMT)

Can the Torque Wiki supplied arduino code be used to sense digital inputs?
I set the following to add one more sensor that was digital input. No other changes were made to the code listed in the Wiki.

const int SENSORSSIZE = 9 * 4; // each line is 9 attributes, and we have 4 lines.
const String sensors[SENSORSSIZE] = {
“0”, ANALOG, IS_INPUT, “-“, “Pot 1”, “Potentiometer 1”, “v”, “0”, “5”,
“1”, ANALOG, IS_INPUT, “-“, “LDR 1”, “Light Sensor 1”, “v”, “0”, “5”,
“4”, DIGITAL,IS_OUTPUT, “0”, “Dout1”, “Digital Out 1”, “bit”, “0”, “1”,
“7”, DIGITAL,IS_INPUT, “_”, “Din1”, “Digital In1”, “bit”, “0”, “1”
};

Here are the results:
Digital in 7 not connected yields an “Off”.
Digital In 7 grounded yields an “Off”.
Digital in 7 touching 3.2Vdc = “On”

So .. Can the Torque Wiki supplied arduino code be used to sense digital inputs? The answer is yes but it should be noted that Arduino does not sense “contact closure” from the input to ground. Over 2.5Vdc is “on”, under 2.5Vdc is “off”.

You could add an external pullup resistor to manage the contact losure application. You can also add the following code to the setup function:

digitalWrite (inputpin#, HIGH);

That code enables the internal pullup resistor for the inputpin# you selected. “HIGH” enables the pull up resistor. LOW disables it.

Now an open circuit is “ON” and a closed circuit is “OFF”. Backwards by my expectations but that is what code is for.

Pages: [1]
WP-Forum by: Fredrik Fahlstad, Version: 2.4
Page loaded in: 0.009 seconds.

  Follow me on twitter