Hi
I need to add a Rotary Encoder to my project with Arduino Uno for a MIDI controller.
This R.E. needs to move a midi control change.
I don't have, find a code for this propose.
Hi
I need to add a Rotary Encoder to my project with Arduino Uno for a MIDI controller.
This R.E. needs to move a midi control change.
I don't have, find a code for this propose.
google-translation german to english
I used google translator to translate this posting from German into english. You can see immediately from a translation whether it was made by google or a human. But the translation is good enough to understand the text. This posting should demonstrate that you can write a post in your native language and then have it translated by google.
You should provide significantly more information about what exactly you want to do. You should describe how much programming knowledge you have. You should add code that you already have as a code section in your post. You should provide a data sheet of the encoder as an attachment. You want help. Why should the others do all this work for you without knowing exactly what it is about? Should you make 5 different suggestions?
(by the way: I'm astonished about the quality of this translation made by google )
many greetings Stefan
google-translation german to spanish:
Utilicé el traductor de Google para traducir esta publicación del alemán al español. Puede ver inmediatamente a partir de una traducción si fue realizada por Google o por un humano. Pero la traducción es lo suficientemente buena para entender el texto. Esta publicación debe demostrar que puede escribir una publicación en su idioma nativo y luego hacer que Google la traduzca.
Debe proporcionar mucha más información sobre lo que desea hacer exactamente. Debe describir cuánto conocimiento de programación tiene. Debe agregar el código que ya tiene como una sección de código en su publicación. Debe proporcionar una hoja de datos del codificador como archivo adjunto. Quieres ayuda. ¿Por qué los demás deberían hacer todo este trabajo por usted sin saber exactamente de qué se trata? ¿Deberías hacer 5 sugerencias diferentes?
muchos saludos Stefan
The Control Surface library I maintain supports this out of the box: RotaryEncoder.ino
See the MIDI over USB page on how to get MIDI over USB to work on an Arduino UNO.
Pieter
//--------------------------------/ Declaro Encoder /------------------
int pinEnt = 4; // Conectado al SW on KY-040
int pinA = 2; // Conectado al CLK on KY-040
int pinB = 3; // Conectado al DT on KY-040
int Pos = 64; // Es el que indica la posición del encoder
int aux;
unsigned long time;
unsigned long t;
unsigned long tEnt;
bool C = true;
bool D = true;
bool E = false;
bool Ent = false;
int EncMenu = Pos;
//int D6 = Pos;
//-----------------/ ENCODER END/-------------------------------------------------------
void setup()
{
//Serial.begin(57600); //PRUEBA MONITOR SERIAL
//Serial.begin(9600);
//Serial.println("INICIO");
//Serial.begin(31250); // HIDUINO
Serial.begin(115200); //hairless + loop midi (via usb - pc) descargar hairless y loop midi - conecta con PEDALERA gt-1000 a traves de loopmidi
//-----------------/ SETUP - ENCODER /-------------------------------------------------------
// Declaro pines Encoder
pinMode (pinA,INPUT); // Derecha
pinMode (pinB,INPUT); // Izquierda
pinMode (pinEnt,INPUT); // Enter
Serial.print("Encoder Position: "); // ** reemplazar por codigo nuevo
Serial.println(Pos); // Contador para la posición // ** reemplazar por codigo nuevo
// ** esto tiene que enviar un numero a hairless para asignar el valor de encoder a un CC# como en Pot (Pin Number, **Command, CC Control, Channel Number)
//-----------------/ END SETUP - ENCODER /-------------------------------------------------------
//-----------------/ LOOP - ENCODER /---------------------------*FALTA ASIGNAR MIDI A VUELTA DE ENCODER
time = millis(); // Registra el tiempo en todo el programa
//y lo usare en las distintas instancias.
// -------------------------------------------------------
// Codigo del encoder
if (digitalRead(pinA)==LOW){
t = time;
if(C == true){
Pos ++; //pos = pos + 1
if (Pos>127){Pos --;} // Evito conflicto con Encoder
Serial.print("Encoder Position: ");
Serial.println(Pos);
C = false;
D = false;
}
}
if (digitalRead(pinB)==LOW){
t = time;
if(D == true){
Pos --; // pos = pos - 1
if (Pos<0){Pos ++;} // Evito conflicto con Encoder
Serial.print("Encoder Position: ");
Serial.println(Pos);
D = false;
C = false; // Bloquea la lectura del A porque el B llego primero
//y sino me entra y pasa a la posición anterior
}
}
if (time-t>8){ // Tengo que esperar 8 ms para registrar nuevamente
C = true;
D = true;
}
//------------------------------------------------------------------
// Enter
if(E == false){
if(digitalRead(pinEnt) == LOW){
E = true;
}
}
if(E == true){
if(digitalRead(pinEnt) == HIGH){
Serial.println("Enter");
E = false;
}
}
//-----------------/ END LOOP - ENCODER /-------------------------------------------------
This is the code, it works but I dont know how asignate a midi message to CC#
This Encoder gives values from 0 to 127.
#include <Encoder.h> // Include the Encoder library.
// This must be done before the Control Surface library.
#include <Control_Surface.h> // Include the Control Surface library
// Instantiate a MIDI over USB interface.
USBMIDI_Interface midi;
// Instantiate a CCRotaryEncoder object
CCRotaryEncoder enc = {
{2, 3}, // pins
MCU::V_POT_1, // MIDI address (CC number + optional channel)
1, // optional multiplier if the control isn't fast enough
};
void setup() {
// Select the correct relative MIDI CC mode.
// Options:
// - TWOS_COMPLEMENT (default)
// - BINARY_OFFSET
// - SIGN_MAGNITUDE
// - NEXT_ADDRESS
// Aliases:
// - REAPER_RELATIVE_1
// - REAPER_RELATIVE_2
// - REAPER_RELATIVE_3
// - TRACKTION_RELATIVE
// - MACKIE_CONTROL_RELATIVE
// - KORG_KONTROL_INC_DEC_1
RelativeCCSender::setMode(relativeCCmode::MACKIE_CONTROL_RELATIVE);
Control_Surface.begin(); // Initialize Control Surface
}
void loop() {
Control_Surface.loop(); // Update the Control Surface
}
Here is Control Surface code, but where we can setup the CC# number?
I don't understand this code, how can I define the parameters of CC# ?
barbol_music:
Here is Control Surface code, but where we can setup the CC# number?
I don't understand this code, how can I define the parameters of CC# ?
It says so in the comment, the second argument is the MIDI address, which consists of the CC number and the optional MIDI channel (and cable).
If you want CC number 9, for example, you can use
// Instantiate a CCRotaryEncoder object
CCRotaryEncoder enc = {
{2, 3}, // pins
9, // MIDI address (CC number + optional channel)
1, // optional multiplier if the control isn't fast enough
};
See this tutorial for more information.