Arduino and the multiplexer


to build a cool midi controller I will need to attach a set of knots to the arduino board. Arduino has built in analogic to digital converters and that could help to transduce the resisntence value of a knot to a digital value.

There is only one problem: arduino has nly 6 AD converters that would allow to use only six knots.

In order to come through this limitation one should use a multiplexer. A multiplexer is basically a piece of hardware with N inputs and 1 output plus a set of address inputs. The inputs are routed to the output choosing one of the N with the address.
For instance a multiplexer might have 16 inputs, selectable with 3 bits and one output.

There is a huge variety of multiplexers in the market, with N inputs and M outputs, with different response times, analogiacl and digital, etc…

I’ve searched the web and I’ve come across many suggestions, but I finally decided to buy the 4051 multiplexer.

4051 is a family of analogical multiplexer with 8 inputs and 1 output, controlled with 3 bits. It is very common in hobby electronics and there are many producers that provide an implementation of it.

My local store had the version produced by ST microelectronics. Its schematics are here:

Here you can read how to connect the multiplexer to the arduino:

I have followed the instructions and asimple application that swithed on two leds put at different ports of the multiplexer.

Here it goes the sketch that I’ve used:

int controlPin1 = 2;
int controlPin2 = 3;
int controlPin3 = 4;

int ledPin = 13;

void setup()
  pinMode(controlPin1, OUTPUT);
  pinMode(controlPin2, OUTPUT);
  pinMode(controlPin3, OUTPUT);
  pinMode(ledPin, OUTPUT);

  digitalWrite(ledPin, HIGH);

void loop()
  digitalWrite(controlPin1, LOW);
  digitalWrite(controlPin2, LOW);
  digitalWrite(controlPin3, LOW);


  digitalWrite(controlPin1, HIGH);
  digitalWrite(controlPin2, LOW);
  digitalWrite(controlPin3, LOW);


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s