I need to be able to control each of LED individually. Now, I thought of multiplexing 16 pots using 4067 mux, and then connecting other 2 to analog pins. Regarding buttons, can I link more than 2 CD4021BE? That would require me do link 5 of them but I'm feeling there's a simpler solution that that. Is it better to multiplex them aswell or use shift registers?
I don't really have an idea how to control those LEDs.
Clock line
Serial data out
Serial data in
output latch
input latch
So 5 lines total.
The latch can be shared, so 4.
The serial data line can be shared if you had an output enable on the shift-in registers - but that's another control line, so might as well just have seperate data in & data out lines.
If you need faster access, can use SPI for a hardware shift-in (MISO) and shift-out (MOSI). Use SS for the two shift registers the input latch signal and the output latch signal for parts like 74HC595.
For the pots, you of course need some analog mux or analog switch parts. TI and Maxim I think both make 8:1 parts, and I think 16:1 also.
CrossRoads:
Clock line
Serial data out
Serial data in
output latch
input latch
So 5 lines total.
The latch can be shared, so 4.
Thanks for help.
CrossRoads:
If you need faster access, can use SPI for a hardware shift-in (MISO) and shift-out (MOSI). Use SS for the two shift registers the input latch signal and the output latch signal for parts like 74HC595.
I'm still quite a newbie at electronics so I don't understand this part at all.
CrossRoads:
For the pots, you of course need some analog mux or analog switch parts. TI and Maxim I think both make 8:1 parts, and I think 16:1 also.
Yeah, 4067 has 16 channels. One more question, CD4021BE can be used as both input and output or I need different register for output (the LEDs)?
shiftin() and shiftout() commands do something ike this under software control:
set the state of the bit go out
toggle the output clock bit
repeat 7 more times for the next 7 bits
latch the data into the shift register's output latch (on 74HC595 for example)
SPI does the same but had dedicated hardware to do it.
So one just writes the data into the hardware shift register, and 8 clock cycles later it is all shifted out. Much quicker.
and then data into the shift register's output latch, that is the same.
Same for incoming. Dedicated hardware to shift the bits in, vs a string of software commands to control the clock 8 times to read the input bit 8 times, and put the bits back into a byte.
4000 series chips are slow (clock upto 2MHz or so) and can't source or sink even 1mA without sagging from a 5V supply. They will work from 3V to 18V though (and perform better at higher voltages)
74HC series work from 2V to 6V, are much faster (can clock at 20MHz or so), can source/sink several mA. They are the modern choice unless you need the higher supply voltage ability - also likely to be cheaper.
I haven't checked but the precise details of driving them are probably different too.