Hot answers tagged

18 votes
Accepted

How to avoid that my arduino clicks eternally?

Hold the RESET button as you plug the Arduino in and keep it pressed all the time it's plugged into your computer. Load Blink.ino into the IDE and compile it. Press the UPLOAD button in the IDE and ...
user avatar
  • 103k
14 votes

What is the best technique to design a 20 push button circuit

For 20 buttons you can use a Keypad Matrix arrangement (plenty of examples online) where you would use only 9 pins (5 columns of 4 rows is 5+4 pins). It's slightly more involved that simple 1:1 ...
user avatar
  • 103k
12 votes

Why does this button have a connection to ground?

That resistor is called a pull-down resistor. It's there to make sure pin 2 read low when the button isn't pressed. If you don't put it there pin 2 is left 'floating', and it could erroneously read a ...
user avatar
  • 11.1k
9 votes

How do I repurpose Arduino's reset button

If you just want the reset button to change the program mode, the simplest thing would be to let the button reset the Arduino and switch modes each time your program restarts. Then you do not need to ...
user avatar
  • 36.9k
7 votes

Good button debouncing/stateChange library

The Button library in the Arduino playground works perfectly.
user avatar
  • 81
7 votes

How to turn two LED's on and off with one button?

Just use the return value of digitalRead (which is 1 or 0) as the input to digitalWrite: int btnVal = digitalRead(3); digitalWrite(4, btnVal); // On when button is HIGH digitalWrite(5, 1 - ...
user avatar
  • 103k
7 votes
Accepted

button connection without connection to 5V pin

There is a pullup resistor you don't see in the diagram because it is internal to the Arduino. I have added it in red. To make pin 7 an input, you can write: digitalWrite(7, INPUT_PULLUP); , which ...
user avatar
  • 14.5k
6 votes

Multiple Buttons on Single Analog Pin and Trigger Pin Arduino Uno

Use the analog comparator in the ATmega328P to trigger an interrupt once the input voltage rises enough to indicate a button press. Connect the analog network to both the analog input and D6. If ...
user avatar
6 votes
Accepted

Why are pin 18 and 19 always HIGH?

The analog pins function as digital pins number 14 - 19, with 14 being A0 and 19 being A5. I had hooked it up backwards. This time we're gonna get funky Everybody check your pins Check check check ...
user avatar
  • 171
6 votes
Accepted

Choosing wireless tech for lowest possible lag

I've used NRF24L01+ chipset 2.4GHz wireless modules with Arduino before, and found them to be great, and super cheap (~$10 for 10 of them on ebay!). They have 3 modes of transmission: 250kbps, 1Mbps, ...
user avatar
  • 373
6 votes

Press the Windows key using "keyboard.press();"

They Keyboard.press() command accept modifiers per the documentation. You may need to do multiple press() commands before releasing. For example, if you want to launch File Explorer you could use: ...
user avatar
  • 161
6 votes
Accepted

Powering potientiometer/button with a digital pin

You can likely use an I/O pin as an output to "power" fairly high-impedance devices such as pullup resistors for buttons, or even potentiometers of moderate to high total resistance. A ...
user avatar
6 votes

Buttons, LOW vs no connection

There must be a difference between a LOW reading and no connection, correct? No, the input circuitry measures a voltage. The exact details are in the datasheet, but how could it know there is ...
user avatar
  • 35.3k
6 votes
Accepted

Do I need a pull-up/down resistor for button LED circuit?

The circuit you have made is only using Arduino as a 5V power source. You aren't using any GPIO pins to read the state of the button or to control the LED by an output pin. You've just made a plain-...
user avatar
  • 6,932
6 votes

How do I make another action repeat inside a loop?

By using delay() it blocks the rest of the code. The programme needs to keep track of two buttons and update the lightshow at appropriate times, therefore a non-blocking style of coding is needed ...
user avatar
  • 679
5 votes
Accepted

Led on when not supposed to be

The behavior you describe is symptomatic of a floating input. I guess you have directly wired your buttons between input pins and +5V (or GND, that won't change the observed behavior). The problem ...
user avatar
  • 8,829
5 votes
Accepted

Performance of internal vs external resistors

If you are using the pin as an input in close proximity to the Arduino there is little reason to use an external pullup. There are a number of factors to consider. If the switch is some distance ...
user avatar
  • 1,645
5 votes

How to toggle LED on button press?

At the moment, you've got two main problems. Firstly, both your if statements are being triggered one after the other. This is because the first if statement sets x to 0, which is part of the ...
user avatar
5 votes

Good button debouncing/stateChange library

I think what you need is an interrupt-based detection of the button. This way, your Arduino can do what it needs to do without stalling for the delay function. // Example code usage int pin = 13; //...
user avatar
5 votes

Instead of 1 and 0, make display say On or Off

Put the strings to display in an array, and output them instead. char const * const stateDisplay[] = {"Off", "On"}; ... lcd.print(stateDisplay[state]);
user avatar
5 votes

How should I connect 5 buttons to arduino so that I can use the least number of inputs all the buttons are connected to ground

If all switches have one input grounded, you cannot use matrixing. In any case, the best you could do would be a 2 * 3 matrix, which uses 5 signals, the same as individual switching (though you may ...
user avatar
5 votes
Accepted

Push button restarts the arduino

If your button creates a short circuit between 5V and GND pins... it will certainly act like a RESET. Let's try to make sure you are not creating a dead short on an Arduino pin so you avoid ...
user avatar
5 votes
Accepted

Arduino alternating between high and low signal without button press

Look at this breadboard image: I have marked the power rail connections with green and red lines. Do you see, that they are not connected in the middle, right there where I've drawn the blue dotted ...
user avatar
  • 14k
4 votes

How to toggle LED on button press?

Don't forget to turn ON the LED: digitalWrite(ledPin, HIGH); And OFF: digitalWrite(ledPin, LOW);
user avatar
4 votes

My button control working in reverse

This behavior is expected: INPUT_PULLUP means the pin is pulled up via the internal pull up, i.e. it will read as high if not connected externally. With your push button you connect it to ground (0 ...
user avatar
4 votes

Choosing wireless tech for lowest possible lag

Have you considered using real time clocks? You could synchornise them all ahead of time and then use any wireless protocol. Once a button is pressed, you'll look for the unit that reports the ...
user avatar
  • 119
4 votes
Accepted

Newbie Question with 4 pin button

Internally those little tactile switches look like this: That means that the two pins on the same long side are connected together. So you can use, when you hold the switch vertically as in the ...
user avatar
  • 103k
4 votes
Accepted

1x4 Button membrane help

pinMode(one, INPUT); You have configured the input with no pullup. Since it is a CMOS input and hence very high impedance, it effectively acts as an antenna picking up random signals including that ...
user avatar

Only top scored, non community-wiki answers of a minimum length are eligible