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 95
103 0 1 1 0 0 0 0 0 96
102 0 1 1 0 0 0 1 0 98
91 0 1 1 0 1 0 1 0 106
116 0 1 1 1 0 0 0 0 112
117 0 1 1 1 0 0 0 1 113
115 0 1 1 1 0 1 0 0 116
93 0 1 1 1 1 0 0 0 120
94 0 1 1 1 1 0 0 1 121
92 0 1 1 1 1 0 1 0 122
114 0 1 1 1 1 1 0 0 124
95 0 1 1 1 1 1 0 1 125
113 0 1 1 1 1 1 1 0 126
0 0 1 1 1 1 1 1 1 127
72 1 0 0 0 0 0 0 0 128
71 1 0 0 0 0 0 0 1 129
68 1 0 0 0 0 0 1 1 131
73 1 0 0 0 0 1 0 0 132
29 1 0 0 0 0 1 1 1 135
70 1 0 0 0 1 0 0 1 137
69 1 0 0 0 1 0 1 1 139
35 1 0 0 0 1 1 1 0 142
34 1 0 0 0 1 1 1 1 143
121 1 0 0 1 0 0 0 0 144
122 1 0 0 1 0 0 1 0 146
74 1 0 0 1 0 1 0 0 148
30 1 0 0 1 0 1 1 1 151
6 1 0 0 1 1 0 0 0 152
123 1 0 0 1 1 0 1 0 154
124 1 0 0 1 1 1 1 0 158
17 1 0 0 1 1 1 1 1 159
67 1 0 1 0 0 0 1 1 163
26 1 0 1 0 0 1 0 0 164
27 1 0 1 0 0 1 1 0 166
28 1 0 1 0 0 1 1 1 167
59 1 0 1 0 1 0 0 1 169
15 1 0 1 0 1 1 1 1 175
5 1 0 1 1 1 0 0 0 184
110 1 0 1 1 1 1 0 0 188
111 1 0 1 1 1 1 1 0 190
16 1 0 1 1 1 1 1 1 191
87 1 1 0 0 0 0 0 0 192
84 1 1 0 0 0 0 0 1 193
45 1 1 0 0 0 0 1 1 195
86 1 1 0 0 0 1 0 0 196
85 1 1 0 0 0 1 0 1 197
50 1 1 0 0 0 1 1 1 199
46 1 1 0 0 1 0 1 1 203
33 1 1 0 0 1 1 1 1 207
83 1 1 0 1 0 0 0 1 209
44 1 1 0 1 0 0 1 1 211
75 1 1 0 1 0 1 0 0 212
31 1 1 0 1 0 1 1 1 215
32 1 1 0 1 1 1 1 1 223
100 1 1 1 0 0 0 0 0 224
61 1 1 1 0 0 0 0 1 225
101 1 1 1 0 0 0 1 0 226
66 1 1 1 0 0 0 1 1 227
62 1 1 1 0 0 1 0 1 229
49 1 1 1 0 0 1 1 1 231
99 1 1 1 0 1 0 0 0 232
60 1 1 1 0 1 0 0 1 233
47 1 1 1 0 1 0 1 1 235
48 1 1 1 0 1 1 1 1 239
77 1 1 1 1 0 0 0 0 240
82 1 1 1 1 0 0 0 1 241
78 1 1 1 1 0 0 1 0 242
65 1 1 1 1 0 0 1 1 243
76 1 1 1 1 0 1 0 0 244
63 1 1 1 1 0 1 0 1 245
64 1 1 1 1 0 1 1 1 247
98 1 1 1 1 1 0 0 0 248
81 1 1 1 1 1 0 0 1 249
79 1 1 1 1 1 0 1 0 250
80 1 1 1 1 1 0 1 1 251
97 1 1 1 1 1 1 0 0 252
96 1 1 1 1 1 1 0 1 253
112 1 1 1 1 1 1 1 0 254
Yes, no problem. Better not use 5V as not all Teensy's are 5V tolerant.With only 3.3v it is ok ?
/* Encoder Library - Basic Example
* http://www.pjrc.com/teensy/td_libs_Encoder.html
*
* This example code is in the public domain.
*/
#include <Encoder.h>
// Change these two 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 myEnc(5, 6);
// avoid using pins with LEDs attached
void setup() {
Serial.begin(9600);
Serial.println("Basic Encoder Test:");
}
long oldPosition = -999;
void loop() {
long newPosition = myEnc.read();
if (newPosition != oldPosition) {
oldPosition = newPosition;
Serial.println(newPosition);
}
}
Is it possible to post your complete code so that we can reproduce the issue? [or, preferably, the smallest code that shows the error].
Paul
#include <Encoder.h>
Encoder myEnc(5, 6);
void setup() {
}
long oldPosition = -999;
void loop() {
long newPosition = myEnc.read();
if (newPosition != oldPosition) {
oldPosition = newPosition;
usbMIDI.sendControlChange(1, 64, 1);
Serial.println(newPosition);
}
delay(10);
}
/* Encoder Library - Basic Example
* http://www.pjrc.com/teensy/td_libs_Encoder.html
*
* This example code is in the public domain.
*/
#include <Encoder.h>
Encoder myEnc(6, 5);
void setup()
{
}
long oldPosition = -999;
void loop()
{
long newPosition = myEnc.read();
if (oldPosition != newPosition)
{
// Serial.println(newPosition);
int fourStep;
fourStep = (newPosition - oldPosition) % 4;
if (fourStep == 0 && newPosition - oldPosition >= 0)
{
// Serial.println(newPosition);
usbMIDI.sendControlChange(40, 63, 1);
}
else if (fourStep == 0 && newPosition - oldPosition <= 0)
{
usbMIDI.sendControlChange(40, 65, 1);
}
oldPosition = newPosition;
}
// delay(1);
}
#include <Encoder.h>
Encoder myEnc(6, 5);
long oldPosition = -999;
void setup() {
}
void loop() {
long newPosition = (myEnc.read() / 4);
if (newPosition != oldPosition) {
Serial.println(newPosition);
if (newPosition - oldPosition > 0) {
usbMIDI.sendControlChange(40, 63, 1);
}
else if (newPosition - oldPosition < 0) {
usbMIDI.sendControlChange(40, 65, 1);
}
oldPosition = newPosition;
}
delay(10);
}