I really want to cut some threads this weekend. I was going through my electronics stash and found some goodies.
I have a LED infared emitter and a phototransistor.
I made up a small circuit with a few resistors and hooked it up to an extra arduino I have not in use right now.
I wrote code that reads the analog signal from the phototransistor, and if it's above a threshold variable I set, it sees white, and I set a digital pin high, if it sees black, it goes below a lower threshold and I set the digital pin low.
I tried it on a little DC motor I have lying around and it's working well.
Going to try to hook up that digital pin from my arduino to my G540 and mach3 and see if this works later today. If it works, I will make a black disk with one white stripe on it and put it somewhere on my spindle and mount my phototransistor/emitter setup to read it.
Hopefully this works, I will post back when I get a chance to play around with it.