sync 2 4051s (both as mux and demux)


I’m trying to use 2 4051s. The first one is used as multiplexer and it’s reading 8 pots, while the second one is used as demultiplexer, in order to turn On/Off 8 LEDS, each time a pot (from the first 4051) changes value.

In other words, what I need is a LED for each input of the multiplexer.

Both 4051s use the same address inputs (dig pin 2,3,4). However, what happens is:

if I move pot 1, the 1st and 2nd LEDs are On
if I move pot 2, the 2nd and 3rd LEDs are On
if I move pot 3, the 3rdd and 4th LEDs are On
if I move pot 8, the 8th and 1st LEDs are On

I’ve been through this problem the last 5-6 days and I really must to solve it asap. So, any help/suggestion/etc…
is more than welcome…
I could post my code if needed (although is a bit more complicated), but I don’t know if the problem is in my code or 4051s behave like that (possible delay between input and output maybe?)…


There are a few things you can do to help you determine if the problem is in your code or in your wiring.

You could try sending serial messages to the Arduino serial monitor to see more clearly what your software is doing. For example, print the LED that you want to light and the pins you your are setting to control the multiplexer.

You could also write a simple test routine that ignored the pots and just sequenced through the LEDs to see if the wiring is the problem.

I hope that helps.

thank you mem, I'll try to debug my code to see what's wrong. However, it all makes sense to me so I'm not sure what's going on..

It's been my experience that if everything you know about what a program is doing makes sense but it still doesn't work, then its time to find out more about what the program/hardware is actually doing.

I hope the debugging will make things clearer.