IR Remote Component Documentation
The IR Remote component is a digital infrared receiver module that allows microcontrollers to receive and decode infrared signals from remote controls. This module is commonly used in various applications, such as home automation, robotics, and consumer electronics.
Technical Specifications:
Operating Voltage: 3.3V to 5V
Operating Current: 10mA to 20mA
Infrared Frequency: 38kHz
Receiver Sensitivity: -40dBm to -10dBm
Response Time: 10ms to 20ms
Interface: Digital output (active low)
### Example 1: Basic IR Remote Usage with Arduino
In this example, we will demonstrate how to use the IR Remote component with an Arduino board to receive and decode infrared signals from a remote control.
Arduino Board (e.g., Arduino Uno)
IR Remote component
Breadboard and jumper wires
Arduino IDE (version 1.8.x or later)
Code:
```cpp
#include <IRremote.h>
const int irReceiverPin = 11; // Pin connected to IR Receiver module
IRrecv irRecv(irReceiverPin);
void setup() {
Serial.begin(9600);
irRecv.enableIRIn(); // Enable infrared input
}
void loop() {
if (irRecv.decode()) {
Serial.print("Received IR signal: ");
Serial.println(irRecv.decodedIRData.decodedRawData, HEX);
irRecv.resume(); // Receive the next signal
}
delay(50);
}
```
In this example, we use the `IRrecv` library to receive and decode infrared signals. We connect the IR Remote component to digital pin 11 on the Arduino board. In the `loop()` function, we use the `decode()` function to receive and decode the infrared signal, and print the received data to the serial console.
### Example 2: Controlling an LED with IR Remote using Raspberry Pi
In this example, we will demonstrate how to use the IR Remote component with a Raspberry Pi to control an LED using infrared signals from a remote control.
Raspberry Pi (e.g., Raspberry Pi 4)
IR Remote component
Breadboard and jumper wires
LED and resistor
Raspbian OS (version 10 or later)
Python 3.x
Code:
```python
import RPi.GPIO as GPIO
import ir_remote
# Set up GPIO pin for LED
LED_PIN = 17
GPIO.setmode(GPIO.BCM)
GPIO.setup(LED_PIN, GPIO.OUT)
# Set up IR Remote receiver
ir_receiver = ir_remote.IRReceiver(18) # Pin connected to IR Receiver module
while True:
if ir_receiver.decode():
if ir_receiver.decodedIRData == 0xFF38C7: # Replace with your desired IR code
GPIO.output(LED_PIN, GPIO.HIGH) # Turn on LED
elif ir_receiver.decodedIRData == 0xFF5AA5: # Replace with your desired IR code
GPIO.output(LED_PIN, GPIO.LOW) # Turn off LED
```
In this example, we use the `ir_remote` library to receive and decode infrared signals. We connect the IR Remote component to GPIO pin 18 on the Raspberry Pi. In the `while` loop, we use the `decode()` function to receive and decode the infrared signal, and control the LED based on the received IR code.
Note: In both examples, you need to replace the IR codes with the actual codes received from your remote control.