Working an a usbMidi master clock project which currently provides eight separate Midi clock sources and is controllable via the usual transport commands and some device-specific CC messages and it's time for some user interface hardware.
Starting with encoders, testing on a T3.6 and using Bourns R/C debounce circuit and non-detent, 96ppr encoder, here's relevant code currently in use. IDE 1.8.12 TD 1.51.
Which works but needs a motor on it. Ok thats a big value for tempo but with an eye on a future project which will be looking at 0 - 16383 I'm seeking guidance as to how to implement a rotational velocity sensitive value multiplier.
Been spoiled by this native feature of Behringer BCR-2000's encoders. The user does not have control of velocity thresholds but can assign multiplier values to each of four. Once you get used to it, its easy not to want to use pots any more.
Thanks for reading and hands up from back of junior class anyone?
Starting with encoders, testing on a T3.6 and using Bourns R/C debounce circuit and non-detent, 96ppr encoder, here's relevant code currently in use. IDE 1.8.12 TD 1.51.
Code:
#include <Encoder.h>
Encoder encoder1(2, 3);
int previousEncoderInterval;
int encoderInterval = 500;// polling every 500 uSec ..
int encoder1Min= 0;
int encoder1Max= 1023;
int encoder1InitialValue = 120;
int encoder1Lag;
int encoder1Value;
int tempo1;
//**********************************************************
void setup()
{
delay(1000);
Serial.begin(115200);
encoder1.write(encoder1InitialValue);
}
//**********************************************************
void loop()
{
unsigned long currentEncoderTime = micros();
if(currentEncoderTime - previousEncoderInterval > encoderInterval)
{
previousEncoderInterval = currentEncoderTime;
{
long encoder1Value = (encoder1.read());
if(encoder1Value>encoder1Max)
{
encoder1Value=encoder1Max;encoder1.write((encoder1Value));
}
else if(encoder1Value< encoder1Min)
{
encoder1Value=encoder1Min;encoder1.write((encoder1Value));
}
else if (encoder1Value != encoder1Lag)
{
encoder1Lag = encoder1Value;
tempo1=(encoder1Value);
Serial.print("Encoder 1 ");
Serial.println(tempo1,DEC);
}
}
}
}
Been spoiled by this native feature of Behringer BCR-2000's encoders. The user does not have control of velocity thresholds but can assign multiplier values to each of four. Once you get used to it, its easy not to want to use pots any more.
Thanks for reading and hands up from back of junior class anyone?