Hi,
I'm currently working on a project to create a midi controller to control guitar rig and other guitar software. I have designed and manufactured my pedal board and gathered all of the components I need. I am now just struggling to master the code
My aim is to have 14 foot switches, 1 potentiometer and 5 LEDs. I am using an arduous nano.
So far I am struggling to get 1 button working. All I want it to do is select the previous preset. In guitar rig, it does this once then resets the action. It is not reconsigned as a midi command in any other program.
Here is my code so far.
// set pin numbers:
const int buttonPin = 2; // the number of the pushbutton pin
const int ledPin = 13; // the number of the LED pin
int buttonState = 0; // variable for reading the pushbutton status
void setup() {
// Set MIDI baud rate:
Serial.begin(31250);
pinMode(ledPin, OUTPUT);
}
void loop() {
// assign midi note
int Cnote = 0x30;
// read the state of the pushbutton value:
buttonState = digitalRead(buttonPin);
// check if the pushbutton is pressed.
// if it is, the buttonState is HIGH:
if (buttonState == HIGH) {
// Play midi note: Note on channel 1 (0x90), some note variable in this case (Cnote), middle velocity (0x45):
noteOn(0xB1, 70, 127);
// turn LED on to indicate successful button press:
digitalWrite(ledPin, HIGH);
// delay to supress stuttering
delay(1000);
}
else {
// turn LED off:
digitalWrite(ledPin, LOW);
}
}
// plays a MIDI note. Doesn't check to see that
// cmd is greater than 127, or that data values are less than 127:
void noteOn(int cmd, int pitch, int velocity) {
Serial.write(cmd);
Serial.write(pitch);
Serial.write(velocity);
}