TI 4051 Multiplexing

Hi Everyone,

I've been following this tutorial Arduino Playground - HomePage, but have no luck with getting my multiplexer to work...

here's my setup:
E, Vee and GND re all connected to the arduino ground. Vcc and Z are set to +5V of the arduino. Each Y pin is hooked up to an led then to ground.

I'm assuming that if I connect the S0, S1 and S2 pins to +5V (in different variations) the leds will turn on/off. Instead I'm getting some random flickering which makes no sense at all..

could anyone break down the tutorial? I guess I need to start by confirming that my connections are right.. :slight_smile:

I'm assuming that if I connect the S0, S1 and S2 pins to +5V (in different variations) the leds will turn on/off. Instead I'm getting some random flickering which makes no sense at all..

The pins are probably "floating" when not being supplied the +5v.

S0, S1, S2 are connected to digital outputs 2, 3, 4 respectively.
Each LED gets a resistor, too, right**?**

If you expect to see anything, then a delay( ); should be added at the end of the
for loop:

int r0 = 0;      //value of select pin at the 4051 (s0)
int r1 = 0;      //value of select pin at the 4051 (s1)
int r2 = 0;      //value of select pin at the 4051 (s2)
int count = 0;   //which y pin we are selecting

void setup()
{
  pinMode(2, OUTPUT);    // s0
  pinMode(3, OUTPUT);    // s1
  pinMode(4, OUTPUT);    // s2
}

void loop () 
{
  for (count=0; count<=7; count++)
  {
    // select the bit  
    r0 = bitRead(count,0);      
    r1 = bitRead(count,1);     
    r2 = bitRead(count,2);     

    digitalWrite(2, r0);
    digitalWrite(3, r1);
    digitalWrite(4, r2);
   
   delay (500);  // added by r_p 
  }  
}

Otherwise, I think it’d look like sparkles or something because the counter would be whizzing along (without let or hindrance.)
Tell me how that goes

Thanks for your response. Im not using any code,but basically just manually plugging in the 5v in different combinations on to the s0 s1 s2 pins. Wont that work? Isnt it the same principle as sending a high/low signal through the output pins?

:slight_smile:

Well, Yes & No.
It's likely what our friend zoomkat alluded to ? if an S pin isn't connected to +5 then it must be connected to Ground, it can't be left in an unconnected, "floating", state.
Run each S pin to +5 through a resistor, for this exercise any value between 1k-10k? would be fine. Then, when you want the pin to be "0", connect a wire from that pin to Ground (don't remove the resistor).

Run each S pin to +5 through a resistor,

Probably a better setup is to have each 4051 S pin connected to ground thru a high value resistor to ground any floating voltages. Then connect the arduino 5v control pins to the S pins for control. When the arduino pin is high, 5v is put on the S pin. When the arduino pin is low, the resistor removes any potential floating voltage on the S pin. I had to do this to get a 4051 working with another control chip. The main question is weather the arduino pin is grounded or high impedance when it is set low. If the arduino pin is high impedance, then the S pins will float resulting in unpredictable outputs. As always, the 4051 and arduino ground pins need to be connected.

I can appreciate that, zoomkat, except that ?

heyarn:
Im not using any code,but basically just manually plugging in the 5v in different combinations on to the s0 s1 s2 pins.

Pulling-up, pulling-down, either way sets the S-pins to a known state.
6 of one and a half-dozen of the other.

Pulling-up, pulling-down, either way sets the S-pins to a known state. 6 of one and a half-dozen of the other.

Not for his application. If he is using 5v for a signal to an S pin, having the S pin already pulled up to 5v just won't work.

What's the problem?
So, saying the pins were pulled-up and wires ("switches") put to ground, opening the connection to ground results in a +V on the S_pin ? replace the wires with DIPswitches to ground and, Voilà!, open = "1" and closed = "0".

What's the problem?

None on my end. I'm just explaining what I did to operate my 4051 chips using 0v and 5v control to the S pins. :wink:

i ended up using a shift key register… Thanks everyone!