-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathmultiplexed_4067.ino
36 lines (30 loc) · 1008 Bytes
/
multiplexed_4067.ino
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
#include "EncoderTool.h"
using namespace EncoderTool;
constexpr unsigned encoderCount = 16; // number of attached encoders
constexpr unsigned S0 = 0; // address pin 0
constexpr unsigned S1 = 1; //...
constexpr unsigned S2 = 2; //...
constexpr unsigned S3 = 3; // address pin 3
constexpr unsigned SIG_A = 4; // output pin SIG of multiplexer A
constexpr unsigned SIG_B = 5; // output pin SIG of multiplexer B
// breakout: https://www.sparkfun.com/products/9056
// datasheet: https://www.ti.com/lit/gpn/CD74HC4067
EncPlex4067 encoders(encoderCount, S0, S1, S2, S3, SIG_A, SIG_B);
void setup()
{
encoders.begin();
}
void loop()
{
encoders.tick();
for (unsigned i = 0; i < encoderCount; i++)
{
if (encoders[i].valueChanged())
{
Serial.print("Encoder:");
Serial.print(i);
Serial.print(" value:");
Serial.println(encoders[i].getValue());
}
}
}