Hi guys,
I'm trying to map an encoder, for start. I've been following this instructable https://www.instructables.com/id/A-Framework-For-Making-Affordable-Stylish-Modula/
and modified it, using this code:
Is this the kind of MIDI message you would use to map to Traktor? When I try to map it, what I get is jog turn only in one direction, regardless in which direction I turn the encoder.
Any kind of help is deeply appreciated.
Best regards,
Natasha
I'm trying to map an encoder, for start. I've been following this instructable https://www.instructables.com/id/A-Framework-For-Making-Affordable-Stylish-Modula/
and modified it, using this code:
Code:
int pressed1 = 0;
int p1_state = 0;
int encoder_pin_a = 0;
int encoder_pin_b = 1;
boolean enableDebug = 0;
int8_t enc_states[] =
{
0,-1,1,0,1,0,0,-1,-1,0,0,1,0,1,-1,0 //16
};
int read_encoder(){
p1_state <<= 2;
p1_state |= (digitalRead(encoder_pin_a)<< 1 | digitalRead(encoder_pin_b));
p1_state &= 0x0f;
return enc_states[p1_state];
}
void intFunc1(void){
pressed1=1;
}
void setup() {
if(enableDebug==1){
Serial.begin(9600);//open serail port @ debug speed
}
else{
Serial.begin(31250);//open serail port @ midi speed
}
pinMode(encoder_pin_a, INPUT);
digitalWrite(encoder_pin_a,HIGH);
pinMode(encoder_pin_b, INPUT);
digitalWrite(encoder_pin_b, HIGH);
attachInterrupt(0, intFunc1, CHANGE);
attachInterrupt(1, intFunc1, CHANGE);
}
void loop()
{
if(pressed1){ //encoder has been touched
pressed1=0; //reset flag
switch(read_encoder()){ //call out encoder function
case -1:
if (enableDebug==1){
Serial.println("encoder +");
}
else {
usbMIDI.sendNoteOn(1,127,127);
}
break;
case 0:
break;
case 1:
if(enableDebug==1){
Serial.println("encoder -");
}
else {
usbMIDI.sendNoteOn(1,127,126);
}
break;
}
}
}
Is this the kind of MIDI message you would use to map to Traktor? When I try to map it, what I get is jog turn only in one direction, regardless in which direction I turn the encoder.
Any kind of help is deeply appreciated.
Best regards,
Natasha