2 IR leds
v/I = R
(5-(1.2*2)) / 50mA = R
52ohm = R
3 IR leds
v/I = R
(5-(1.2*3)) / 50mA = R
28ohm = R
For my initial tests I used just a single transistor with 3 IR leds connected. Next was connecting up a single IR detector to the PIC. I initially wanted to trial just one detector and a few IR leds in order to do range tests. More on that later.
I used some PNA4602 detectors (the TSOP4038 seems more common now) which I had purchased from Solarbotics some time ago. Yes, I was buying parts years before I got around to using them. As widely recommended I put a 0.1uF capacitor across the power rail close to the detector. The output of the detector went to pin RB4, one of the interrupt capable pins. I setup in the ISR section that when the detector registered a hit, to turn left (thus changing one of the bicolor leds I've substituted for motors during testing). Due to the blinking led loop I had in the main loop I could see when the detector (and thus ISR) was triggered. Ie when I was in the ISR section the blinking led wouldn't be blinking. Thus I had a double visual check that the detector was working as one of the dual colour leds I was using instead of motors would change color and in addition the blinking status led would stop blinking. Now for range tests.
On my breadboard the IR leds and IR detector were approx a hand length apart and both pointing up at the ceiling. Also I replaced the initial 1K resistor with my Variable resister box so I could adjust the power sent to the IR leds and thus the detector range. So holding a ruler upright I slowly lowered my hand down the ruler. I was looking for two things. When the blinking led (from the main loop) stopped blinking, which would show the ISR had been entered. The second was when the dual color led changed color from red to a solid green (not just a flickering green). The results are below.
In the final circuit I plan to use a 1K variable resistor with the minimum safe resistor in series so I can tune on the fly. The two front IR leds will be on one variable resistor, the left/right/rear IR leds will be on a second variable resistor.