Figuring out wiring of optical encoder
This is a simple optointerruptor.  One side is an IR LED and the other side is a single photodiode or phototransistor.  It will detect the presence or absence of an object in the slot.  In this case, it will detect the slots in the wheel.  You'll need to figure out which side is which.  I presume the side with the red wire is the LED.  You'll need to power it through a decent current limiting resistor, try 330 ohms if you want to use 5 volts.  The detector on the other side is probably a phototransistor.  One lead should be grounded and the other one connected to power with a pull up resistor, 1k to 10k.  You may have to experiment with the polarity.