How to Use IR Transmitter and Receiver with Arduino
In the world of electronics and programming, Arduino has become a popular platform for beginners and enthusiasts alike. One of the many applications of Arduino is the use of infrared (IR) transmitters and receivers. These devices are widely used for various purposes, such as remote control, home automation, and wireless communication. In this article, we will guide you on how to use IR transmitter and receiver with Arduino, step by step.
First, let’s understand the basic components involved. An IR transmitter is a device that sends out infrared signals, while an IR receiver is designed to capture these signals. When used together, they can enable communication between devices, allowing you to control electronic appliances, receive signals, or even build your own remote control system.
To begin, you will need the following components:
1. Arduino board (e.g., Arduino Uno)
2. IR transmitter module (e.g., TSOP1738)
3. IR receiver module (e.g., TSOP1738)
4. Breadboard
5. Jumper wires
6. Power supply (e.g., 5V)
7. LED (optional)
Now, let’s proceed with the setup:
1. Connect the IR transmitter module to the Arduino board:
Connect the VCC pin of the IR transmitter module to the 5V pin on the Arduino board.
Connect the GND pin of the IR transmitter module to the GND pin on the Arduino board.
Connect the OUT pin of the IR transmitter module to a digital pin on the Arduino board (e.g., pin 3).
2. Connect the IR receiver module to the Arduino board:
Connect the VCC pin of the IR receiver module to the 5V pin on the Arduino board.
Connect the GND pin of the IR receiver module to the GND pin on the Arduino board.
Connect the OUT pin of the IR receiver module to a digital pin on the Arduino board (e.g., pin 2).
3. Optional: Connect an LED to the Arduino board:
Connect the anode (longer leg) of the LED to the 5V pin on the Arduino board.
Connect the cathode (shorter leg) of the LED to a digital pin on the Arduino board (e.g., pin 4).
Add a 220 ohm resistor in series with the LED to limit the current.
4. Upload the following code to the Arduino board:
“`cpp
int irReceiverPin = 2;
int ledPin = 4;
void setup() {
pinMode(irReceiverPin, INPUT);
pinMode(ledPin, OUTPUT);
}
void loop() {
if (digitalRead(irReceiverPin) == HIGH) {
digitalWrite(ledPin, HIGH);
} else {
digitalWrite(ledPin, LOW);
}
}
“`
This code reads the signal from the IR receiver module and turns on the LED when a signal is detected. You can modify the code to perform different actions based on the received signal.
Now you have successfully connected and programmed the IR transmitter and receiver with Arduino. You can use this setup to control electronic appliances, receive signals, or even build your own remote control system. Happy hacking!