one led/ldr combination gives a square wave OK.
if we place the second one not exactly in sync with the first but a few mm further
+-------+ +-------+
| LED1 | | LED2 |
+-------+ +-------+
+-----+ +------+ +------+ +-------+
+-------+ +-------+
| PHR1 | | PHR2 |
+-------+ +-------+
If the chain moves to the right PHR1 sees the hole a small fraction earlier than PHR2 sees its hole
If the chain moves to the left PHR1 sees the hole a small fraction later than PHR2 sees its hole
connect PHR1 to an IRQ routine (RISING) and use something like this.
volatile int direction;
void IRQ()
{
if (digitatalRead(PHR2) == LOW) direction = RIGHT; // or CW
else direction = LEFT; // CCW;
count++; // for the speed
}
Practical problem might be dirt, => do the photoresistors above the chain so gravity works with you...; The leds are needed so it will also work at night