Hi, I have an interesting task here - i want to sit something on the rim of a roulette wheel, and get a +5v logic signal while the red pocket is infront of this 'something', and 0v (or close to it) while its not. The problem is the lighting conditions are indoors, and shadows may be cast, so i want it to automatically calibrate somehow to these effects. The wheel also has a green pocket, which i dont want to triger. I have a selection of photodiodes i purchased for experimentation - and im considering how to go about this. I could use an A2D, like a PIC16f877, it has an internal A2D, but i think its too slow. My tests show that i can only get a reading every 10ms, i need a lot more than that. So this is why i would like to make an analogue circuit that would be 'biased' to logic levels, for a simple '1' or '0' depending. But then the lighting conditions come into play ... also the green may trigger it. Im really not sure how to do it. what if i was to have a red led, and a suitable 'visible light' photodiode, and take a reading with the led off, then with the led on (over and over again) and use the difference to workout if its right. OR compare readings to a 2nd photodiode which is unaffected by the led output. or something like that - but the problem with that is it needs A2D, and thats too slow. The wheel has 37 pockets, and spins at about 2 1/2 seconds per rotation, leaving me about 15 pockets per second to check - but its not enough to get '1 pocket per reading', i need a much higher resolution than that. Im not sure im explaining it right, but how would any of you go about setting something like this up ? Any suggestions would be great! Alex.