I am a cellist and organist and I am trying to convert a 32 note organ pedal board to MIDI for practice at home. I am using the book “MIDI and ARDUINO: organ bass pedal encoders” by Tom Scarff. I plan to use an ARDUINO Mega 2560. I don’t know anything about entering or programming code. I haven’t bought the ARDUINO so it is not connected to my laptop yet. After entering the whole program and verifying I get the following error messages:
C:\Users\macon\OneDrive\Documents\Arduino\Arduino12345\Arduino12345.ino: In function 'void loop()':
C:\Users\macon\OneDrive\Documents\Arduino\Arduino12345\Arduino12345.ino:79:5: error: 'noteOff' was not declared in this scope
noteOff(MIDIchannel,note,velocity);
^~~~~~~
C:\Users\macon\OneDrive\Documents\Arduino\Arduino12345\Arduino12345.ino:79:5: note: suggested alternative: 'noteff'
noteOff(MIDIchannel,note,velocity);
^~~~~~~
noteff
C:\Users\macon\OneDrive\Documents\Arduino\Arduino12345\Arduino12345.ino: In function 'void noteOn(byte, byte, byte)':
C:\Users\macon\OneDrive\Documents\Arduino\Arduino12345\Arduino12345.ino:138:19: error: lvalue required as left operand of assignment
midiMsg((0x90 = channel), note + startNote + octave,
^~~~~~~
exit status 1
Compilation error: 'noteOff' was not declared in this scope
This is how I entered the program:
//PROGRAM: A design with an 32 switch encoder circuit, to produce Bass pedal outputs,
//with Octave UP/DOWN switches.
//variables setup
int octave = 0;
int midiByte;
byte MIDIchannel = 2;// midi channel 3
byte channel;
byte x;
byte LedPin = 13; // select the pin for the LED
byte count;
byte note;
byte velocity = 100;
byte currentSwitch = 0;
int startNote = 36;
//32 bass switches + octave and Channel up + octave down switches = 36 switch inputs-
byte switches[36] = {
22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,8,9,10,11
};
byte switchState[36] = {
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
};
//---------------------------------------------
void setup(){
//Set Inputs for Octave up/down Switches
pinMode(8, INPUT_PULLUP);
pinMode(9, INPUT_PULLUP);
//Set Inputs for Channel up/down Switches
pinMode(10, INPUT_PULLUP);
pinMode(11, INPUT_PULLUP);
//pins 22 to 53 corresponding to switches 1 to 32
for (x = 22;x < 54;x++){
pinMode(x, INPUT);
digitalWrite(x, HIGH);
}
//declare the LED's pin as output
pinMode(LedPin, OUTPUT);
for (x = 1; x <= 4;x++){
digitalWrite( LedPin, HIGH );
delay(300);
digitalWrite( LedPin, LOW );
delay(300);
}
//start serial with midi baudrate 31250
Serial.begin(31250);
Serial.flush();
}
//----------------------------------------
void loop(){
//scan 32 switches on inputs
for (int n = 0;n < 32;n++) {
currentSwitch = digitalRead(switches[n]);
//switch pressed and NOT pressed previously
if (currentSwitch == LOW &&switchState[n] == LOW)
{
switchState[n] = HIGH;
note = n;
noteOn(MIDIchannel, note, velocity);
}
// switch released AND pressed previosly
if ( currentSwitch == HIGH && switchState[n] ==
HIGH){
switchState[n] = LOW;
note = n;
noteOff(MIDIchannel,note,velocity);
}
}
//-----------------------------------
//scan 2 Octave and Channel switches on inputs
for (int n = 32;n < 36; n++){
currentSwitch = digitalRead(switches[n]);
// switch pressed and NOT pressed previosly
if (currentSwitch == LOW && switchState[n] == LOW)
{
//---------------------------------------------------
if (n == 32){
octave = octave + 12;
if (octave >= 12){
octave = 12;
}
}
//----------------------
if (n == 33){
octave = octave - 12;
if (octave <= -12){
octave = -12;
}
}
//---------------------
if (n == 34){
MIDIchannel = MIDIchannel + 1;
if (MIDIchannel >= 15){
MIDIchannel = 15;
}
}
//-------------------------
if (n == 35){
MIDIchannel = MIDIchannel - 1;
if (MIDIchannel <= 0){
MIDIchannel = 0;
}
}
switchState[n] = HIGH;
}
// switch released AND pressed previosly
if (currentSwitch == HIGH && switchState[n] ==
HIGH){
switchState[n] = LOW;
}
}
delay(20);
}
//---------------------------------
//Send a MIDI note-on message.
void noteOn(byte channel, byte note, byte velocity){
midiMsg((0x90 = channel), note + startNote + octave,
velocity);
}
//Send a MIDI note-off message.
void noteff(byte channel, byte note, byte velocity){
midiMsg((0x80 + channel), note + startNote + octave,
velocity);
}
//Send a general MIDI message
void midiMsg(byte cmd, byte data1, byte data2)
{
digitalWrite(LedPin, HIGH);
Serial.write(cmd);
Serial.write(data1);
Serial.write(data2);
digitalWrite(LedPin,LOW);
}
//---------------------------------------------------------------------
I am wondering what did I do wrong.
Sincerely
Dr. Juan Jose Gutierrez