Time to start thinking about how to drive/sense the IR pair.
Here's what I'm using...
5mm Infrared Transmitting LED
Infrared Phototransistor
I have to re-learn all about LEDs and how an IR pair works. In my first build, I kind of just wired up the circuit and plugged things in to the correct places, and it worked. This time I'm going to be driving the pair from the Arduino so I need to know voltage, current requirements, etc. I recall that LEDs are current-driven devices and there was a voltage drop across the LED, and you used a resistor to limit the current and you could chain multiple LEDs and if the voltage was sufficient to cross all LEDs then you got light
So I'm thinking the transmitter will have a minimum voltage - we're able to supply 5V from the Arduino so that can power the transmitter directly. The receiver is going to be analog, and we'll get into how to detect that later on. For now, let's get that transmitter lit up.
Going to use the mobile phone camera to detect when the LED is lighting up (because it's infrared, and I know the camera sees those wavelengths and conveniently converts down to a visible wavelength when displayed on its screen). I think what's required is a simple current-limiting resistor between the pin and the IR diode and sufficient voltage and it should light up. The long lead is positive, so I guess I'll just give that a quick test and see how that goes.
"Be sure to connect your LED correctly! The long leg is positive and connects to the resistor, then to the Arduino’s output pin. The short leg is negative and is connected to ground (GND)."
So, data sheet, what's the current requirements for the xmit IR diode? Mmh... that would be forward current...? Says 50 mA - 200 mA. I see it says "duty 1/10 @ 1KHz". OK I think by "continuous forward current 50mA" I think it's saying that IF you are going to power it constantly then 50mA is the maximum. However, if you use 1/10 duty cycle at 1KHz then you can send 200mA. I'm not going to worry about that too much - just have to keep the current under 40mA for the Arduino pin.
So, 5V from the Arduino 5V pin, 40 mA - that's 5/0.04 ohms resistor = 125 ohms. << WRONG! Need to take account of the voltage drop across the LED.
Let's be conservative and go with 150 or thereabouts.
- LED.jpg (290.42 KiB) Viewed 13624 times
OK, wiring is 5V pin on the Arduino connects to 150 ohm resistor, connects to the long lead of the IR transmit LED, then short pin back to the GND pin on the Arduino. And it's lit up. How easy was that! The voltage drop of the LED should be counted when calculating the resistor. Looking at the data sheet, that's probably the forward current vs. forward voltage graph and I see we're looking at about 1.4 V. This would make the voltage "across" the resistor (5-1.4) = 3.6V and then allowing 30mA just to be conservative we get 3.6/0.03 = 120 ohm resistor. I tested with a 150 ohm, and that would give 24 mA which is just fine.
Edit: 20 mA is recommended!So, 3.6/0.02 = 180 ohms - so next time I do a test I'll use that.
The Arduino Micro has its own limits; per I/O pin it's just 20 mA, with 10 mA recommended. For the 5V I've been unable to find the recommended or maximum current.