CtC’s post on this encoder states that, “the LED portion of this sensor will require a 330R resistor and the input pin should be pulled down with a 10k resistor to gnd (if it isn’t allready pulled down on the board itself)”.
Later in his post, he mentions that there is a spot on the attached circuit board to install the 330 ohm resistor.
If you read the comments to the post, you’ll see a discussion about using pull-up Vs pull-down resistors. The Arduino has internal pull-up resistors, which you need to enable.
Your link above shows a stand-alone part, not a breakout board. Also, if you got the parts from Sparkfun, the part you are showing in your link is the old, discontinued part. I would assume you are using the newer version which is a 5-pin, digital unit. The do look alike, but one is analog and one is digital --kinda a big difference.
Also, what does the data sheet say? Is this a 3.3v part or is it 5v?
Before we can do ANYTHING, we need good links to the actual parts you are using. Maybe a picture.
The “encoder wheel” --With the confusion about the sensors, we should be sure you are using the correct wheel as well. You said that the one you have is “like this one”…
Is it a wheel designed for slot-encoders or reflective ones? Can we get a link to the actual part you are using?
I just saw your pictures. --The encoder you are showing will not work the way it is now.
A board (with a part attached to it) that you remove from something does not a break-out board make.
When you buy something from say, sparkfun, the breakout board you can buy for that part is designed to be a stand-alone unit. It will have the needed pull-up resistors, for example. A manufacturer doesn’t always put parts together on the same board. Yes, the encoder itself is attached to that board, but all the resistors needed could be on another board in a different part of the product.
First off, you need to confirm your pin-out. Figure out what side is what for the LED and which is the collector/emmiter for the sensor side. Next, confirm the LED still works. Then, with a multi-meter and a pull-up resistor, see if it actually toggles from low to high as you pass objects through it. Once you know it is working, then write a simple test program --for get about counting wheel revs here, we just need to know if the uC can see the high/low.
Once all that is done, then start working on your code.