How To Connect Multiple Pushbuttons To One Arduino Input

  Рет қаралды 58,688

Michael Klements

Michael Klements

Күн бұрын

Пікірлер: 64
@Kabiedron
@Kabiedron 4 жыл бұрын
This is one of the best things I came across when learning arduino. It really helps, thanks!
@MichaelKlements
@MichaelKlements 4 жыл бұрын
Glad the video helped you out!
@SamHodby
@SamHodby 3 жыл бұрын
Brilliant! You just saved me so much hassle with too many digital/analogue pins being used.
@MichaelKlements
@MichaelKlements 3 жыл бұрын
That's great to hear!
@deletedmediatj
@deletedmediatj Жыл бұрын
i've been looking for this solution for the past 5 months!!!
@kevinchamberlain863
@kevinchamberlain863 3 жыл бұрын
I have been searching for a simple and affordable solution to control turnouts on my model train layout using pushbuttons. Your explanation is clear and helped me decide that the Arduino together with the PCA9685 servo controller is that way to go. Thank you for that.
@MichaelKlements
@MichaelKlements 3 жыл бұрын
That's great to hear!
@mohammedabdulbasit7252
@mohammedabdulbasit7252 10 ай бұрын
I'm glad to watching your video. In this video teach me practical learning. Thanks to you. Abdul Basit from Bangladesh.
@abpccpba
@abpccpba 3 жыл бұрын
Headed about this technique could not figure it out Wola here you are with the answer. THX
@jeremyhalfmanorofficialpro7795
@jeremyhalfmanorofficialpro7795 3 жыл бұрын
omg this is awesome, really need to watch more of your content. subscirbed, great job!
@MichaelKlements
@MichaelKlements 3 жыл бұрын
Thank you!
@KSATica
@KSATica 2 жыл бұрын
Your amazing….. thank you so much inspired today 👏👏👏👏👏👏
@bluehippotech
@bluehippotech 3 жыл бұрын
Awesome tutorial and very clear! Thanks
@Ampereg_17
@Ampereg_17 2 жыл бұрын
Could you make something like this, but with button on/off latch?
@casalguayaquil
@casalguayaquil 2 жыл бұрын
Excelent explaination. The only thing is that the floating ground was not placed back into the drawing, which is what makes de vudeo stand from others.
@bertrandlapointe6479
@bertrandlapointe6479 2 жыл бұрын
Tks for showing this method, I might use it with à attiny project. I would like to suggest to use différent resistor values for each resistor, this way, you could detect 2 buttons being
@bertrandlapointe6479
@bertrandlapointe6479 2 жыл бұрын
Pushed at once
@MichaelKlements
@MichaelKlements 2 жыл бұрын
Yes you could do that too
@varnamq3
@varnamq3 2 жыл бұрын
all you need is to put as many distinct(not of the same value) resistors in parallel as there are buttons and connect the buttons in series to those resistors, this will give you an unique voltage drop even if multiple buttons are pressed.
@pablocifuentescam
@pablocifuentescam 3 жыл бұрын
Thx a lot Michael!!! Great video!!! Anyway I've done it and works but the values of the analog are not so stable than in yours that are very sharp. I use the same resistors but with 9 buttons. Any help?
@MichaelKlements
@MichaelKlements 3 жыл бұрын
Thanks Pablo. If you're getting unstable results its probably either because you've got a poor ground or 5V connection or just poor connections in general. Jumpers and breadboards don't always provide a stable and reliable connection.
@davidroberts1218
@davidroberts1218 Жыл бұрын
Excellent tutorial I would like to achieve the same thing as Kevin Chamberlain in the comments I want to use uno and pca9685 to control servo motors using this pushbutton system on the same uno. The pca9685 board will used two analogue pins in leaving 4 analogue pins available could I assign pushbuttons to these four analogue pins would this allow 4 buttons to be pressed at the same time as long as they are on different analogue pins is it possible to assign one pushbutton to each servo in the programme sketch. ThankYou very much
@mohamedabdellatif6377
@mohamedabdellatif6377 4 жыл бұрын
is there anyway make us do this with one digital input ?? because I want for example use ESP 01 which doesn't have analog input ..... thanks in advance
@MichaelKlements
@MichaelKlements 4 жыл бұрын
There isn't any way (that I'm aware of) of connecting multiple push-buttons to a single digital input. You could, however, use a shift register to connect multiple push-buttons to substantially fewer digital inputs, typically 3 are required.
@cginclude
@cginclude 2 ай бұрын
thanks you're cool
@devilvortex1
@devilvortex1 Жыл бұрын
is there any debouncing effects?
@MichaelKlements
@MichaelKlements Жыл бұрын
Because we're reading an analogue signal, it's not as sensitive to button bounce, but if it is a problem in your application then you could debouce the signal in the same way as it is done digitally.
@Andrewthegreatish
@Andrewthegreatish 3 жыл бұрын
This wouldn't let you detect two buttons being pressed at once right? It would think it's just a different button further down the chain ?
@MichaelKlements
@MichaelKlements 3 жыл бұрын
Only if the combination had a uniquely identifiable resistance as well. You’ll also need to program this in as a combination option.
@tnmonty501
@tnmonty501 Жыл бұрын
How about multiple 3 axis buttons
@lovrojoksimovic5134
@lovrojoksimovic5134 Жыл бұрын
In theory this can work with other digital sensors right? For example a PIR sensor and pushbutton
@MichaelKlements
@MichaelKlements Жыл бұрын
It'll work for any digital sensors that have a contact or switch style output, most PIR sensors would work this way. Some digital sensors with internal circuitry might try force the output to a certain voltage or may not be compatible with a resistor being in series with the output.
@DuDeMBR
@DuDeMBR 2 жыл бұрын
I just read that there is no guarantee that the input will survive if you provide 5V directly without a resistor to limit current. So maybe you should either add a low resistance compared to the others or an equal one and get your HIGH signal from after then. Also I think you could make it possible to press and recognize them in parallel if you cleverly choose a unique resistance to add in parallel so there will always be a different total resistance.
@wiremonkeyshop
@wiremonkeyshop 2 жыл бұрын
Brilliant!
@dice6918
@dice6918 2 жыл бұрын
Dear brother can you help me a very small correction in my code
@mikelee1906
@mikelee1906 2 жыл бұрын
I have an arduino project that has a potentiometer on A1 which is used to produce 12 different tones. I want to convert the pot to momentary push buttons so I can play like a piano keyboard. I am thinking your example should work as a solution for me?
@MichaelKlements
@MichaelKlements 2 жыл бұрын
As long as you're not expecting to use the buttons simultaneously (two buttons at the same time)
@mikelee1906
@mikelee1906 2 жыл бұрын
@@MichaelKlements Thanks for the quick reply!! The tones are actually chords with harmony note to be more precise so no I only need one at a time. Thanks again!!
@heroicsquirrel3195
@heroicsquirrel3195 11 ай бұрын
Hello is it possible to connect two separate buttons that have the same functiona (down) on a fighting game controller that uses a brooks zero pi pcb, do you know about this?
@heroicsquirrel3195
@heroicsquirrel3195 11 ай бұрын
Basically screw the wires of each button into the same (down) function terminal and have them both work when used separately
@MichaelKlements
@MichaelKlements 11 ай бұрын
If the buttons are "normally open" then just connect them in parallel and you'll have the same functionality, if they're "normally closed" then connect them in series.
@unchayndspersonalaccount7690
@unchayndspersonalaccount7690 3 жыл бұрын
Can I use resistors with a higher resistance like 1kΩ? I still have a hard time grasping how this kind of circuit works... do higher-resistance resistors use or require more energy/current?
@MichaelKlements
@MichaelKlements 3 жыл бұрын
Yes you can, the resistor values in this particular arrangement aren't all that important. They are just there to provide a load between 5V and GND. They limit the current, so a higher value resistor results in less current (effectively more efficient).
@unchayndspersonalaccount7690
@unchayndspersonalaccount7690 3 жыл бұрын
@@MichaelKlements Ah cool, thanks for the reply!
@deonzeelie2746
@deonzeelie2746 3 жыл бұрын
great for expanding inputs. would it be possible for you to do a tutorial using say 6 push buttons on the one analogue to move a stepper motor to six preset degrees?
@MichaelKlements
@MichaelKlements 3 жыл бұрын
Thanks for the suggestion Deon, I'll have a look at this. It sounds quite easy to do.
@daniel_gaming783
@daniel_gaming783 2 ай бұрын
How much buttons can i connect?
@MichaelKlements
@MichaelKlements 2 ай бұрын
In theory you could connect up to 1024 although in practise you'd probably only be able to connect about 100 with some "margin of error" on either side of readings.
@cpatriciasousa
@cpatriciasousa 3 жыл бұрын
Hi, I understood everything and it's a great video! However, I don't know why, but I can't get this working! Only one button is working, all the others have the value 0 when pressed. I used the 220 Ohm resistors. Please help me, thank you in advance. Best regards.
@MichaelKlements
@MichaelKlements 3 жыл бұрын
Hi Patricia, Have you tried working through the write-up linked in the video description? Are you sure that your 5V and GND connections are correct?
@cpatriciasousa
@cpatriciasousa 3 жыл бұрын
Hi Michael, thank you for your reply. I tried with the code you have in the video description. I am sure the connections are correct. I am using Mega instead of Uno, I changed only the LED inputs codes. The LEDs works fine, because I tested it all of them. When I press the first button I only have one LED on. I don't know what is missing here. :( Thank you for your help.
@MichaelKlements
@MichaelKlements 3 жыл бұрын
If you've used only 220 ohm resistors then I assume you've connected the resistors are in method 2? If that's correct then start by displaying the raw value from the analogue input to your serial monitor and check whether you're getting a different reading for each button push. If you're getting 0 with any other button push then you've got a problem with your wiring somewhere.
@cpatriciasousa
@cpatriciasousa 3 жыл бұрын
I did the method 2 with 220 Ohms resistors. I will check again the wires :) Thank you.
@fmaz1952
@fmaz1952 4 жыл бұрын
Everyone is impressed by this technique at first until you realise the mess that happens when you press more than 1 button at the same time.
@MichaelKlements
@MichaelKlements 4 жыл бұрын
Yes, this isn't a great solution if you need to handle simultaneous button pushes, but it can be done. As long as you know which keys are likely to be pressed simultaneously, you can set up a case or range for them as well. This works if you've got a few combinations you need, but if its for an entire keypad of simultaneous button options then it can get messy.
@bertrandlapointe6479
@bertrandlapointe6479 2 жыл бұрын
Hi, if all resistors of the divider have the same value we can detect that more than one button was pushed but can not know which ones. If you use different values for each resistor than you can also detect which specific 2 buttons were pushed
@3D_Printing
@3D_Printing 2 жыл бұрын
Good idea:; resistors, by careful math's, you could maybe do two or more buttons at the same time, I think :) something like 1000 Ohms is button 1; 2000 Ohms is button 2 and then 3000 Ohms is both buttons, (series) or what ever it is in parallel
@MichaelKlements
@MichaelKlements 2 жыл бұрын
Yes you could detect simultaneous pushes by playing around with different resistor values, you'd just need to make sure that each combination resulted in a unique resistance.
@welcometomcdonaldsmayitake2003
@welcometomcdonaldsmayitake2003 3 жыл бұрын
Why I just learned this after years of Arfuino projects... I feel so dumb rn...
@matta666-c9q
@matta666-c9q 4 жыл бұрын
i want to push 96 button at the same time 🤣(arduino full piano😎)
@MichaelKlements
@MichaelKlements 4 жыл бұрын
Haha, you’d have to look at multiplexing the inputs then
@milespeterson5049
@milespeterson5049 Жыл бұрын
This is stupid, why do you need resistors for EACH pushbutton???
@virium.8372
@virium.8372 9 ай бұрын
the resistors knock down the voltage to give different analog input
Connect A 4x4 Keypad To One Arduino Input
7:35
Michael Klements
Рет қаралды 21 М.
Гениальное изобретение из обычного стаканчика!
00:31
Лютая физика | Олимпиадная физика
Рет қаралды 4,8 МЛН
Try this prank with your friends 😂 @karina-kola
00:18
Andrey Grechka
Рет қаралды 9 МЛН
Can the ARDUINO NANO handle 64 potentiometers?
26:55
Notes and Volts
Рет қаралды 17 М.
Arduino Basics Handling Multiple States
10:35
learnelectronics
Рет қаралды 121 М.
How To Wire It! Buttons & Switches
9:52
ItKindaWorks
Рет қаралды 146 М.
I built my own computer. by hand.
13:03
jdh
Рет қаралды 1,2 МЛН
100+ Switches in a single pin of Arduino
9:21
DIY USTHAD
Рет қаралды 50 М.
🤖Я в шоке! ChatGPT пишет Arduino проекты
28:24
Control 2 Servos with a Joystick and Arduino: Wiring + Code
15:18
Rachel De Barros
Рет қаралды 18 М.
I Accidentally Bought the New Arduino UNO R4 (And It's INSANE)
5:15
Arduino Multiplexor - MUX INPUTS & OUTPUTS - ANALOG and PWM
13:21
Electronoobs
Рет қаралды 116 М.
Гениальное изобретение из обычного стаканчика!
00:31
Лютая физика | Олимпиадная физика
Рет қаралды 4,8 МЛН