Need Help with IR Sensor Speed Control for Large DC Motor

speed_calc() runs when pin2 recieves a falling edge. It's an ISR triggered by an external interrupt on Pin2, which is in turn connected to the sensor output. The attachInterrupt line in void setup() is where the ISR name is declared.