Added resistors or not ? Need help

Hello, I am new to Arduino.

I followed this tutorial https://docs.arduino.cc/tutorials/micro/keyboard-press/
to make a button to write a letter, it's simple and it works. I used an Arduino Pro Micro board.

My question : I will create a code using this same tutorial to create a small keyboard (I think 12 buttons or more) each button will be a letter a/b/c/d/ or a special key ctrl/esc/..... I will use mechanical keyboard buttons as push buttons and each button will be connected to a pin on the card (letter A button on pin 2, letter B on pin 3...) As on the plan in the picture. And I might sometimes have to press two keys at the same time (CTRL+C for example).

  1. Do you think I should put a resistor for each keyboard button or is this not necessary?

  2. If adding a resistor is necessary, what value do you think the resistor would be?

Thanks in advance for the help.

Picture of my diagram example.
SAVE-01

Welcome to the forum

  • Wire the buttons so that the pin is connected to GND when they are pressed
  • Use INPUT_PULLUP in pinMode() for the button pins to keep them normally HIGH
  • When an input becomes LOW it has become pressed
  • No external resistors are required

Hello and thank you for the answer.

Perfect ! I dont add resistor.

remember buttons can bounce so if you don't want to send multiple times the same letter when the button is pressed or released you either need to take that into account in your coding or use a button library. There are plenty to choose from (such as Button in easyRun or OneButton or Toggle or EasyButton or Bounce2, ...)

If you really do have 4 lead buttons like your picture shows, it is best to connect diagonal corners. One to ground, one to your pin. That way, if the button is accidentally installed rotated 90 degrees, it will still work.

Also you should not be using the TX pin to connect a button to. Use another pin.

JML: Very good, thank you for the information. This project is very simple at the moment. But in the future, I plan to make more buttons, I will think about your advice which will be very useful to me.

blh64: As I said in the post there will be more than 10 buttons, but each button will be connected to a different pin on the board, the button with letter A will be on PIN "2", letter B on PIN "3" etc. I would put a JoyStick on PIN A0 and A1 and for the SW of the Joystick it will be connected to PIN 15 I think.

Grumpy_Mike: Well, I based it on the plan (which I am attaching a photo to you) it is indicated that the "TX" is the DIGITAL PIN 1. There will be an incident if I connect a button to the "TX" PIN “?
I wanted to take advantage of all the Digital PINs to connect the keys, this would save me from having to create a matrix keyboard. I still have a lot to learn, which is why I opted for simplicity by using all Digital PINs for the buttons.

Yes, on a Pro Micro this pin is used for TX only as a secondary output so it will only be a problem if you want, at some time to use Serial1 (as apposed to the Serial output which goes through the USB socket).

You seem to be totally missing the point that blh64 is trying to make. It is the way the wiring to the switches is done. The way you have it you are leaving yourself open to making a wiring mistake, by having the 4 pin push button rotated by 90˚. By wiring the buttons across the diagonal connection of the push button. This in no way affects the number of push buttons you can use.

It just makes it easier to convey the wiring without having to resort to Physical layout diagrams, which to be honest is not the way to show wiring. In other words it is not actually a schematic and is sadly what beginners all to often present as a schematic..

1 Like

excellent, your response is precise and valuable. I'm going to think about making a keyboard assembly (as in the photo from internet). This allows me to do something more safely and there are so many tutorials on the internet that will be very useful to me. I must have diodes. So I'm going to change my project and make something more logical with more buttons.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.