LDR midi trigger as laser harp= very basic

HELP!!!
Hi, I’m super new and have been going through all the books and web pages to get an idea on how to make a really simple midi controller where I am using an LDR that has a 1mW red laser shining on it and when the beam is broken the arduino sends a midi noteOn signal of 60 (middleC). That’s really it.

Here’s the code I’ve been using:

// MIDI trigger from LDR with constant laser stream from 1mW laser

#define midichan           1

#define note_midC     60

#define ldrAPin  0
#define ledPin     13  // for midi out status

byte note = 0;
int AnalogValue = 0;

int val,t;

void setup() {

  pinMode(ledPin, OUTPUT);
  Serial.begin(31250);   // set MIDI baud rate
}

void loop() {
// ldr with laser stream
  AnalogValue = analogRead(ldrAPin);
  note = AnalogValue/8;
  if( AnalogValue <= 127 ) {
    t=0;
    while(analogRead(ldrAPin) <= 127/2) {
      t++;
    }
    noteOn(midichan,note_midC, t*2);
    delay(t);
    noteOff(midichan,note_midC,0);
  }
}

// Send a MIDI note-on message.  Like pressing a piano key
// channel ranges from 0-15
void noteOn(byte channel, byte note, byte velocity) {
  midiMsg( (0x90 | channel), note, velocity);
}

// Send a MIDI note-off message.  Like releasing a piano key
void noteOff(byte channel, byte note, byte velocity) {
  midiMsg( (0x80 | channel), note, velocity);
}

// Send a general MIDI message
void midiMsg(byte cmd, byte data1, byte data2) {
  digitalWrite(ledPin,HIGH);  // indicate we're sending MIDI data
  Serial.print(cmd, BYTE);
  Serial.print(data1, BYTE);
  Serial.print(data2, BYTE);
  digitalWrite(ledPin,LOW);
}

[sry had to make the rest of my post a seperate post because the moderator wouldn't allow a web address for first post]

cont.

Essentially the code is a cross between: http://todbot.com/blog/2006/10/29/spooky-arduino-projects-4-and-musical-arduino/comment-page-2/#comments

and

http://itp.nyu.edu/physcomp/Labs/MIDIOutput

can't seem to get it working, and feel like super n00b because it seems like such a simple thing to do.

hardware wise: I'm using the same set-up as todbot, and instead of piezo's I'm using an LDR where the set-up for the LDR analogInput is the same set-up as ITP's one for the force sensor.

Any help or links or suggestions would be very graciously appreciated.

cheers, Diacri