-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMA3_FourKnobs.pde
60 lines (47 loc) · 1.49 KB
/
MA3_FourKnobs.pde
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
/*
MA3 Rotary Encoder Plugin // PrysmLX
---- teensy 4.1 + 4 x rotary encoders ----
-- needed plugins: Bounce2 + Encoder --
*/
#include <Encoder.h>
#include <Bounce.h>
const int channel = 1;
// Change these pin numbers to the pins connected to your encoder.
// Best Performance: both pins have interrupt capability
// Good Performance: only the first pin has interrupt capability
// Low Performance: neither pin has interrupt capability
Encoder knobOne(4, 3); // oldLeft
Encoder knobTwo(6, 5); // oldRight
Encoder knobThree(8, 7);
Encoder knobFour(10, 9);
// renumber these and figure out how to add SW push
// avoid using pins with LEDs attached
void setup() {
//Serial.begin(9600);
// Serial.println("TwoKnobs Encoder Test:");
}
long positionOne = -999;
long positionTwo = -999;
long positionThree = -999;
long positionFour = -999;
void loop() {
long newOne, newTwo, newThree, newFour;
newOne = knobOne.read();
newTwo = knobTwo.read();
newThree = knobThree.read();
newFour = knobFour.read();
if (newOne != positionOne || newTwo != positionTwo || newThree != positionThree || newFour != positionFour) {
positionOne = newOne;
positionTwo = newTwo;
positionThree = newThree;
positionFour = newFour;
usbMIDI.sendNoteOn(1, positionOne, 1);
usbMIDI.sendNoteOn(2, positionTwo, 2);
usbMIDI.sendNoteOn(3, positionThree, 3);
usbMIDI.sendNoteOn(4, positionFour, 4);
}
knobOne.write(0);
knobTwo.write(0);
knobThree.write(0);
knobFour.write(0);
}