How To Connect Multiple Pushbuttons To One Arduino Input

แชร์
ฝัง
  • เผยแพร่เมื่อ 25 พ.ย. 2024

ความคิดเห็น • 64

  • @Kabiedron
    @Kabiedron 4 ปีที่แล้ว +20

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

  • @kevinchamberlain863
    @kevinchamberlain863 3 ปีที่แล้ว +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.

  • @SamHodby
    @SamHodby 3 ปีที่แล้ว +7

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

  • @deletedmediatj
    @deletedmediatj 10 หลายเดือนก่อน +3

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

  • @mohammedabdulbasit7252
    @mohammedabdulbasit7252 9 หลายเดือนก่อน +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 ปีที่แล้ว +2

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

  • @jeremyhalfmanorofficialpro7795
    @jeremyhalfmanorofficialpro7795 3 ปีที่แล้ว +2

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

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

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

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

  • @Ampereg_17
    @Ampereg_17 2 ปีที่แล้ว +1

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

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

  • @bluehippotech
    @bluehippotech 3 ปีที่แล้ว

    Awesome tutorial and very clear! Thanks

  • @cginclude
    @cginclude 10 วันที่ผ่านมา

    thanks you're cool

  • @wiremonkeyshop
    @wiremonkeyshop 2 ปีที่แล้ว

    Brilliant!

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

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

  • @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 ปีที่แล้ว +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.

  • @tnmonty501
    @tnmonty501 ปีที่แล้ว

    How about multiple 3 axis buttons

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

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

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

  • @dice6918
    @dice6918 2 ปีที่แล้ว

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

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

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

  • @heroicsquirrel3195
    @heroicsquirrel3195 9 หลายเดือนก่อน

    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 9 หลายเดือนก่อน

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

    • @MichaelKlements
      @MichaelKlements  9 หลายเดือนก่อน

      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.

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

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

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

  • @daniel_gaming783
    @daniel_gaming783 16 วันที่ผ่านมา

    How much buttons can i connect?

    • @MichaelKlements
      @MichaelKlements  15 วันที่ผ่านมา

      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 ปีที่แล้ว +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.

  • @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 8 หลายเดือนก่อน

      the resistors knock down the voltage to give different analog input