Using a 4051 multiplexer to read 3 pots

I’ve had a frustrating night,

I picked up a few NTE4051B’s

I used this guide:
http://www.arduino.cc/playground/Learning/4051

And the help of “Cheater” in the forums to get everything squared away.

The pots I’m using are 1 Meg Ohm.

And here’s my code:

int led = 13;
int r0 = 0; //value select pin at the 4051 (s0)
int r1 = 0; //value select pin at the 4051 (s1)
int r2 = 0; //value select pin at the 4051 (s2)
int row = 0; // storeing the bin code
int count = 0;
int bin [] = {000, 1, 10};

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

void loop () {
  for (count=0; count<=2; count++) {
    digitalWrite(led, HIGH);
    row = bin[count];      
    r0 = row & 0x01;
    r1 = (row>>1) & 0x01;
    r2 = (row>>2) & 0x01;
    digitalWrite(2, r0);
    digitalWrite(3, r1);
    digitalWrite(4, r2);
    Serial.print(analogRead(1));Serial.print("   ");
    delay(100);
    digitalWrite(led, LOW);
    delay(100);
  }  
  Serial.println("");
}

Alright, enough set-up. I’m not really getting the desired input, just a bunch of random numbers :slight_smile: I also tried adding all 6 ports to the bin array to see if I had those wrong.

Do I have anything wrong? The 1401’s top is on the left. The only thing I’ve noticed is the 1401 gets scorching hot. Kinda got me worried.

I’d appreciate any help anybody has!

You didn't connect it to ground, pin 8.

My god, how easy was that.

Is it just me, or did that tutorial skip over that part?

Thanks, I'll give it a shot when I get home!

You connected it according to the logic symbol figure. That is only make things easier! :-? You need to use the left image which says "pin configuration".

Man, did I mess that one up.

Works like a champ now! Thanks for all your help!