How To Connect Multiple Pushbuttons To One Arduino Input

Поделиться
HTML-код
  • Опубликовано: 28 авг 2024

Комментарии • 61

  • @Kabiedron
    @Kabiedron 4 года назад +17

    This is one of the best things I came across when learning arduino. It really helps, thanks!

  • @SamHodby
    @SamHodby 2 года назад +7

    Brilliant! You just saved me so much hassle with too many digital/analogue pins being used.

  • @kevinchamberlain863
    @kevinchamberlain863 2 года назад +8

    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.

  • @deletedmediatj
    @deletedmediatj 7 месяцев назад +3

    i've been looking for this solution for the past 5 months!!!

  • @mohammedabdulbasit7252
    @mohammedabdulbasit7252 6 месяцев назад +1

    I'm glad to watching your video. In this video teach me practical learning. Thanks to you. Abdul Basit from Bangladesh.

  • @abpccpba
    @abpccpba 3 года назад +3

    Headed about this technique could not figure it out Wola here you are with the answer. THX

  • @KSATica
    @KSATica Год назад +2

    Your amazing….. thank you so much inspired today 👏👏👏👏👏👏

  • @casalguayaquil
    @casalguayaquil Год назад

    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.

  • @jeremyhalfmanorofficialpro7795
    @jeremyhalfmanorofficialpro7795 2 года назад +2

    omg this is awesome, really need to watch more of your content. subscirbed, great job!

  • @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.

  • @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.

  • @Ampereg_17
    @Ampereg_17 2 года назад +1

    Could you make something like this, but with button on/off latch?

  • @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

  • @pablocifuentescam
    @pablocifuentescam 3 года назад +1

    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 года назад +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.

  • @bluehippotech
    @bluehippotech 3 года назад

    Awesome tutorial and very clear! Thanks

  • @mohamedabdellatif6377
    @mohamedabdellatif6377 4 года назад +1

    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 года назад +2

      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.

  • @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

  • @Andrewthegreatish
    @Andrewthegreatish 2 года назад

    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  2 года назад

      Only if the combination had a uniquely identifiable resistance as well. You’ll also need to program this in as a combination option.

  • @lovrojoksimovic5134
    @lovrojoksimovic5134 Год назад

    In theory this can work with other digital sensors right? For example a PIR sensor and pushbutton

    • @MichaelKlements
      @MichaelKlements  Год назад +1

      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.

  • @deonzeelie2746
    @deonzeelie2746 3 года назад +1

    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 года назад +2

      Thanks for the suggestion Deon, I'll have a look at this. It sounds quite easy to do.

  • @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!!

  • @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 года назад +1

      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.

  • @3D_Printing
    @3D_Printing Год назад

    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  Год назад +1

      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.

  • @heroicsquirrel3195
    @heroicsquirrel3195 6 месяцев назад

    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 6 месяцев назад

      Basically screw the wires of each button into the same (down) function terminal and have them both work when used separately

    • @MichaelKlements
      @MichaelKlements  6 месяцев назад

      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 года назад +1

      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 года назад +2

      @@MichaelKlements Ah cool, thanks for the reply!

  • @dice6918
    @dice6918 2 года назад

    Dear brother can you help me a very small correction in my code

  • @wiremonkeyshop
    @wiremonkeyshop 2 года назад

    Brilliant!

  • @tnmonty501
    @tnmonty501 Год назад

    How about multiple 3 axis buttons

  • @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

  • @devilvortex1
    @devilvortex1 11 месяцев назад

    is there any debouncing effects?

    • @MichaelKlements
      @MichaelKlements  11 месяцев назад

      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.

  • @welcometomcdonaldsmayitake2003
    @welcometomcdonaldsmayitake2003 2 года назад

    Why I just learned this after years of Arfuino projects... I feel so dumb rn...

  • @matta666-c9q
    @matta666-c9q 3 года назад

    i want to push 96 button at the same time 🤣(arduino full piano😎)

    • @MichaelKlements
      @MichaelKlements  3 года назад +1

      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 5 месяцев назад

      the resistors knock down the voltage to give different analog input