Cart 0

Add Analogue Pins to Your Arduino with Paul Brown's MC14051B Library

Gareth Halfacree

Paul Brown's Multiplexor Arduino Library

The Arduino's analogue pins represent one of the platform's most useful features: the ability to read a variable voltage from everything from photo-sensitive resistors to temperature probes, contrasted with the two-state on-off digital pins. Sadly, they're limited in number: the most commonly-used model, the Arduino Uno, has just six analogue pins, and even the impressively beefy Arduino Mega tops out at 16. If you're finding that limiting, the answer is a multiplexor - and maker Paul Brown has made using one particularly cheap model as easy as possible.

The MC14051B multiplexor is available in breadboard-friendly through-hole format and adds eight additional analogue pins to your project in exchange for tying up a single existing analogue pin - gaining seven additional pins in total. Using a multiplexor, though, is harder than just wiring it up: you need to toggle three ports on the chip to tell the device which of its eight analogue pins you want to read, take the reading, then reset the device for the next round.

This is where Paul's newly-published library comes in. By including the library into any Arduino project which uses the MC14051B, it's possible to read from any of its pins without manually handling the port toggling. The job, in fact, is just one line longer than reading from an Arduino's built-in analogue pins: there's an additional reset line beneath each read to ready the multiplexor for its next use. Naturally, the library also works for writing to an analogue pin - just like the built-in pins.

Paul has released his library as under the GNU General Public Licence v3, meaning you're free to start using it in your projects whenever you like.

The M14051b is a popular and cheap anlogue multiplexer that can be used to add 8 more analogue ports to your Arduino. However, writing reading and writing to the MC14051B's ports makes sketches long and tedious, hence this driver.


Older Post Newer Post