I assume you get 12V from your car? In that case your resistor should be 56 ohm if you want 100mA LED current. You don't want the kickback diode. It is required for inductive loads, but LEDs are a resistive load.
You risk burning the Arduino pin. I believe it is 5.5V tolerant? You should put a Zener diode on the gate of the MOSFET to limit its voltage.
Also check that the FET you are using turns fully on with 5V at the gate.
As the question does not state which digital IR Transmitter and Receiver modules are in use, this answer explains how infrared data communication can be achieved using simply a generic IR LED, and a modulated IR receiver such as Vishay's TSOP17xx or other similar parts.
Assumptions:
- IR LED chosen can be driven with 20 mA current, e.g. IR333
- TSOP1756 sensor is to be used (56 KHz modulation).
- Change modulation frequency according to actual part used in sensor module. For TSOP11 38, for instance, modulation frequency is 38 KHz.
Receiving:
This is the easy part. Simply connect the OUT pin of the sensor to the serial RX pin of your Arduino (digital Pin 0). If your Arduino is one of the basic (older) models, use Serial.read()
in loop()
:
int inputByte = 0;
if (Serial.available() > 0) {
// read the incoming byte:
inputByte = Serial.read();
// Do stuff with this byte, then loop again
For the Arduino Mega or Due, you can also use Serial1, Serial2 or Serial3, depending on which RX pin you use.
For additional reference, see the Arduino Serial reference.
N.B. Power the sensor with the same voltage as your Arduino actually runs its microcontroller at, either 3.3 or 5 Volts depending on Arduino model. Each Arduino board has a suitable voltage output pin you can use for this. Do not use the external supply (7 to 12 Volts typically) provided to the Arduino board.
Transmitting:
You have two options: (1) Arduino, LED and passive components, or (2) using an additional logic gate component. The first option is good for low-current IR LEDs (20-30 mA tops):
simulate this circuit – Schematic created using CircuitLab
- When the TX pin is high, the LED will be pulsed at the modulation frequency. When TX pin is low, the LED will not light up, and the small-signal diode in series will protect the LED from reverse breakdown.
- If your Arduino is the 3.3 Volt type, then the small-signal diode is not really essential.
For driving a higher current LED, an additional logic component, a quad AND gate such as SN74AS1008 can be used. This part sources or sinks up to 48 mA per gate, and multiple gates can be paralleled for higher current drive.
- Connect the Timer1 output as set up above, to one input of each of the AND gates.
- Connect the TX output as mentioned above, to the second input of each of the AND gates.
- Connect a current limiting resistor of suitable value to each output pin of these 4 AND gates - such that the sum of the 4 output currents equals the desired drive current on the LED
- Connect the other ends of the 4 current limiting resistors to the Anode of the LED, with the Cathode connected to Arduino ground.
- You may have to supply the AND gate's Vcc from an external (5 Volts) power supply, since the Arduino's on-board regulator will overheat if too much current is drawn through it. Make sure the ground of this external supply is connected to Arduino GND.
simulate this circuit
Now simply use Serial.write()
in your Arduino loop()
code, to transmit any serial data, which will be received by the Serial.read()
at the other end, as described previously.
Best Answer
According to your link "The KY-005 Infrared Transmitter Module consists of just a 5mm IR LED.". This is confirmed in this YouTube video (image below is from the video).
Infrared is not visible to the human eye, but you can check to see if it is emitting light using the camera in a cell phone or laptop computer.
Connecting it directly to the Arduino I/O pin produces the most light, but relies on the internal resistance of the port to limit current. This is safe provided no other pins are driving heavy loads (ATmega328 absolute maximum current for all MCU pins combined is 200mA). It should still work with a resistor, but with shorter range. With 220Ω it should draw about 15mA, which is around half the current it draws with a direct connection.
Note: do not connect the 'signal' input directly to +5V, as it will burn out the LED!