cfredisded
Active member
Hi all,
I have a teensy 3.6 and was working on an audio project until I ran into a problem. When ever I start to send a midiclock signal into the teensy my program thinks I'm turning an encoder. This is only a problem when I use pin 1 and 2 for the encoder. Using Pin 3 and 4 for Encoder.read works as intended. When I remove MIDI.read from the code the encoder works as intended. I skimmed the code down to just the problem:
Does the Teensy think I am using pin 1 as a midi output or something?
Can anyone replicate this issue? If so I think this is a bug.
Any help is greatly appreciated.
I have a teensy 3.6 and was working on an audio project until I ran into a problem. When ever I start to send a midiclock signal into the teensy my program thinks I'm turning an encoder. This is only a problem when I use pin 1 and 2 for the encoder. Using Pin 3 and 4 for Encoder.read works as intended. When I remove MIDI.read from the code the encoder works as intended. I skimmed the code down to just the problem:
Code:
#include <MIDI.h>
#include <Audio.h>
#include <Wire.h>
#include <SPI.h>
#include <SD.h>
#include <SerialFlash.h>
#define ENCODER_DO_NOT_USE_INTERRUPTS //If you define ENCODER_DO_NOT_USE_INTERRUPTS *before* including Encoder, the library will never use interrupts.
#include <Encoder.h>
Encoder EncoderEnc(1, 2);
//Encoder EncoderEnc(4, 3); //pins 4 and 3 connected to encoder works as intended.
MIDI_CREATE_DEFAULT_INSTANCE();
//Global Variable
bool EncoderTurned;
long oldEncoderPos;
//Global Variable
void setup() {
Serial.begin(9600);
MIDI.begin(MIDI_CHANNEL_OMNI);
}
void loop(){
if (MIDI.read()){ // Remove MIDI.read() and EncoderEnc.read() works as expected
}
///Encoder Read///
long newEncoderPos = EncoderEnc.read(); // When MIDI.read() is present EncoderEnc.read() returns a -1 once every 30 to 100 or so reads.
if (newEncoderPos != oldEncoderPos){
EncoderTurned = true;
oldEncoderPos = newEncoderPos;
Serial.println("Encoder Turned");
}
else{
EncoderTurned = false;
}
///Encoder Read///
}
Does the Teensy think I am using pin 1 as a midi output or something?
Can anyone replicate this issue? If so I think this is a bug.
Any help is greatly appreciated.