Main Menu

input pin question

Started by djash40, December 06, 2015, 07:10:37 AM

djash40

Must I use a resistor for a digital input tactile button?
I am having mixed results with a 10K resistor.
I have pin#>resistor>SWitch_pin>GND and other side of switch_pin> 3.3V

Felix

You don't really need any resistor for digital inputs.
You can just do: GND > _button_ > pin
Then you initialize the pin as INPUT_PULLUP to use the internal pullup resistor, and you do software debouncing.
If you wanted multiple buttons on a single pin, you can use a voltage divided array of buttons going into an analog pin so you can read different buttons, but that gets more complex and you need multiple resistors.

djash40

Thank you Felix, that did the trick.
I was also able to use the A3 as digital too by referencing it as digital like so:
const int test = 17; // test button to kill pump
pinMode(test,     INPUT_PULLUP);
Also the digital pins marked with an *
I assume I cannot use these being they are used elsewhere.
Is that correct?

Felix

Correct, the used pins are shown in the pinout diagrams.