Goal: to just light up a bunch of LEDs using push buttons. I have 8 push buttons and 8 leds. (I'm using the 74HC595 to drive the leds) So if I push PB1, I'd only like the first LED to light up and the other 7 off. If i push PB2, only LED2 is on, rest is off..etc.
So I'm using the 74HC4051 to help me control my inputs (multiplexing). I just have some questions about the chip and how to approach the code.
Pin 3 on the 4051 (Z common output or input),, what do I have to use that for? I was reading other articles and they say to put it on A0 on the Arduino. But then I don't know how to utilize it in my code. I'd like to use IF statements, just a fyi
I understand that if s0 = HIGH, s1 = LOW, s2 = LOW, it will activate Y1 on my push button.
so how do i like write that in my code?
should i be making like different functions? or idk?
The link Nick posted has all the info you'll need. See the diagram under 'Suggested Wiring'. Looking at the diagram, Z, I/O common, or pin 3, is at the state that pins A/B/C address. If A/B/C were at 0,0,0, then pin 13 is being addressed, and that data is on the Z pin. If A/B/C were 0,1,0, then pin 15 would be addressed and that data is on the Z pin. Since the device is bi-directional, Z will show up on whatever pin you're addressing as well - as I understand it. Hope that helps.
Don't know how familiar you are with reading datasheets, but sometimes different manufacturers have different names for the same pins/functions. Makes it difficult sometimes.
The implementation and design follows directly from the function. It's an analog switch, so you can interconnect them. But they are not one in, one out devices. So I'm not sure what you mean by daisy chaining. If you connect one devices common input to one of the other one's outputs, you'd get 7+8 = 15 I/O's.
can I have like (addressA, addressB, addressC) for the first chip then (addressD, addressE, addressF) for the second chip?
Since one chips has one "output" you could connect that to A0, and have a second chip connected to A1, and so on. You would also need to connect the A/B/C pins but I don't see any reason why (if you only sampled one at a time) that they could not be connected in parallel.