1

In a project with an Atmega328 running at 8 MHz and powered from 3.3 V, I need to check if a 2-pin jumper is permanently inserted.

photo of 2-pin jumper example

So, the schematic is:

schematic diagram

and the board is:

PCB layout

I cannot figure it...

Is it really simple as:

1) Configure the PIN as INPUT_PULLUP?

2) Check if PIN is HIGH then is connected and do stuff?

3) Do I need external resistor (and what value) or is it sufficient the INTERNAL_PULLUP?

4) Can I leave the PIN shorted to GND for a massive amount of time, let's say for 1 year? This ATmega will be on "forever"

pseudocode, to understand:

void setup() {

  pinMode(PIN_CHECK , INPUT_PULLUP);

}

void loop() {

   // at first post, I did put this HIGH, but I was wrong.
   // the check need to be for LOW, when connected
   if ( PIN_CHECK == LOW ) {

     Serial.println("The user has placed the jumper, the pin is shorted to GND!");

   }


}

Thank you to all

sineverba
  • 303
  • 3
  • 12
  • 1
    I didn't look up the specific MCU. But if it supports an internal pull-up resistor, and if you activate that mode correctly, then yes you can apply the pull-up and configure the pin for input and detect the jumper. – jonk Oct 08 '17 at 16:52
  • 1
    If the jumper is installed, the pin will be LOW, not HIGH. – Peter Bennett Oct 08 '17 at 16:52
  • @PeterBennett ok, thank you for correction. But, for my 4 question? The answer is "YES" to the 4 questions? Thank you – sineverba Oct 08 '17 at 17:24
  • 1
  • yes 2) low 3) internal pull-up enough for not very noisy environments 4) forever. But put decoupling 100-nF capacitors between AVCC/VCC and gnd.
  • – next-hack Oct 08 '17 at 17:30
  • 1
    Also asked at: http://forum.arduino.cc/index.php?topic=504506 If you're going to do that then please be considerate enough to add links to the other places you cross posted. This will let us avoid wasting time due to duplicate effort and also help others who have the same questions and find your post to discover all the relevant information. – per1234 Oct 08 '17 at 22:49