RobTillaart / HC4067

Arduino library for CD74HC4067 1 x 16 channel multiplexer and compatibles.
MIT License
5 stars 2 forks source link

Arduino CI Arduino-lint JSON check GitHub issues

License: MIT GitHub release PlatformIO Registry

HC4067

HC4067 is an Arduino library for a HC4067 1 x 16 channel multiplexer.

Description

HC4067 is a library to control the CD74HC4067 16 channel multiplexer / demultiplexer and compatible devices.

The HC4067 allows e.g one analog port read up to 16 different analog channels, or one digital port to read the state of 16 buttons.

It is also possible to use the HC4067 to select an OUTPUT channel. The signal pin can be connected to VCC (5V) or an IO pin set to OUTPUT. Only the selected channel can show the HIGH level of the IO pin if set to HIGH. Not selected pins will all be set to LOW.

The channel selection is done with four select lines S0..S3.

The device can be enabled/disabled by the enable line E.

0.3.0 breaking change

Version 0.3.0 has a bugfix for setChannel() which obsolete all previous versions.

Compatibles

Not tested, considered compatible.

Related

Hardware connection

Typical connection is to connect the four select pins to four IO pins of your board.

The optional enablePin E must be connected to GND if not used. This way the device will be continuous enabled.

Example multiplexing analog in.

        processor                      HC4067
     +-------------+              +-------------+
     |             |              |             |
     |          S0 |------------->| S0       Y0 |
     |          S1 |------------->| S1       Y1 |
     |          S2 |------------->| S2       Y2 |
     |          S3 |------------->| S3       Y3 |
     |             |              |          Y4 |
     |          E  |------------->| Enable   Y5 |
     |             |              |          Y6 |
     |             |              |          Y7 |
     |         A0  |<-------------| Z        Y8 |
     |             |              |          Y9 |
     |             |              |         Y10 |
     |             |              |         Y11 |
     |             |              |         Y12 |
     |             |              |         Y13 |
     |        GND  |--------------| GND     Y14 |
     |             |              | VCC     Y15 |
     |             |              |             |
     +-------------+              +-------------+

Less Select lines

Note: the library does not meant for this mode, although it should work. The GND-ed pins should be set to 255 (not tested).

It is possible to use less IO pins to connect to the S0..S3. The ones not connected to an IO pin must be connected to GND (preferred).

S0 S1 S2 S3 pins notes
IO IO IO IO 0-15 default usage
IO IO IO GND 0-7
IO IO GND GND 0-3
IO GND GND GND 0-1

Of course it is possible to set a Select pin to VCC instead of GND. This will result in another subset of the Y pins to select from.

Interface

#include "HC4067.h"

Core

Enable

These functions work only if enablePin is set in the constructor.

Future

Must

Should

Could

Won't (unless requested)

Support

If you appreciate my libraries, you can support the development and maintenance. Improve the quality of the libraries by providing issues and Pull Requests, or donate through PayPal or GitHub sponsors.

Thank you,