First of all, I'd like to thank Paul and whoever else had a part in it for making and regularly improving the teensy. I loved it ever since I knew about it, and today I finally received my first 3.2.
My first project will be a two-way MIDI controller (sending control changes and have LEDs on the device, possibly motorfaders as well, change according to MIDI data the teensy receives), and so today I started prototyping with a rotary encoder (the data sheet can be found here http://cdn-reichelt.de/documents/datenblatt/C650/401588.pdf ) . The two outer pins are connected to digital in 2+3 , while the middle pin is connected to GND. Device type is just USB Midi. It works, however only for less than a minute at which point it will no longer update, serial.print stays blank and no control change gets sent . I also seem to experience occasional mouse and keyboard freezes ( i think the teensy , the mouse and keyboard are connected on the same port) and had 3 blue screens which iirc seemed to happen while i had Ableton (the MIDI "receiver" in my case) open and tried to reprogram the board.
Before posting , I did a little googling and found a possible solution of clearing the MIDI the teensy receives . Even tho Ableton doesnt have the Teensy MIDI Out set as an output, i am still clearing the buffer, but it wont help.
I did not ground any inputs, so only pins GND, D2 and D3 are used at the moment as well as D4 for the rotary encoder's switch, however when it does work, the rotary encoder seems to produce "correct" outputs.
This is my code (based on the Encoder example)
The other weird thing is (nothing to do with MIDI here), the LED never lights up (also I assume since the rotary encoder's switch is set as a pullup , the led should light when i am not pressing the button, correct?)
Any ideas?
Bonus question: Is there any way where i dont have to manually set knobLeft.write() ? Ideally id like the returned value to be the change since the last check / CC message ; im assuming the Encoder class does the "absolute" counting , so if theres a setting or a different library i can use, Im all ears.
Apologies for asking a trivial question that gets asked too frequently and not being able to provide more troubleshooting details right now, i am just a little stuck on why it happens and how to solve it.
Thanks for reading and best regards,
Jazz
My first project will be a two-way MIDI controller (sending control changes and have LEDs on the device, possibly motorfaders as well, change according to MIDI data the teensy receives), and so today I started prototyping with a rotary encoder (the data sheet can be found here http://cdn-reichelt.de/documents/datenblatt/C650/401588.pdf ) . The two outer pins are connected to digital in 2+3 , while the middle pin is connected to GND. Device type is just USB Midi. It works, however only for less than a minute at which point it will no longer update, serial.print stays blank and no control change gets sent . I also seem to experience occasional mouse and keyboard freezes ( i think the teensy , the mouse and keyboard are connected on the same port) and had 3 blue screens which iirc seemed to happen while i had Ableton (the MIDI "receiver" in my case) open and tried to reprogram the board.
Before posting , I did a little googling and found a possible solution of clearing the MIDI the teensy receives . Even tho Ableton doesnt have the Teensy MIDI Out set as an output, i am still clearing the buffer, but it wont help.
I did not ground any inputs, so only pins GND, D2 and D3 are used at the moment as well as D4 for the rotary encoder's switch, however when it does work, the rotary encoder seems to produce "correct" outputs.
This is my code (based on the Encoder example)
Code:
#include <MIDI.h>
#include <Encoder.h>
// 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 knobLeft(2, 3);
// avoid using pins with LEDs attached
void setup() {
Serial.begin(9600);
Serial.println("TwoKnobs Encoder Test:");
pinMode(4,INPUT_PULLUP);
}
long positionLeft = -999;
void loop() {
digitalWrite(13,digitalRead(4));
long newLeft;
newLeft = knobLeft.read();
if (newLeft != positionLeft ) {
Serial.print("Left = ");
Serial.print(newLeft);
Serial.println();
positionLeft = newLeft;
usbMIDI.sendControlChange(22,positionLeft,1);
positionLeft = 0;
knobLeft.write(0);
}
// if a character is sent from the serial monitor,
// reset both back to zero.
if (Serial.available()) {
Serial.read();
Serial.println("Reset both knobs to zero");
knobLeft.write(10);
//value of 10 for troubleshooting (after the reset , it will always log a change)
}
while (usbMIDI.read()) ;
delay(100);
}
Any ideas?
Bonus question: Is there any way where i dont have to manually set knobLeft.write() ? Ideally id like the returned value to be the change since the last check / CC message ; im assuming the Encoder class does the "absolute" counting , so if theres a setting or a different library i can use, Im all ears.
Apologies for asking a trivial question that gets asked too frequently and not being able to provide more troubleshooting details right now, i am just a little stuck on why it happens and how to solve it.
Thanks for reading and best regards,
Jazz