-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathAnalogMUX.h
44 lines (30 loc) · 1 KB
/
AnalogMUX.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
// Library: MUX Abstraction for analog multiplexers including MAX4617 and CD4051 or similar
// Version: 1.1.9
// Developer: Daniel Melendrez
// email: dmelendrez(at)gmail(dot)com
// Category: Analog Devices
// Date: Dec 2018 - Initial release
// Mar 2019 - Updated constructor to receive the enable pin
// July 2020 - Class name updated, Minor corrections, semver updated
#ifndef AnalogMUX_h
#define AnalogMUX_h
#include "Arduino.h"
class AnalogMUX {
public:
//constructor
AnalogMUX(uint8_t pinC, uint8_t pinB, uint8_t pinA, uint8_t pinEn);
// Pin A is the LSB; PinEn is active Low. Drive pins high to set all switches off
// Methods and variables
uint8_t cp[3] = {0, 0, 0}; // MAX4617/CD4051 use 3 addressing pins for up to 8 sensors per MUX
void setup(void);
void selectChannel(uint8_t ch);
void enable(void);
void disable(void);
private:
uint8_t _pinA;
uint8_t _pinB;
uint8_t _pinC;
uint8_t _pinEn;
bool _enabled = false;
};
#endif