I am trying use my Arduino to control a guitar pedal, a DigiTech Whammy via MIDI, the pedal has a single MIDI In that can be used to control every funtion of the pedal. On the pedal there is a mode select dial, this sweeps through 17 different modes of pitch shift. So far I have found a sketch that has given me the ability to sweep through each mode continuously. Or I can create sequences for the mode change to follow.
Want I want, is a circuit and sketch that will allow me to choose when it advances to the next mode with a momentary footswitch. I have searched a lot to try and find a sketch that will allow me to use a single footswitch to control the Whammy in this way without success, I have attached a second code at the bottom which gave me A result, but not the correct result. Instead of advancing through each mode, it only jumps back and forth between two modes.
If anyone can help that would be amazing, I am still new to Arduino so I apologise if the problem is quite simple to fix.
Thanks!!
Here is the sketch that simply sweeps through each mode:
#define DLY 90
#define MIN 0
#define MAX 125
void setProgram(uint8_t p) {
Serial.write((uint8_t)0xC0);
Serial.write((uint8_t)p);
}
void setup() {
Serial.begin(31250);
}
void loop() {
setProgram(0); //This loop simply sweeps through each mode that the pedal has.
delay(DLY);
setProgram(1);
delay(DLY);
setProgram(2);
delay(DLY);
setProgram(3);
delay(DLY);
setProgram(4);
delay(DLY);
setProgram(5);
delay(DLY);
setProgram(6);
delay(DLY);
setProgram(7);
delay(DLY);
setProgram(8);
delay(DLY);
setProgram(9);
delay(DLY);
setProgram(10);
delay(DLY);
setProgram(11);
delay(DLY);
setProgram(12);
delay(DLY);
setProgram(13);
delay(DLY);
setProgram(14);
delay(DLY);
setProgram(15);
delay(DLY);
setProgram(16);
delay(DLY);
}
The code that gave almost the correct results, it switches between two modes, the switching is also quite flaky and if the button is held down it switches between the two modes erratically:
//Button 1
int ledPin = 12; //led output
int buttonPin = 10; //button input pin
int buttonVal = 0; //variable for reading the button status
int buttonState = 0; //variable to hold the buttons current state
int bounceCheck = 0; //variable for debouncing
void setup() {
pinMode(ledPin, OUTPUT); //declare LED as output
pinMode(buttonPin, INPUT); //declare pushbutton as input
Serial.begin(31250); //MIDI communicates at 31250 baud
}
void loop()
{
////////////////////////////TOGGLE////////////////////////////////////
buttonVal = digitalRead(buttonPin); //read input value from button
delay(5); //wait 10ms
bounceCheck = digitalRead(buttonPin); //check again
if(buttonVal == bounceCheck){ //if val is the same then not a bounce
if (buttonVal == HIGH && buttonState == 1) { //check if the input is HIGH
digitalWrite(ledPin, HIGH); //turn LED OFF
midiOUT(0xC0, 0, 1); //Note ON (CH 1), C1, velocity 127
buttonState = 0;
}
if(buttonVal == LOW && buttonState == 0){
digitalWrite(ledPin, LOW); //turn LED ON
midiOUT(0xC0, 0, 0); //Note ON (CH 1), middle C1, velocity 0
buttonState = 1;
}
}
}
void midiOUT(char command, char value1, char value2) {
Serial.print(command);
Serial.print(value1);
Serial.print(value2);
}