Help building Arduino IR based Tachometer

I'm trying to build a simple arduino IR based tachometer for measuring a DC motor RPM. I used the code below, adjusting it to suit my needs. Thing is: I don't know if I'm doing this right, so I would appreciate some tips. Below are the images of the tachometer I've build: |500x299 |500x299 OBS: The purple LED is the IR emitter, while the another one is the phototransistor (receiver).

I'm using the following code:

 * Optical Tachometer
 * Uses an IR LED and IR phototransistor to implement an optical tachometer.
 * The IR LED is connected to pin 13 and ran continually.
 * Pin 2 (interrupt 0) is connected across the IR detector.
 * Code based on:
 * Coded by:

int ledPin = 13;                // IR LED connected to digital pin 13
volatile byte rpmcount;
unsigned int rpm;
unsigned long timeold;

int enableA = 11;
int motorA1 = 10;
int motorA2 = 9;

void rpm_fun()
   //Each rotation, this interrupt function is run twice, so take that into consideration for 
   //calculating RPM
   //Update count

void setup()

  pinMode(enableA, OUTPUT);
  pinMode(motorA1, OUTPUT);
  pinMode(motorA2, OUTPUT);

  digitalWrite(enableA, HIGH);
  digitalWrite(motorA1, HIGH);
  digitalWrite(motorA2, LOW);

   //Interrupt 0 is digital pin 2, so that is where the IR detector is connected
   //Triggers on FALLING (change from HIGH to LOW)
   attachInterrupt(0, rpm_fun, FALLING);

   //Turn on IR LED
   pinMode(ledPin, OUTPUT);
   digitalWrite(ledPin, HIGH);

   rpmcount = 0;
   rpm = 0;
   timeold = 0;


 void loop()
   //Update RPM every second
   //Don't process interrupts during calculations
   //Note that this would be 60*1000/(millis() - timeold)*rpmcount if the interrupt
   //happened once per revolution instead of twice. Other multiples could be used
   //for multi-bladed propellers or fans
   rpm = 3*1000/(millis() - timeold)*rpmcount;
   timeold = millis();
   rpmcount = 0;

   //Print out result to lcd

   //Restart the interrupt processing
   attachInterrupt(0, rpm_fun, FALLING);

And those are the RPM's I've measured using this tachometer: 84 157 152 160 131 94 116 115 103 84 197 24 2 0 1 102 154 252 95 27 22 33 120 35 98 149 136 152 150 127

Am I doing something wrong?

Google slotted optocoupler. Perfect for what you are doing