I'm in the process of making a tag scanner (which transfers the tag ID to the computer), and I figured I'd use an Arduino Micro for that and just use the keyboard function on it to save myself a whole lot of hassle. From what I've read, however, having the keyboard open all the time can make it tricky to program it.

I figured my solution would be to use two of the pins as a jumper check, and have some code in the setup to read the input pin; if the circuit is closed between them, the keyboard function never activates, and if it's open, the Arduino will act as a keyboard. That way I should be able to put the jumper on if I need to program it, and leave it off if I just want it to run.

Unfortunately, I've never really done anything like this before, and I don't really want to just start plugging things around and run the risk of damaging my board. I've read around a bit, but I figured I wanted to bounce my ideas off of someone before I try it.

First, would you recommend a different approach? I did see a question that used the internal pullup resistor to check if a jumper connected it to ground, but since I only want to make this check once, is that a good route to go?

Secondly, if I connect it between two pins, am I correct in thinking I'd need a resistor between them (the Arduino website suggested 470ohm to 1kohm when connecting to other devices, so I'm guessing this would be a good number)? How would I set the pins up to make this work; should I put one pin as output and the other as input, and just read the input pin (after which I'd simply turn the output pin off), or would I need to add additional connections?

Thirdly, since this will use the USB port on the Arduino that is used to program it, is there a way to wipe the code from the Arduino in case of Serious Bugs, or is it possible to "brick" the board by tying up the USB permanently? I mean, I'll definitely make use of the Serial connection to test the output (and also to test the above jumper), so I think the odds are small enough to try it anyway, but... better safe than sorry?

  • why on-hold as too broad? there are two perfect answers
    – Juraj
    Sep 7, 2018 at 16:07
  • I had voted to close because multiple questions were asked in one question. I think Juraj is right, there are two great answers so I'm voting to re-open. +1 for each of the answers.
    – VE7JRO
    Sep 7, 2018 at 19:48

2 Answers 2


First of all, welcome here. Usually questions should contain, well, only one question ;)

In any case the usual circuit with buttons (a jumper can be seen as a button) are these ones:


simulate this circuit – Schematic created using CircuitLab

In the left case, usually the arduino pin is "pulled down" by the resistor when the button is not pressed (or the jumper is not present), so it will read "LOW". When the button is pressed, the arduino will see a "HIGH" value, since the button is "stronger" than the resistor and is able to force its value. The resistor is called "pull-down".

In the right case, the voltages are inverted. You read a "HIGH" value when the button is not pressed, and a "LOW" value when it is. The resistor is called "pull-up" for obvious reasons.

The resistor is needed because you need to have a "weak" component that can pull the arduino pin to a voltage value; it needs to be weak, so the button can override it.

The arduino, however, as a very common feature, called "internal weak pull-up" on the digital pins. This means that internally there is already the possibility to enable a weak resistor pulling the voltage to +5V. For this reason, what you need is to just connect the jumper to ground and read it.


simulate this circuit

You will need, in your setup, to set the pin as INPUT_PULLUP, and then check the value you read:

const byte jumperPin = 2;

void setup() {
  pinMode(jumperPin, INPUT_PULLUP);

void loop() {
  if (digitalRead(jumperPin) == LOW)
    // Jumper is inserted
    // Jumper is not inserted

This is what the DigitalInputPullup example is for...

Regarding your other question, there is a connector on every board named ICSP (of if there isn't, you should have access to the ICSP pins from somewhere else). This connector is used to flash the bootloader again (or to flash a program with an external programmer). You will need a atmel programmer to restore the original bootloader and "unbrick" it.

Luckily any arduino board can be used for this task; you will just need to download on another board the sketch ArduinoISP (already included in Arduino IDE) and you can use it to flash. There is plenty of tutorials online to do it. So to "unbrick" it you will just need another arduino board


First off, the premise:

having the keyboard open all the time can make it tricky to program

is completely false.

The problems that people experience with programming are when the Arduino is sending keystrokes all the time without external stimulus. This makes it tricky to do anything - not just program. Just like it's hard to write a letter when you have a cat walking all over your keyboard.

So as long as you aren't just sending keypresses all the time, and only send them when you actually read a card, there is no problem for you to try and fix.

Secondly, the idea:

use two of the pins as a jumper check, and have some code in the setup to read the input pin; if the circuit is closed between them, the keyboard function never activates, and if it's open, the Arduino will act as a keyboard.

is overly complex and meaningless. If all you want to do is check a state of "set" or "not set" using some external "device", what you're talking about is a button, or a switch. You don't need two pins for that - only one. And there's a myriad of tutorials available on the internet showing you in detail how to read the state of a button (or switch). (Hint: use a pin set to INPUT_PULLUP and connect that pin to GND to "activate" it. Include a small [100Ω] resistor for safety if you like).

So in summary:

  1. Unless you're being really daft in your program, there is no problem to solve.
  2. You are over-thinking your solution.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.