Push It!
In this installment of the MIDI for the Arduino Series, we will add Push Buttons to the Midi Controller we started building in the last chapter.Before You Start
This tutorial will ONLY work with the Arduino UNO. (Please don't ask if it will work on other Arduino models.) I am using some direct port manipulation in the code that is currently specific to the UNO. I'll let you know if this changes in the future.The Software
To make things simple, I have created a plug and play program that will allow you to customize your controller. All you need to do is tell the software the number of controls you will be using and how these controls should behave and the software will take care of the details. The video explains how to configure the software for your project.Download the software HERE
Quick question, I am using an infrared distance sensor for a high filter pass, is there any way I can invert the signal so the number goes up as it gets closer instead of visa versa?
ReplyDeleteis the signal out of your infrared sensor analogue? If it is, you may be able to use a transistor circuit to invert the signal like you say, but you may be able to also do that through the use of some code in your arduino.
DeleteHello, what do I have to type in the program to change the tone value. For example C -20 (notes tuning)
Deletethis is really interesting, but I just bought a NANO :-( I have never programmed before and have no idea what direct port manipulation is but love the idea of creating my own custom controllers and this looks like a better way to do it than my NOCTURN
ReplyDelete1)Read
Delete3)Practice
2)Git gud
there are lots of tutorials for everything, start with the Arduino IDE, free in the official website
Okay here is a question - can I use an Atmega 328P-PU chip with Arduino UNO boot Loader - essentially this would be an UNO ??? so I can build the whole thing a bit smaller? Thanks
ReplyDeleteHi Mark. Yes you can. I cover that topic in this article http://www.notesandvolts.com/2014/07/fun-with-arduino-arduino-on-proto-board.html
DeleteHi, i have MEGA 2560. i have mailed you my issue please reply.... thanks
ReplyDeleteHello, you could make a tutorial on how to put more analog and digital inputs and outputs to arduino? I'm doing a midi controller and I need more analog and digital connections. In the code that is shared programming but do not know how to connect and configure, you could help me with that?
ReplyDeleteThank you very much
Hi Carlos. Use multiplexers like this http://www.notesandvolts.com/2016/07/arduino-midi-controller-multiplexers.html
Deletehi,fantastic job,,,,is it possible to reduce the volume of the notes as I am using them to set off track play and stop buttons etc and i get this annoying note playing everytime i hit the switch
ReplyDeleteMake sure that there are no other instruments or plug-ins set to the same Midi channel as you transport controls.
DeleteHey Dave, is it posibel to use the code for sending over sreival/usb
ReplyDeleteAwsome Tutorials!! ive been looking for something like this for a long time. I started proototyping this weekand ran into a small problem, when i set the buttons to output CC data(cmd1 or 2) it works until i stop pressing the buttons for 2 or more seconds.
ReplyDeleteIt then somehow forgets to send midi.
BUT strange thing, if i then press a note button the CC buttons work again until i stop pressing them for about 2 seconds. Any Help?
Hi,
ReplyDeleteI used your code and my setup works fine. Thank you for that. I need a little MOD in the code that IF A BUTTON IS PRESSED IT GENERATES A NOTE AND WHEN RELEASED IT GENERATES ANOTHER NOTE.
Please Help.
Thank you.
Is there a way to get this to work with Photocell sensors?
ReplyDeleteplease tell me ,how to create programme change button ?(ex Button BU1(9, 1, 0, 10, 1 );)
ReplyDeleteHello Dave,
ReplyDeleteIs possible to use only USB port to send CC notes to
e.g. example Guitar Rig, without standard MIDI socket?
Kind Regards
Beardini
Sure you can, pal, use HINDUINO, flash it, google for more, I made it ;)
DeleteHi man,
ReplyDeleteCould i use piezo disks for this. I wanna make this by stepping on a 'button'.
Kind regards
If AT ALL possible, could you post a video with this same concept but with a board like the Leonardo that will transmit Midi over USB? A LOT of people would really appreciate it!
ReplyDeleteI really appreciate it!
ReplyDeletei got my controller working but i want to add two led lights to two of the buttons.how do i do that ?
ReplyDeletetry this, it's working for me with 6 buttons with leds:
Deleteconst int ledButtonPin1 = 8;
const int ledLedPin1 = 24;
int buttonState1 = 0;
long time = 0;
long debounce = 200;
void setup() {
pinMode(ledLedPin1, OUTPUT);
pinMode(ledButtonPin1, INPUT);
}
void loop() {
buttonState1 = digitalRead(ledButtonPin1);
if (buttonState1 == HIGH) {digitalWrite(ledLedPin1, LOW);}
else {digitalWrite(ledLedPin1, HIGH);}
}
Hello, using this code for the leds do they work simply put they in the same positive and negative of the switch that they are associeted?
DeleteHi Dave,
ReplyDeleteAmazing tutorials, all of them, thank u very much.
I made a controller with pots and buttons and works perfect. Now i'm to develop a foot controller with 9 DPDT (toggle) footswitchs.
I need 4 of them to work like momentary switches to trigger clips on Ableton Live.
There is any way to modify the buttons setting to make de toggle switches work like momentary?
Something like this but for MIDI:
______________
const int footPin1 = 45;
void setup() {
pinMode (footPin1, INPUT);
Serial.begin(9600);
}
void loop() {
int footA1 = digitalRead (footPin1);
delay(5);
int footB1 = digitalRead (footPin1);
if (footA1 != footB1)
{digitalWrite(footPin1, HIGH);
Serial.println(1);
}
else
{digitalWrite(footPin1, LOW);
Serial.println(0);
}
}
MUCHAS GRACIAS!!!!!!
I'm only using CC command parametrs, can i change any configuration on toggle (case2)?
DeleteSolved!
DeleteSet the Command Parameter of the footswitchs to "2" them made some mods on the "void updateButtons()" settings.
Thanx again for all the tutorials and the controller program!
___________________________________
void updateButtons() {
// Cycle through Button array
for (int i = 0; i < NUMBER_BUTTONS; i = i + 1) {
byte message = BUTTONS[i]->getValue();
// Button is pressed
if (message == 1) {
switch (BUTTONS[i]->Bcommand) {
case 0: //Note
MIDI.sendNoteOn(BUTTONS[i]->Bvalue, 127, BUTTONS[i]->Bchannel);
break;
case 1: //CC
MIDI.sendControlChange(BUTTONS[i]->Bvalue, 127, BUTTONS[i]->Bchannel);
break;
case 2: //Toggle
if (BUTTONS[i]->Btoggle != message) {
MIDI.sendControlChange(BUTTONS[i]->Bvalue, 127, BUTTONS[i]->Bchannel);
BUTTONS[i]->Btoggle = 0;
}
else if (BUTTONS[i]->Btoggle == message) {
MIDI.sendControlChange(BUTTONS[i]->Bvalue, 0, BUTTONS[i]->Bchannel);
BUTTONS[i]->Btoggle = 0;
}
break;
}
}
// Button is not pressed
if (message == 0) {
switch (BUTTONS[i]->Bcommand) {
case 0:
MIDI.sendNoteOff(BUTTONS[i]->Bvalue, 0, BUTTONS[i]->Bchannel);
break;
case 1:
MIDI.sendControlChange(BUTTONS[i]->Bvalue, 0, BUTTONS[i]->Bchannel);
break;
case 2: //Toggle
if (BUTTONS[i]->Btoggle != message) {
MIDI.sendControlChange(BUTTONS[i]->Bvalue, 0, BUTTONS[i]->Bchannel);
BUTTONS[i]->Btoggle = 0;
}
else if (BUTTONS[i]->Btoggle == message) {
MIDI.sendControlChange(BUTTONS[i]->Bvalue, 127, BUTTONS[i]->Bchannel);
BUTTONS[i]->Btoggle = 0;
}
break;
}
}
}
}
Hi people, I'm wondering that if anyone knows how to implement a 4x4 button matrix to this project. Cheers! :)
ReplyDeleteWatch the Multi Plexer tutorial.
Deletecan I use a cadmium light sensor instead of a button I am trying to make a laser harp so when the laser is interrupted it send a midi cc to ableton any help please
ReplyDeleteanyone else having issues compiling the midi library with the controller code. I am able to compile the MIDI_Input code with no problem but the MIDI_Controller code is not. Any ideas? here is the error:
ReplyDeletelibraries/MIDI/MIDI.cpp.o (symbol from plugin): In function `midi::encodeSysEx(unsigned char const*, unsigned char*, unsigned int)':
(.text+0x0): multiple definition of `midi::encodeSysEx(unsigned char const*, unsigned char*, unsigned int)'
sketch/MIDI.cpp.o (symbol from plugin):(.text+0x0): first defined here
libraries/MIDI/MIDI.cpp.o (symbol from plugin): In function `midi::encodeSysEx(unsigned char const*, unsigned char*, unsigned int)':
(.text+0x0): multiple definition of `midi::decodeSysEx(unsigned char const*, unsigned char*, unsigned int)'
sketch/MIDI.cpp.o (symbol from plugin):(.text+0x0): first defined here
collect2: error: ld returned 1 exit status
exit status 1
Error compiling for board Arduino Nano.
Thanks Dave. Yours are the only tutorials that make it crystal clear of what is what etc. regarding DIY Midi on Arduino controllers. Two questions.
ReplyDelete1. I'm using a joystick for two of the analog inputs but I can'f figure out how to make one way Pitch Bend. I didn't find a MIDI CC number for that. Is that done a different way?
2. Toggle switch/ Rotary switch to shift octaves? 7 ocatves with a 7 postion rotary would be awesome. Could it be done analogue as well?
I guess that's more than two. Tia
Thanks Dave!! I would like to switch banks in a guitar processor, using 3 buttons one foot to change the channel and to move forward and backward. How do you define the buttons?
ReplyDeleteHi! I want to use this as a stomp box midi controller to control my looper. My first question is, how would I go about using stronger momentary switches that would connect to the encolsure? Woould it just be about wiring them down into the breadboard? I see only two pin ones everywhere. Second would be how to add a midi thru/out jack if I wanted to run another devices midi clock through this pedal? Thanks!
ReplyDeleteHi,
ReplyDeleteThis is great stuff!!! Forgive my ignorance, as I know nothing about coding (I'm just a lowly guitar player). But if I wanted to add program changes to the command parameters, would it be as simple as adding 3=PC and a case 3 with MIDI.sendProgramChange? Thanks so much!
This comment has been removed by the author.
ReplyDeleteI'm really stuck. I've tried to add a case 3 with a MIDI.sendProgramChange, but I keep getting errors. Anyone know what I'm doing wrong?
ReplyDeleteAh, I figured out that I had to remove the value because program changes don't have a value. Now I'm not getting any errors, but it still doesn't work. Pressing a button assigned to a program change always makes the device go to the first program, no matter which CC number I've given it. AAAARG!
ReplyDeleteEVerything works perfect for the MIDI buttons. Is there any way to modify the code to incorporate the dmxsimple library so I only need to use one Arduino to trigger a dmx scene when I press one of the MIDI buttons?
ReplyDeleteDo you have a link where I can buy good quality buttons ?
ReplyDeleteAnd the MIDI socket as well!
ReplyDeletecool project, got me hooked up, so...
ReplyDeleteim now using:
Bu1, on pin8, sends cc, on my 4th note, ch1... but i want my 4th note to be on value 90... how do i do that?
How would you add a rotary encoder with push button with sample code
ReplyDeleteHi Dave, first of all i really thank you for your efforts for this Arduino MIDI controller project.
ReplyDeleteI want to make a simple MIDI program change device with 128 push buttons. I learned so much from you post. but i am new to coding or i can say i don't know much about coding.
i want to accomplish this MIDI program change project on Arduino MEGA 2560.
Please help me on this for coding.
any help really appreciated.
Thanks.
Code compiles w/o issue, but won't load.
ReplyDeletetried the Blink program same result
and
<avrdudestk500_getsync()
wiring quadruple checked OK.
I even tried different brand new Nano boards (from Amazon) with nothing wired I got the same result
Any ideas??
Weird, some of my comment didn't get thru....
ReplyDelete<arvdude: stk500_recv() : Programmer not responding
and <avrdude:stk500_getsync() attempt 10 of 10: not in sync: resp=0xa9
Hello, what do I have to type in the program to change the tone value. For example C -20 (notes tuning)
ReplyDeleteHi,
ReplyDeleteIf I wanted each button to activate three notes simultaneously so as to trigger a chord with each button pressed would I just add two extra lines of code for each button each containing a different note value would it be done some other way? Thanks.
Never mind I figured it out eventually.
DeleteArduino: 1.8.13 (Windows 10), Board: "Arduino Uno"
ReplyDeleteC:\Users\georg\AppData\Local\Temp\cc1Y8lBr.ltrans0.ltrans.o: In function `global constructors keyed to 65535_0_MIDI_Controller_v1_2.ino.cpp.o.1912':
:(.text.startup+0x12e): undefined reference to `Button::Button(unsigned char, unsigned char, unsigned char, unsigned char, unsigned char)'
:(.text.startup+0x13c): undefined reference to `Button::Button(unsigned char, unsigned char, unsigned char, unsigned char, unsigned char)'
:(.text.startup+0x14a): undefined reference to `Button::Button(unsigned char, unsigned char, unsigned char, unsigned char, unsigned char)'
:(.text.startup+0x158): undefined reference to `Button::Button(unsigned char, unsigned char, unsigned char, unsigned char, unsigned char)'
C:\Users\georg\AppData\Local\Temp\cc1Y8lBr.ltrans0.ltrans.o: In function `updateButtons':
C:\Users\georg\AppData\Local\Temp\arduino_modified_sketch_461154/MIDI_Controller_v1-2.ino:144: undefined reference to `Button::getValue()'
collect2.exe: error: ld returned 1 exit status
Multiple libraries were found for "MIDI.h"
Used: C:\Users\georg\OneDrive\Documents\Arduino\libraries\MIDI
Not used: C:\Users\georg\OneDrive\Documents\Arduino\libraries\arduino_midi_library-master
exit status 1
Error compiling for board Arduino Uno.
This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.
After reading the post , I got some descriptive information which is very helpful for me. Thanks for posting it. Keep it up. microsonic ultrasonic sensors
ReplyDeleteIs it possible to use pins that are not included in the software, such as pins 10, 11, 12, 13 and even A0, A1, ..., A5?
ReplyDeleteI mean adding buttons as BU10, BU11 and such
DeleteWONDERFUL Post.thanks for share..more wait.
ReplyDeleteDogforum.co.uk
Information
Click Here
Visit Web
I made it. 11 buttons, one serve as "shift", so I have 20 effective switches. Added 6 LEDs for Power, Shift and 4 for presets within a bank. Box is 3D printed. I had to add some code to get Shift working and LEDs turned on/off in a correct manner. Your code was great base for that, as I am not a programmer and it took some time (and help from my friend) to figure out how to do it. I may publish entire project on Thingiverse or github, if I have time.
ReplyDeleteHi all! Does it could work with a Arduino leonardo Midi Usb (i want to use CC change buttons) ? tks
ReplyDelete