When using a multiplexer 74HC4067 to connect multiple push buttons as inputs, what is the best way to connect the buttons? Do I need external pull up resistors for all buttons, or only for the SIG pin? Can i use the arduino internal pull up instead? Are the buttons connected to ground when pushed or are they connected to 5v?
Sorry if this was already answered but I could not find a clear answer and I am uncertain how to proceed with this.
sushyoshi:
When using a multiplexer 74HC4067 to connect multiple push buttons as inputs, what is the best way to connect the buttons? Do I need external pull up resistors for all buttons
No.
sushyoshi:
or only for the SIG pin?
Yes.
sushyoshi:
Can i use the arduino internal pull up instead?
Yes, but you may need an external pullup as well.
sushyoshi:
Are the buttons connected to ground when pushed or are they connected to 5v?
Two problems with that diagram - the 220 Ohm resistor is inappropriately low, should be more like 1k, and you do not show the "sig" pin connected to any Arduino input!
Yes I realize that. My point is that I do not understand what you mean to connect input pull up resistor to 5v. Where does this resistor connects? Are you saying that the Sig connects to one arduino pin and to the input pull up resistor as well, and the other end of the resistor goes to 5V?
You have just illustrated the "sig" terminal connected to the pull-up resistor with a brown wire - you showed a 220 Ohm - which "pulls up" to the 5 V line unless the button which is presently selected by the multiplexer, is pressed. That same wire should also connect to whichever input pin on the Arduino you choose.
Ok. I Think I understand it now. So what it mean is that when the button is "open" the SIG gets 5V, but when the button is pressed "closed" it goes to the multiplexer.
Would it be OK like this? (see picture). Also since the SIG is already pulled up, does that means we don't use the software command for input pull up?
A 1k resistor sounds reasonable, the circuit looks right now.
If you set pinMode for the input in question to INPUT_PULLUP, this enables an effective 47k pullup in the Arduino itself. If you provide an external pullup such as the 1k here, you do not need to set INPUT_PULLUP, but there is no reason not to do so as the internal pullup will simply be in parallel with the external one.
It may be of interest to note that the 74HC4067 has a "switch contact" resistance of about 60 Ohms which will effectively be in series with whichever button you select which is why the pull-up resistor needs to be much greater and I suggested not less than 1k.
I am trying to use the CD74HC4067 multiplexer along with push buttons. The idea is to have 16 push buttons and use as least pins possible on the arduino. I found some guides for using CD74HC4067 but all of them seem to focus only on output to the 16 channels instrad of using the 16 channels as inputs. In the end I have not been able to find any guide about using the multiplexer for input buttons.
As I am not very experienced, I am not very sure how to use the multiplexer for input. I am not sure if it is correct but from what I understand for the arduino to read a channel it needs to have the control pins at a certain configuration (high or low). My concern with this is that if I press a button connected to the channel 0, this will only be able to be read if the control pins are all low (equivalent to channel 0 selected). But even if the arduino is looping through the different channels, wouldnt it miss an input button pressed because the control pins are not at that moment at the correct channel?
All in all if the multiplexer is not the best option for inputs, maybe I should go for mulitple push buttons on a single analog pin, with each button a different resistor to diferentiate the resulting analog value.
I was wondering if anyone has used this multiplexer successfully along with push buttons. For now what I really need is to have a working code that will serial.print when each of the buttons is pressed.
You should realise that the microcontroller is executing about sixteen million instructions per second (presuming one instruction per clock cycle; I haven't checked up on this ).
A sensibly written program unless it has some very complex calculations to perform, should cycle through the loop() code in much less than one millisecond, so should do this at least a thousand times a second. Now if it checks one of your buttons on each pass through the loop() - which is how it should do it, then each of your 16 buttons will be checked no less than 62 times each second.
The idea is to have 16 push buttons and use as least pins possible on the arduino.
I would suggest pcf8574. Only 2 Arduino pins required. In a manner of speaking, this uses zero pins, because those 2 pins are still available for many other possible uses, such as connecting to an RTC, or an LCD with a backpack, or temperature/humidity sensors, or....