Hello everyone I'm working on a Arduino midi foot controller, its real simple just two button that scrolls up and down, and has an expression pedal input, and runs through serial.
I would like to add a LCD that would display the patch name and or number from the FX Unit that it will be controlling. If I need to add a midi in port that shouldn't be a problem.
Any ideas? I searched but couldn't find any examples of what I'm trying to achieve. This is my current code sorry if its a bit sloppy its all borrowed code. It compiled fine and works good!
#include <MIDI.h>
MIDI_CREATE_DEFAULT_INSTANCE();
#define expPin A0
int currentVal = 0;
int lastVal = 0;
int progNo = 0;
int upLastTime, downLastTime, upNow, downNow;
void setup() {
MIDI.begin();
MIDI.setInputChannel(1);
pinMode(2, INPUT);
pinMode(3, INPUT);
digitalWrite(2, HIGH); // enable pull up
digitalWrite(3, HIGH); // enable pull up
upLastTime = digitalRead(2);
downLastTime = digitalRead(3);
}
void loop(){
currentVal = analogRead(expPin);
currentVal = map(currentVal, 150, 700, 0, 127);
currentVal = constrain(currentVal, 0, 127);
if(abs(currentVal-lastVal) > 1)
{
MIDI.sendControlChange(1, currentVal, 1);
}
lastVal = currentVal;
delay(1);
upNow = digitalRead(2);
downNow = digitalRead(3);
if (upNow == HIGH && upLastTime == LOW) {
progNo++; // increment program change
if(progNo > 95) progNo = 0; // stop it going too high
MIDI.sendProgramChange(byte(progNo), 1);
delay(20); // bit of debounce delay
}
if (downNow == HIGH && downLastTime == LOW) {
progNo--; // decrement program change
if(progNo < 0) progNo = 95; // stop it going too low
MIDI.sendProgramChange(byte(progNo), 1);
delay(20); // bit of debounce delay
}
upLastTime = upNow;
downLastTime = downNow;
delay(50);
}