arduino midi code for a simple keyboard

so i got a grant from my school to do a project involving arduino, midi, and some fsrs. being a music major, i'm not too familiar with arduino yet so i could use some help with the code. the premise here is there are 12 fsrs on a pair of gloves (1 on each of the ten fingers and 1 at the base of each palm). these fsrs are hooked up to a arduino mega with a sparkfun midi shield mounted on it. then, using 4 pairs of infrared emitters and receivers, i'm going to have these positioned by the feet so that when a particular beam is broken, the octave of the notes in the hands switches, either up or down. (no beams being broken is the middle c octave, the two pairs of ir detectors to the right make the octaves go up and the 2 left pair go down). so i have a couple of codes that i've found, one for the shield on sparkfun and the other is a combination of a code i found online and stuff from my arduino cookbook. any help would be appreciated, especially with changing octaves with the emitter/receivers!

// SparkFun MIDI Sheild and MIDI Breakout test code
// Defines bare-bones routines for sending and receiving MIDI data
// Written 02/16/10


// defines for MIDI Shield components only
#define KNOB1  0
#define KNOB2  1

#define BUTTON1  2
#define BUTTON2  3
#define BUTTON3  4

#define STAT1  7
#define STAT2  6

#define OFF 1
#define ON 2
#define WAIT 3

byte incomingByte;
byte note;
byte velocity;
int pot;

byte byte1;
byte byte2;
byte byte3;

int action=2; //1 =note off ; 2=note on ; 3= wait



void setup() {

  pinMode(STAT1,OUTPUT);   
  pinMode(STAT2,OUTPUT);

  pinMode(BUTTON1,INPUT);
  pinMode(BUTTON2,INPUT);
  pinMode(BUTTON3,INPUT);

  digitalWrite(BUTTON1,HIGH);
  digitalWrite(BUTTON2,HIGH);
  digitalWrite(BUTTON3,HIGH);

  for(int i = 0;i < 10;i++) // flash MIDI Sheild LED's on startup
  {
    digitalWrite(STAT1,HIGH);  
    digitalWrite(STAT2,LOW);
    delay(30);
    digitalWrite(STAT1,LOW);  
    digitalWrite(STAT2,HIGH);
    delay(30);
  }
  digitalWrite(STAT1,HIGH);   
  digitalWrite(STAT2,HIGH);

  //start serial with midi baudrate 31250
  Serial.begin(31250);     
}

void loop () {

  //*************** MIDI OUT ***************//

  pot = analogRead(0);
  note = pot/8;  // convert value to value 0-127
  if(button(BUTTON1) || button(BUTTON2) || button(BUTTON3))
  {  
    Midi_Send(0x90,note,0x45);
    while(button(BUTTON1) || button(BUTTON2) || button(BUTTON3));
  }

  //*************** MIDI LOOPBACK ******************//
  if(Serial.available() > 0)
  {
    byte1 = Serial.read();
    byte2 = Serial.read();
    byte3 = Serial.read();

    Midi_Send(byte1, byte2, byte3);
  }

  //*************** MIDI IN ***************//
  if (Serial.available() > 0) {
    // read the incoming byte:
    incomingByte = Serial.read();

    // wait for as status-byte, channel 1, note on or off
    if (incomingByte== 144) // Note on
    { 
      action = OFF;
    }
    else if (incomingByte== 128) // Note off
    { 
      action = ON;
    }
    else if (note==0 && action != WAIT) // note on, wait for note value
    { 
      note=incomingByte;
    }
    else if (note!=0 && action != WAIT)  // velocity
    { 
      velocity=incomingByte;
      if(action == ON){ 
        Midi_Send(0x90,note,velocity); 
      }
      if(action == OFF){ 
        Midi_Send(0x80,note,velocity); 
      }
      note=0;
      velocity=0;
      action=WAIT;
    }
    else{
    }
  }

}

void Midi_Send(byte cmd, byte data1, byte data2) {
  Serial.print(cmd, BYTE);
  Serial.print(data1, BYTE);
  Serial.print(data2, BYTE);
}

void blink(){
  digitalWrite(STAT1, HIGH);
  delay(100);
  digitalWrite(STAT1, LOW);
  delay(100);
}

char button(char button_num)
{
  return (!(digitalRead(button_num)));
}
 const int middleC = 60;    // Middle C (MIDI note value 60) is the lowest note we'll play
 byte note = 0;              // The MIDI note value to be played
 int fsrAnalogPinC = 0;       // FSR is connected to analog 0
 int fsrReadingC;             // the analog reading from the FSR resistor divider
 int AnalogValue = 0;        // value from the analog input
 int lastNotePlayed = 0;     // note turned on when you press the switch
 int lastSwitchState = 0;    // state of the switch during previous time through the main loop
 //int currentSwitchState = 0;

 void setup() {
   //  Set MIDI baud rate:
   Serial.begin(31250);
 }

 void loop() {
   //  My potentiometer gave a range from 0 to 1023:
   AnalogValue = analogRead(0); //not correct, should be digital
   //  convert to a range from 0 to 127:
   note = AnalogValue/8; //same, digital
  
   fsrReadingC = analogRead(fsrAnalogPinC);
   // Check to see that the switch is pressed:
   if (fsrReadingC >= 1) {
     //  check to see that the switch wasn't pressed last time
     //  through the main loop:
     if (lastSwitchState == 0) {
       // set the note value based on the analog value, plus a couple octaves:
       // note = note + 60;
       // start a note playing:
       noteOn(0x90, note, 0x40);
       // save the note we played, so we can turn it off:
       lastNotePlayed = note;
     }
   }
   else {   // if the switch is not pressed:
     //  but the switch was pressed last time through the main loop:
     if (lastSwitchState == 1) {
       //  stop the last note played:
       noteOn(0x90, lastNotePlayed, 0x00);
     }
   }

   //  save the state of the switch for next time
   //  through the main loop:
   lastSwitchState = fsrReadingC;
 }

 //  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(byte cmd, byte pitch, byte velocity {
   Serial.print(cmd, BYTE);
   Serial.print(pitch, BYTE);
   Serial.print(velocity, BYTE);
 }

i only started with one fsr here to testing, but there should eventually be 12.

thanks guys.