LowPowerLab Forum

Hardware support => Moteino => Topic started by: djash40 on December 06, 2015, 07:10:37 AM

Title: input pin question
Post by: djash40 on December 06, 2015, 07:10:37 AM
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
Title: Re: input pin question
Post by: Felix on December 06, 2015, 01:23:50 PM
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.
Title: Re: input pin question
Post by: djash40 on December 06, 2015, 07:06:50 PM
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?
Title: Re: input pin question
Post by: Felix on December 07, 2015, 09:46:15 AM
Correct, the used pins are shown in the pinout diagrams (http://lowpowerlab.com/moteino/#pinout).