This is one of the best things I came across when learning arduino. It really helps, thanks!
@MichaelKlements4 жыл бұрын
Glad the video helped you out!
@SamHodby3 жыл бұрын
Brilliant! You just saved me so much hassle with too many digital/analogue pins being used.
@MichaelKlements3 жыл бұрын
That's great to hear!
@deletedmediatj Жыл бұрын
i've been looking for this solution for the past 5 months!!!
@kevinchamberlain8633 жыл бұрын
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.
@MichaelKlements3 жыл бұрын
That's great to hear!
@mohammedabdulbasit725210 ай бұрын
I'm glad to watching your video. In this video teach me practical learning. Thanks to you. Abdul Basit from Bangladesh.
@abpccpba3 жыл бұрын
Headed about this technique could not figure it out Wola here you are with the answer. THX
@jeremyhalfmanorofficialpro77953 жыл бұрын
omg this is awesome, really need to watch more of your content. subscirbed, great job!
@MichaelKlements3 жыл бұрын
Thank you!
@KSATica2 жыл бұрын
Your amazing….. thank you so much inspired today 👏👏👏👏👏👏
@bluehippotech3 жыл бұрын
Awesome tutorial and very clear! Thanks
@Ampereg_172 жыл бұрын
Could you make something like this, but with button on/off latch?
@casalguayaquil2 жыл бұрын
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.
@bertrandlapointe64792 жыл бұрын
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
@bertrandlapointe64792 жыл бұрын
Pushed at once
@MichaelKlements2 жыл бұрын
Yes you could do that too
@varnamq32 жыл бұрын
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.
@pablocifuentescam3 жыл бұрын
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?
@MichaelKlements3 жыл бұрын
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 Жыл бұрын
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
@mohamedabdellatif63774 жыл бұрын
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
@MichaelKlements4 жыл бұрын
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.
@cginclude2 ай бұрын
thanks you're cool
@devilvortex1 Жыл бұрын
is there any debouncing effects?
@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.
@Andrewthegreatish3 жыл бұрын
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 ?
@MichaelKlements3 жыл бұрын
Only if the combination had a uniquely identifiable resistance as well. You’ll also need to program this in as a combination option.
@tnmonty501 Жыл бұрын
How about multiple 3 axis buttons
@lovrojoksimovic5134 Жыл бұрын
In theory this can work with other digital sensors right? For example a PIR sensor and pushbutton
@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.
@DuDeMBR2 жыл бұрын
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.
@wiremonkeyshop2 жыл бұрын
Brilliant!
@dice69182 жыл бұрын
Dear brother can you help me a very small correction in my code
@mikelee19062 жыл бұрын
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?
@MichaelKlements2 жыл бұрын
As long as you're not expecting to use the buttons simultaneously (two buttons at the same time)
@mikelee19062 жыл бұрын
@@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!!
@heroicsquirrel319511 ай бұрын
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?
@heroicsquirrel319511 ай бұрын
Basically screw the wires of each button into the same (down) function terminal and have them both work when used separately
@MichaelKlements11 ай бұрын
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.
@unchayndspersonalaccount76903 жыл бұрын
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?
@MichaelKlements3 жыл бұрын
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).
@unchayndspersonalaccount76903 жыл бұрын
@@MichaelKlements Ah cool, thanks for the reply!
@deonzeelie27463 жыл бұрын
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?
@MichaelKlements3 жыл бұрын
Thanks for the suggestion Deon, I'll have a look at this. It sounds quite easy to do.
@daniel_gaming7832 ай бұрын
How much buttons can i connect?
@MichaelKlements2 ай бұрын
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.
@cpatriciasousa3 жыл бұрын
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.
@MichaelKlements3 жыл бұрын
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?
@cpatriciasousa3 жыл бұрын
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.
@MichaelKlements3 жыл бұрын
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.
@cpatriciasousa3 жыл бұрын
I did the method 2 with 220 Ohms resistors. I will check again the wires :) Thank you.
@fmaz19524 жыл бұрын
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.
@MichaelKlements4 жыл бұрын
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.
@bertrandlapointe64792 жыл бұрын
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_Printing2 жыл бұрын
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
@MichaelKlements2 жыл бұрын
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.
@welcometomcdonaldsmayitake20033 жыл бұрын
Why I just learned this after years of Arfuino projects... I feel so dumb rn...
@matta666-c9q4 жыл бұрын
i want to push 96 button at the same time 🤣(arduino full piano😎)
@MichaelKlements4 жыл бұрын
Haha, you’d have to look at multiplexing the inputs then
@milespeterson5049 Жыл бұрын
This is stupid, why do you need resistors for EACH pushbutton???
@virium.83729 ай бұрын
the resistors knock down the voltage to give different analog input