Yet another Arduino Library for 8-channel Analog Multiplexers/Demutiplexers
Hi there!
I've written this library to help those who are using analog bidirectional multiplexers (MAX4617/CD4051) with microcontrollers such as Arduino, Teensy, STM or equivalent.
It is a simple yet useful layer of abstraction to simplify the use of these analog MUXes. Both models are electronically equivalent!
Usage:
-
Declare the group of pins from the uC connected to the MUX's select pins in the order --> C, B, A and Enable (9,10,11,6 according to the datasheets)
-
Instantiate as many MUX objects as physical devices you need using --> MUX muxDevice(pinC, pinB, pinA, pinEn)
-
Initialize the library in the Setup function --> muxDevice.setup();
-
To enable the device use the method --> muxDevice.enable(); to disable* it: muxDevice.disable();
-
To select a channel pass an integer value corresponding to the channel to be selected --> muxDevice(4); // to connect the input/output (common pin 3) to the switch from channel 4 (pin 1)
Remember that the permitted channel values are only from 0 to 7
- When the device is disabled, the channels are not selected to prevent potential device failure. This is done via an internal boolean flag. Important: Review the two included examples to get a better idea of the utility of this library.
Cheers!
dzalf 😎
#TODO
Sooon I will implement the activation/deactivation of the MUX from the library (Pin EN from MUX). For now you can simply tie this pin to GND to enable it. Never leave the enable pin floating
Add more examples of the usability of the library 😉