Giter Site home page Giter Site logo

arduino-ad-mux-lib's Introduction

arduino-ad-mux-lib

Arduino library for controlling analog/digital multiplexers (A/D mux) like those belonging to the CMOS 4000 series (e.g. 4051 (CD4051, 74HC4051), 4067 (CD4067, 74HC4067)).

This library was forked from project MUX74HC4067 (https://github.com/nlamprian/MUX74HC4067) in order to generalize and streamline its functionalities at both interface and implementation levels.

Getting started

Currently, two common ICs are explicitly implemented (Type4051Mux and Type4067Mux); others can be controlled through the generic class (GenericMux).

This library provides several examples that demonstrate its functionalities; they all revolve around the same simple life cycle:

  1. Object initialization

MCU pins are assigned to signal and channel control:

// Mux declared with analog input signal on pin A0 and channel control on digital pins 8, 9, 10 and 11.
Type4067Mux mux(A0, INPUT, ANALOG, 8, 9, 10, 11);

The signal pin can also be assigned (and possibly replaced) through the setSignalPin method.

  1. Object I/O

After selecting the channel, read/write operations can be invoked:

// Select 3rd channel!
mux.setChannel(2);
// Read data from the current channel (that is 3rd)!
int16_t data = mux.read();

Alternatively, the channel can be directly specified within the read/write operation:

// Read data from the 3rd channel!
int16_t data = mux.read(2);

Advanced use

The same mux can be physically connected to multiple signal pins at once, as any invocation to setSignalPin method ensures that the previous pin is set to high impedance state before switching to the new one.

Conversely, the same signal pin can be physically connected to multiple ICs through a common data line, as setEnabled method controls whether the mux I/O operates.

Repository

https://github.com/stechio/arduino-ad-mux-lib

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.