help with a 4051 projct

hi all,

im hoping if someone here might be able to help here.

so i want to use a 4051 or 2 to get 12 analogue inputs as well as a couple of buttons for a midi controller.

reason for this is that i only have a nano to hand atm and need to expand the i/o.

if anyone can help with hook up and code or any, it would be great

kind regards

marc

Connections may be like this
https://www.google.no/search?q=4051+multiplexer+tutorial&biw=1280&bih=629&tbm=isch&imgil=d7S4iokizTKKLM%3A%3Bz9hSn-ElCUt0KM%3Bhttp%253A%252F%252Fgaragelab.com%252Fprofiles%252Fblogs%252Ftutorial-4051-mux-demux-with-arduino&source=iu&pf=m&fir=d7S4iokizTKKLM%3A%2Cz9hSn-ElCUt0KM%2C_&usg=__tOTMUzSPz8amALLUn8HmbHPlOFc%3D&ved=0CC4Qyjc&ei=qTrmVJTOFcKnygPOrYHgDQ#imgdii=_&imgrc=goveFNZ-0G1bjM%3A%3By7KHNbDEGKLl4M%3Bhttp%3A%2F%2Fwww.567.dk%2Farduino%2Farduinocd4051b02.png%3Bhttp%3A%2F%2Fforum.arduino.cc%2Findex.php%3Ftopic%3D215011.0%3B1038%3B364
You will find some code in this forum as well.

// read analog data from 2*8 inputs at 2*4051
// store in tbl1

const byte p0=10,p1=11,p2=12;
int tbl1[16];

void setup()
{
  pinMode(p0,OUTPUT); // output address pins for 4051
  pinMode(p1,OUTPUT);
  pinMode(p2,OUTPUT);
}

void readall()
{
  byte i; // temporary variable for counting
  for (i=0; i<=7; i++)
  // 1.st set up address to
  {
    digitalWrite(p0, i&1);
    digitalWrite(p1, i&2);
    digitalWrite(p2, i&4);
  }
  // then read the analog value at 4051s pin i
  tbl1[i]=analogRead(0); // the 4051s Y-line connected to A0
  tbl1[i+8]=analogRead(1); // the 4051s Y-line connected to A1
}

void loop()
{
  readall(); // get 16 inputs stored to tbl1
  // do computing..
}