analog-multiplexer
A platform agnostic driver for 4051 and 4067 series analog multiplexers targetting the Rust embedded-hal
This crate provides an interface, Multiplexer
that makes it trivially easy
to select channels on any given 74HC4051 or 74HC4067 series analog multiplexer.
Internally it keeps track of each multiplexer's state, allowing you to
check what channel is presently active or to enable/disable the multiplexer
at will.
Supported Hardware (Analog Multiplexers)
- 4067 series: 74HC4067
- 4051 series: 74HC4051
- ...and any other similar IC that uses three or four channel select pins
Usage
Here's an imaginary example using a 74HC4067 with a Blue Pill (stm32f104) board...
// NOTE: This is pseudocode. It's just meant to get the concept across :)
use Multiplexer; // Important part
use State;
// The pins we're using:
use ;
use ; // So we can read an analog pin (PB0)
Working Example
There's a proper working example in the examples
directory (read_all
) that uses RTIC and probe-rs to great effect. It requires an ST-LINK programmer, a Blue Pill board, and probe-run.
Here's me using it to read a hall effect sensor on channel 15:
License
Licensed under:
* Apache License, Version 2.0 (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)