Yes it would work as you described. That is called a pull-down resistor because it assures that when the contact is open the digital input is at the logic state 0 (low). Usually you can use a 10 KΩ resistor for this purpose.
Bruno Ferreira
- 4.5k
- 2
- 27
- 37