Momentary non-sensitive pushbutton with two speed variables arduino midi #192
-
Hello everyone, I am trying to do my first arduino project which is a pedal to control an effects processor, everything has gone well so far so I would like to ask for a little help since until this week I started learning about arduino, It turns out that it is an arduino uno r3 which is connected to 8 buttons without sensitivity, I can turn on effects in the processor by pressing them but I cannot turn them off, the connection is through a physical midi port not usb-midi, then when pressing the pushbuttons always return a value of 127 to test try to make the value 63 but it still returns 127, what I want to do is that when pressing returns 127 and when pressing 63 again, I appreciate your help in advance Update I already managed to change the velocity value to 63 but how can I put a variable of 127? midiOut.sendControlChange (25,63,1); // send to MIDI CC - 25 = note, 63 = velocity, 1 = channel #include <MIDI.h>
#include <midi_Defs.h>
#include <midi_Message.h>
#include <midi_Namespace.h>
#include <midi_Settings.h>
const int buttonOne = 2; // assign button pin to variable
const int buttonTwo = 3; // assign button pin to variable
const int buttonnThree = 4; // assign button pin to variable
const int buttonFour = 5; // assign button pin to variable
const int buttonFive = 6; // assign button pin to variable
const int buttonSix =7; // assign button pin to variable
const int buttonSeven = 8; // assign button pin to variable
const int buttonEight= 9; // assign button pin to variable
MIDI_CREATE_INSTANCE(HardwareSerial,Serial, midiOut); // create a MIDI object called midiOut
void setup() {
pinMode(buttonOne,INPUT); // setup button as input
pinMode(buttonTwo,INPUT); // setup button as input
pinMode(buttonnThree,INPUT); // setup button as input
pinMode(buttonFour,INPUT); // setup button as input
pinMode(buttonFive,INPUT); // setup button as input
pinMode(buttonSix,INPUT); // setup button as input
pinMode(buttonSeven,INPUT); // setup button as input
pinMode(buttonEight,INPUT); // setup button as input
Serial.begin(31250); // setup MIDI output
}
void loop() {
if(digitalRead(buttonOne) == HIGH) { // check button state
delay(10); // software de-bounce
if(digitalRead(buttonOne) == HIGH) { // check button state again
midiOut.sendControlChange(25,127,1); // send a MIDI CC -- 25 = note, 127 = velocity, 1 = channel
delay(250);
}
}
if(digitalRead(buttonTwo) == HIGH) { // check button state
delay(10); // software de-bounce
if(digitalRead(buttonTwo) == HIGH) { // check button state again
midiOut.sendControlChange(50,127,1); // send a MIDI CC -- 50 = note, 127 = velocity, 1 = channel
delay(250);
}
}
if(digitalRead(buttonnThree) == HIGH) { // check button state
delay(10); // software de-bounce
if(digitalRead(buttonnThree) == HIGH) { // check button state again
midiOut.sendControlChange(28,127,1); // send a MIDI CC -- 28 = note, 127 = velocity, 1 = channel
delay(250);
}
}
if(digitalRead(buttonFour) == HIGH) { // check button state
delay(10); // software de-bounce
if(digitalRead(buttonFour) == HIGH) { // check button state again
midiOut.sendControlChange(36,127,1); // send a MIDI CC -- 36 = note, 127 = velocity, 1 = channel
delay(250);
}
}
if(digitalRead(buttonFive) == HIGH) { // check button state
delay(10); // software de-bounce
if(digitalRead(buttonFive) == HIGH) { // check button state again
midiOut.sendControlChange(107,127,1); // send a MIDI CC -- 107 = note, 127 = velocity, 1 = channel
delay(250);
}
}
if(digitalRead(buttonSix) == HIGH) { // check button state
delay(10); // software de-bounce
if(digitalRead(buttonSix) == HIGH) { // check button state again
midiOut.sendControlChange(63,127,1); // send a MIDI CC -- 63 = note, 127 = velocity, 1 = channel
delay(250);
}
}
if(digitalRead(buttonSeven) == HIGH) { // check button state
delay(10); // software de-bounce
if(digitalRead(buttonSeven) == HIGH) { // check button state again
midiOut.sendControlChange(86,127,1); // send a MIDI CC -- 86 = note, 127 = velocity, 1 = channel
delay(250);
}
}
if(digitalRead(buttonEight) == HIGH) { // check button state
delay(10); // software de-bounce
if(digitalRead(buttonEight) == HIGH) { // check button state again
midiOut.sendControlChange(64,127,1); // send a MIDI CC -- 64 = note, 127 = velocity, 1 = channel
delay(250);
}
} |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
Start off from the basic example and then add the buttons to it. You will notice that you are adding unneeded headers and well as a 'floating' Serial connection. Good luck as you learn to code, so much fun! (also, read up on using MarkDown, to make your message more readable) |
Beta Was this translation helpful? Give feedback.
Hi @lautarotanok
Start off from the basic example and then add the buttons to it.
You will notice that you are adding unneeded headers and well as a 'floating' Serial connection.
As you add the buttons, consider using a button debonce library, like this one.
This should get you well underway.
Good luck as you learn to code, so much fun!
(also, read up on using MarkDown, to make your message more readable)