hola compañeros m tengo un problema con un proyecto ( este proyecto https://www.hispasonic.com/foros/drum-pad-arduino/419343 ), llevo casi un año metido en el y no e podido terminarlo, es un controlador midi basado en arduino, consegui los codigos en un foro de produccion musical, lo monte, solde, y programe; funciono bien en general, pero tengo un problema, cuando quiero asignar un boton (uso botones de arcadea) a un parametro en el programa que uso (traktor dj), arduino manda señales midi intermitentes, oscilan muchisimo y no puedo asignar el boton al parametro por que el programa (traktor) recibe infinidad de mensajes midi de forma aleatoria y no uno solo cundo presion algun boton, el codigo que uso es el siguiente:
//linea 1
const int buttonDoPin = 2;//numeracion de pin
const int button2Pin = 3;
const int button3Pin = 4;
const int button4Pin = 5;
//linea 2
const int button5Pin = 8;
const int button6Pin = 9;
const int button7Pin = 10;
const int button8Pin = 11;
//linea 3
const int button9Pin = 22;
const int button10Pin = 24;
const int button11Pin = 26;
const int button12Pin = 28;
//linea 4
const int button13Pin = 23;
const int button14Pin = 25;
const int button15Pin = 27;
const int button16Pin = 29;
//linea 1
int noteDo = 36; //MIDI note 69=A (440hz)
int note2= 37;
int note3= 38;
int note4= 39;
//linea 2
int note5= 40;
int note6= 41;
int note7= 42;
int note8= 43;
//linea3
int note9= 44;
int note10= 45;
int note11= 46;
int note12= 47;
// linea4
int note13= 48;
int note14= 49;
int note15= 50;
int note16= 51;
int buttonDoState = 0;// current state of the button
int button2State = 0;
int button3State = 0;
int button4State = 0;
int button5State = 0;
int button6State = 0;
int button7State = 0;
int button8State = 0;
int button9State = 0;
int button10State = 0;
int button11State = 0;
int button12State = 0;
int button13State = 0;
int button14State = 0;
int button15State = 0;
int button16State = 0;
int lastButtonDoState = 0;
int lastButton2State = 0;
int lastButton3State = 0;
int lastButton4State = 0;
int lastButton5State = 0;
int lastButton6State = 0;
int lastButton7State = 0;
int lastButton8State = 0;
int lastButton9State = 0;
int lastButton10State = 0;
int lastButton11State = 0;
int lastButton12State = 0;
int lastButton13State = 0;
int lastButton14State = 0;
int lastButton15State = 0;
int lastButton16State = 0;
int val;
void setup() {
// initialize the button pin as a input:
pinMode(buttonDoPin, INPUT);
pinMode(button2Pin, INPUT);
pinMode(button3Pin, INPUT);
pinMode(button4Pin, INPUT);
pinMode(button5Pin, INPUT);
pinMode(button6Pin, INPUT);
pinMode(button7Pin, INPUT);
pinMode(button8Pin, INPUT);
pinMode(button9Pin, INPUT);
pinMode(button10Pin, INPUT);
pinMode(button11Pin, INPUT);
pinMode(button12Pin, INPUT);
pinMode(button13Pin, INPUT);
pinMode(button14Pin, INPUT);
pinMode(button15Pin, INPUT);
pinMode(button16Pin, INPUT);
// initialize serial communication:
// Set MIDI baud rate:
Serial.begin(31250);
}
void loop() {
buttonDoState = digitalRead(buttonDoPin);
if (buttonDoState == 0)
{ noteOn(0x90, noteDo, 0x00);}
else if (buttonDoState == lastButtonDoState)
{}
else { noteOn(0x90, noteDo, 0x45);}
button2State = digitalRead(button2Pin);
if (button2State == 0)
{ noteOn(0x90, note2, 0x00);}
else if (button2State == lastButton2State)
{}
else { noteOn(0x90, note2, 0x45);}
button3State = digitalRead(button3Pin);
if (button3State == 0)
{ noteOn(0x90, note3, 0x00);}
else if (button3State == lastButton3State)
{}
else { noteOn(0x90, note3, 0x45);}
button4State = digitalRead(button4Pin);
if (button4State == 0)
{ noteOn(0x90, note4, 0x00);}
else if (button4State == lastButton4State)
{}
else { noteOn(0x90, note4, 0x45);}
button5State = digitalRead(button5Pin);
if (button5State == 0)
{ noteOn(0x90, note5, 0x00);}
else if (button5State == lastButton5State)
{}
else { noteOn(0x90, note5, 0x45);}
button6State = digitalRead(button6Pin);
if (button6State == 0)
{ noteOn(0x90, note6, 0x00);}
else if (button6State == lastButton6State)
{}
else { noteOn(0x90, note6, 0x45);}
button7State = digitalRead(button7Pin);
if (button7State == 0)
{ noteOn(0x90, note7, 0x00);}
else if (button7State == lastButton7State)
{}
else { noteOn(0x90, note7, 0x45);}
button8State = digitalRead(button8Pin);
if (button8State == 0)
{ noteOn(0x90, note8, 0x00);}
else if (button8State == lastButton8State)
{}
else { noteOn(0x90, note8, 0x45);}
button9State = digitalRead(button9Pin);
if (button9State == 0)
{ noteOn(0x90, note9, 0x00);}
else if (button9State == lastButton9State)
{}
else { noteOn(0x90, note9, 0x45);}
button10State = digitalRead(button10Pin);
if (button10State == 0)
{ noteOn(0x90, note10, 0x00);}
else if (button10State == lastButton10State)
{}
else { noteOn(0x90, note10, 0x45);}
button11State = digitalRead(button11Pin);
if (button11State == 0)
{ noteOn(0x90, note11, 0x00);}
else if (button11State == lastButton11State)
{}
else { noteOn(0x90, note11, 0x45);}
button12State = digitalRead(button12Pin);
if (button12State == 0)
{ noteOn(0x90, note12, 0x00);}
else if (button12State == lastButton12State)
{}
else { noteOn(0x90, note12, 0x45);}
button13State = digitalRead(button13Pin);
if (button13State == 0)
{ noteOn(0x90, note13, 0x00);}
else if (button13State == lastButton13State)
{}
else { noteOn(0x90, note13, 0x45);}
button14State = digitalRead(button14Pin);
if (button14State == 0)
{ noteOn(0x90, note14, 0x00);}
else if (button14State == lastButton14State)
{}
else { noteOn(0x90, note14, 0x45);}
button15State = digitalRead(button15Pin);
if (button15State == 0)
{ noteOn(0x90, note15, 0x00);}
else if (button15State == lastButton15State)
{}
else { noteOn(0x90, note15, 0x45);}
button16State = digitalRead(button16Pin);
if (button16State == 0)
{ noteOn(0x90, note16, 0x00);}
else if (button16State == lastButton16State)
{}
else { noteOn(0x90, note16, 0x45);}
lastButtonDoState = buttonDoState;
lastButton2State = button2State;
lastButton3State = button3State;
lastButton4State = button4State;
lastButton5State = button5State;
lastButton6State = button6State;
lastButton7State = button7State;
lastButton8State = button8State;
lastButton9State = button9State;
lastButton10State = button10State;
lastButton11State = button11State;
lastButton12State = button12State;
lastButton13State = button13State;
lastButton14State = button14State;
lastButton15State = button15State;
lastButton16State = button16State;
}
void noteOn(int cmd, int pitch, int velocity) {
Serial.write(byte (cmd));
Serial.write(byte (pitch));
Serial.write(byte (velocity));
}
Me gustaria que pudieran ayudarme a encontrar cual es el error que hay en mi proyecto, no se si sea del codigo o de mi placa, uso una arduino mega 2560, uso la version 1.03 y 23 del programa de compilacion de arduino, espero puedan ayudarme saludos y suerte compañeros!!!
dejo un video del controlador funcionando con reason, en traktor no puedo asignar nada por que al momento de hacer la lectura del boton los valores fluctuan demasiado, inclusive sin apretar el boton los valores saltan de uno a otro sin que pueda hacer nada, sin embargo en reason funciona de maravilla con el drumrack, pero si quiero asignar un boton del mixer virtual pasa lo mismo, al hacer la lectura del boton para asignarlo los valores saltan como locos.
http://www.youtube.com/watch?v=wXQBjNyT8v8
//linea 1
const int buttonDoPin = 2;//numeracion de pin
const int button2Pin = 3;
const int button3Pin = 4;
const int button4Pin = 5;
//linea 2
const int button5Pin = 8;
const int button6Pin = 9;
const int button7Pin = 10;
const int button8Pin = 11;
//linea 3
const int button9Pin = 22;
const int button10Pin = 24;
const int button11Pin = 26;
const int button12Pin = 28;
//linea 4
const int button13Pin = 23;
const int button14Pin = 25;
const int button15Pin = 27;
const int button16Pin = 29;
//linea 1
int noteDo = 36; //MIDI note 69=A (440hz)
int note2= 37;
int note3= 38;
int note4= 39;
//linea 2
int note5= 40;
int note6= 41;
int note7= 42;
int note8= 43;
//linea3
int note9= 44;
int note10= 45;
int note11= 46;
int note12= 47;
// linea4
int note13= 48;
int note14= 49;
int note15= 50;
int note16= 51;
int buttonDoState = 0;// current state of the button
int button2State = 0;
int button3State = 0;
int button4State = 0;
int button5State = 0;
int button6State = 0;
int button7State = 0;
int button8State = 0;
int button9State = 0;
int button10State = 0;
int button11State = 0;
int button12State = 0;
int button13State = 0;
int button14State = 0;
int button15State = 0;
int button16State = 0;
int lastButtonDoState = 0;
int lastButton2State = 0;
int lastButton3State = 0;
int lastButton4State = 0;
int lastButton5State = 0;
int lastButton6State = 0;
int lastButton7State = 0;
int lastButton8State = 0;
int lastButton9State = 0;
int lastButton10State = 0;
int lastButton11State = 0;
int lastButton12State = 0;
int lastButton13State = 0;
int lastButton14State = 0;
int lastButton15State = 0;
int lastButton16State = 0;
int val;
void setup() {
// initialize the button pin as a input:
pinMode(buttonDoPin, INPUT);
pinMode(button2Pin, INPUT);
pinMode(button3Pin, INPUT);
pinMode(button4Pin, INPUT);
pinMode(button5Pin, INPUT);
pinMode(button6Pin, INPUT);
pinMode(button7Pin, INPUT);
pinMode(button8Pin, INPUT);
pinMode(button9Pin, INPUT);
pinMode(button10Pin, INPUT);
pinMode(button11Pin, INPUT);
pinMode(button12Pin, INPUT);
pinMode(button13Pin, INPUT);
pinMode(button14Pin, INPUT);
pinMode(button15Pin, INPUT);
pinMode(button16Pin, INPUT);
// initialize serial communication:
// Set MIDI baud rate:
Serial.begin(31250);
}
void loop() {
buttonDoState = digitalRead(buttonDoPin);
if (buttonDoState == 0)
{ noteOn(0x90, noteDo, 0x00);}
else if (buttonDoState == lastButtonDoState)
{}
else { noteOn(0x90, noteDo, 0x45);}
button2State = digitalRead(button2Pin);
if (button2State == 0)
{ noteOn(0x90, note2, 0x00);}
else if (button2State == lastButton2State)
{}
else { noteOn(0x90, note2, 0x45);}
button3State = digitalRead(button3Pin);
if (button3State == 0)
{ noteOn(0x90, note3, 0x00);}
else if (button3State == lastButton3State)
{}
else { noteOn(0x90, note3, 0x45);}
button4State = digitalRead(button4Pin);
if (button4State == 0)
{ noteOn(0x90, note4, 0x00);}
else if (button4State == lastButton4State)
{}
else { noteOn(0x90, note4, 0x45);}
button5State = digitalRead(button5Pin);
if (button5State == 0)
{ noteOn(0x90, note5, 0x00);}
else if (button5State == lastButton5State)
{}
else { noteOn(0x90, note5, 0x45);}
button6State = digitalRead(button6Pin);
if (button6State == 0)
{ noteOn(0x90, note6, 0x00);}
else if (button6State == lastButton6State)
{}
else { noteOn(0x90, note6, 0x45);}
button7State = digitalRead(button7Pin);
if (button7State == 0)
{ noteOn(0x90, note7, 0x00);}
else if (button7State == lastButton7State)
{}
else { noteOn(0x90, note7, 0x45);}
button8State = digitalRead(button8Pin);
if (button8State == 0)
{ noteOn(0x90, note8, 0x00);}
else if (button8State == lastButton8State)
{}
else { noteOn(0x90, note8, 0x45);}
button9State = digitalRead(button9Pin);
if (button9State == 0)
{ noteOn(0x90, note9, 0x00);}
else if (button9State == lastButton9State)
{}
else { noteOn(0x90, note9, 0x45);}
button10State = digitalRead(button10Pin);
if (button10State == 0)
{ noteOn(0x90, note10, 0x00);}
else if (button10State == lastButton10State)
{}
else { noteOn(0x90, note10, 0x45);}
button11State = digitalRead(button11Pin);
if (button11State == 0)
{ noteOn(0x90, note11, 0x00);}
else if (button11State == lastButton11State)
{}
else { noteOn(0x90, note11, 0x45);}
button12State = digitalRead(button12Pin);
if (button12State == 0)
{ noteOn(0x90, note12, 0x00);}
else if (button12State == lastButton12State)
{}
else { noteOn(0x90, note12, 0x45);}
button13State = digitalRead(button13Pin);
if (button13State == 0)
{ noteOn(0x90, note13, 0x00);}
else if (button13State == lastButton13State)
{}
else { noteOn(0x90, note13, 0x45);}
button14State = digitalRead(button14Pin);
if (button14State == 0)
{ noteOn(0x90, note14, 0x00);}
else if (button14State == lastButton14State)
{}
else { noteOn(0x90, note14, 0x45);}
button15State = digitalRead(button15Pin);
if (button15State == 0)
{ noteOn(0x90, note15, 0x00);}
else if (button15State == lastButton15State)
{}
else { noteOn(0x90, note15, 0x45);}
button16State = digitalRead(button16Pin);
if (button16State == 0)
{ noteOn(0x90, note16, 0x00);}
else if (button16State == lastButton16State)
{}
else { noteOn(0x90, note16, 0x45);}
lastButtonDoState = buttonDoState;
lastButton2State = button2State;
lastButton3State = button3State;
lastButton4State = button4State;
lastButton5State = button5State;
lastButton6State = button6State;
lastButton7State = button7State;
lastButton8State = button8State;
lastButton9State = button9State;
lastButton10State = button10State;
lastButton11State = button11State;
lastButton12State = button12State;
lastButton13State = button13State;
lastButton14State = button14State;
lastButton15State = button15State;
lastButton16State = button16State;
}
void noteOn(int cmd, int pitch, int velocity) {
Serial.write(byte (cmd));
Serial.write(byte (pitch));
Serial.write(byte (velocity));
}
Me gustaria que pudieran ayudarme a encontrar cual es el error que hay en mi proyecto, no se si sea del codigo o de mi placa, uso una arduino mega 2560, uso la version 1.03 y 23 del programa de compilacion de arduino, espero puedan ayudarme saludos y suerte compañeros!!!
dejo un video del controlador funcionando con reason, en traktor no puedo asignar nada por que al momento de hacer la lectura del boton los valores fluctuan demasiado, inclusive sin apretar el boton los valores saltan de uno a otro sin que pueda hacer nada, sin embargo en reason funciona de maravilla con el drumrack, pero si quiero asignar un boton del mixer virtual pasa lo mismo, al hacer la lectura del boton para asignarlo los valores saltan como locos.
http://www.youtube.com/watch?v=wXQBjNyT8v8