Sensing mechanical alignment

I need to detect the moment when alignment holes on two (relatively slow moving) mechanical arms are lined-up with each other so they can be locked together with a pin that moves out (via a solenoid). The obvious choice would be an LED on one side and a photodetector on the other. Is there a more elegant (preconfigured) solution?

If I am right I think this is a difficult problem. Just using an LED will tell you the holes are overlapping but will not tell you they are exactly aligned.
Maybe it is because it is late but I can't think of a way to do this.
What size are the holes?

If you use some kind of Led and photodetector, you won't detect perfect alignment. But if you use some kind of tapered pin, you should be able to shove the pin into the holes if they are imperfectly aligned, and the act of shoving in the pin will align the holes. A lot of manual operations work this way.

If you want to detect perfect alignment, you could set up a camera and some kind of machine vision system, to determine that the holes are aligned properly when the image looking through the hole is perfect round and not oval or crescent-shaped. This would probably be overkill.

You could possibly set up an arrangement using limit switches on the arm near the hole, to detect the precise position when alignment is achieved.

Thanks. However, when the holes are partially overlapped the measured intensity will be lower and as they become aligned the signal should peak. The trick, I suppose, is to identify the peak before it starts dropping off on the other side. There is something called a position sensitive photodiode which I imagine could allow a specific alignment state to be identified but I haven't found a vendor/reasonable part yet.

If there's a stationary point on the leading rotational arms you could use a potentiometer. Just sense the resistance through arduino and then you'd have a 'count' of exactly where the arm is so you can time the pin to jump in the hole (i'd still taper the top just a bit) at the exact point of resistance.

Just an idea.

Is there room for two sensors?- with one, as pointed out above, you might only detect an imperfect overlap, but with two you might get a better idea of (almost) full alignment.

Using light in this way is not as simple as you might think. The change between a partially aligned hole and a fully aligned one is minuscule and will be almost impossible to detect. Just think of how much of the sun has to be obscured in an eclipse before you can detect any difference in the light.
Some sort of imaging sensor sounds like your best bet.

What are the dimensions of the holes and pin? Are we talking 0.000" type fit? or 0.030" loose?

Well, I was planning on putting the alignment indicator above the actual holes (since they need to be clear to allow the pin to slide in). The pin is tapered (as suggested above) so now there is a fair bit of slop -- say +/- 0.1" I am imagining an LED on one end of a 2" long 1/4" diameter tube (the other end could have a smaller aperture) that lines up with a similar tube on the second arm with a photodiode on the far end of of the tube and maybe a small aperture (0.1" diameter drill hole) on the front side. This still seems clunky.

I don't mean to de-rail the whole plan here but would it be possible to have a spring between the solenoid plunger and the pin, run the detection apparatus you described, and fire the solenoid a little early? The spring pressure between solenoid and pin would cause the pin to drag across just outside the hole, but you don't have to be near as accurate. The moment the holes are perfect, the tapered pin should seat completely, or engage completely.

Or, depending on what type of material we're talking (I'm assuming steel), it might not hurt to not even run a spring and just engage the solenoid early. If the pin is made out of 4140 pre hard, it won't hurt it just dragging across 1018 mild steel. Might make a groove in the mild steel, depending on how many times you're planning on doing this; and how much force the solenoid is applying. If it's a lot, you could put a bronze 660 tip on the pin.

Just a thought

Are the parts moving at a constant speed? Are they moving in concert relative to a fixed part?
You can detect a threshold of light that corresponds to partial overlap and then delay the right
time before operating the solenoid - if the motion is constant.
If they move in concert you really only need to detect the position of one w.r.t the stationary parts,
and a microswitch can do this if a suitable cam or lump is placed on the arm. Adjust the microswitch
position to tune the operation.