-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMux.cpp
41 lines (38 loc) · 864 Bytes
/
Mux.cpp
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
#include "Arduino.h"
#include "Mux.h"
uint8_t _CD74HC4067_Table[16][4] = {
{0, 0, 0, 0},
{1, 0, 0, 0},
{0, 1, 0, 0},
{1, 1, 0, 0},
{0, 0, 1, 0},
{1, 0, 1, 0},
{0, 1, 1, 0},
{1, 1, 1, 0},
{0, 0, 0, 1},
{1, 0, 0, 1},
{0, 1, 0, 1},
{1, 1, 0, 1},
{0, 0, 1, 1},
{1, 0, 1, 1},
{0, 1, 1, 1},
{1, 1, 1, 1}
};
Mux::Mux(uint8_t S0, uint8_t S1, uint8_t S2, uint8_t S3)
{
pinMode(S0, OUTPUT);
pinMode(S1, OUTPUT);
pinMode(S2, OUTPUT);
pinMode(S3, OUTPUT);
_S0 = S0;
_S1 = S1;
_S2 = S2;
_S3 = S3;
}
void Mux::channel(uint8_t channel)
{
digitalWrite(_S0, _CD74HC4067_Table[channel][0]);
digitalWrite(_S1, _CD74HC4067_Table[channel][1]);
digitalWrite(_S2, _CD74HC4067_Table[channel][2]);
digitalWrite(_S3, _CD74HC4067_Table[channel][3]);
}