Hi,
Complete novice when it comes to Arduino and programming. I picked up an Uno last Friday with a view to making some weird MIDI instruments and so far I’ve managed to get it to switch a note on with one button and hold that note until I turn it off with another button.
What I’ve been trying to figure out how to do is get it to play three notes simultaneously with one button and then hold them until I switch those notes off again with the same button.
The next step from there would be to map those chords to a pot, then a joystick etc etc.
Here’s the code I’m using. Any help would be massively massively appreciated because I have no knowledge of programming whatsoever and I’m finding the process really difficult and frustrating. Basically assume that I have the same level of intelligence as a 4 year old child and go from there!
#include <MIDI.h>
int velocity = 100;//velocity of MIDI notes, must be between 0 and 127
int noteON = 144;//144 = 10010000 in binary, note on command
int noteOFF = 128;
int buttonBpin = 8;
int buttonApin = 9;
void setup() {
// Set MIDI baud rate:
Serial.begin(31250);
pinMode(buttonBpin, INPUT_PULLUP);
pinMode(buttonApin, INPUT_PULLUP);
}
void loop()
{
if (digitalRead(buttonApin) == LOW)
for (int note =50;note=50;note++) {//note 50
MIDImessage(noteON, note, velocity);//turn note on
delay (200); //wait 200ms
break; }
if (digitalRead(buttonBpin) == LOW)
for (int note =50;note=50;note++) {//note 50
MIDImessage(noteOFF, note, 0); //turn note off
delay (200); //wait 200ms
break;}
}
//send MIDI message
void MIDImessage(int command, int MIDInote, int MIDIvelocity) {
Serial.write(command);//send note on or note off command
Serial.write(MIDInote);//send pitch data
Serial.write(MIDIvelocity);//send velocity data
}