Wheel encoder using an IR sensor
There are two things you should do.
Firstly, implement a little bit of hysterisis. Currently, it look like you're using 200 as the threshold in both the rising and falling direction. What you'll always get with analogue sensors is a bit of noise. This means that, even during a rising edge, you might actually see a tiny falling edge sometimes. You might even see it cross your threshold up, then down, then up again!


The green line shows what you hope your sensor is producing.
The red line shows what it's probably producing. Actually, it's probably much worse than this.
The purple line is what you want
The black line is what you could be getting

So, when the signal is rising, use 200 as your threshold. And when the signal is falling, use something like 150 as a threshold.
Secondly, you could use both the rising and falling edges to calculate your speed. That way you can have twice the update rate.