+ Anode (A) - Pin 1
+ Cathode (K) - Pin 2
+ Anode (A) - Pin 1
+ Cathode (K) - Pin 2
+ VCC - Pin 1
+ OUT - Pin 2
+ GND - Pin 3
3mm
1.5mm
1.5mm
Conclusion
The 3mm IR Pair is a versatile and compact infrared transmitter and receiver pair, ideal for use in a wide range of IoT applications. Its low power consumption, high sensitivity, and noise immunity make it an attractive solution for designers and developers of IoT devices.
3mm IR Pair Component DocumentationThe 3mm IR Pair component is a popular IrDA (Infrared Data Association) compliant infrared transmitter and receiver module used for wireless communication over short distances. It consists of an IR LED transmitter and an IR photodiode receiver, both packaged in a 3mm diameter plastic casing.Pinout:IR LED Transmitter:
+ Anode (A): Connect to digital output pin of microcontroller
+ Cathode (K): Connect to ground (GND)
IR Photodiode Receiver:
+ Anode (A): Connect to digital input pin of microcontroller
+ Cathode (K): Connect to ground (GND)Technical Specifications:Wavelength: 940nm
Transmission distance: up to 1 meter
Modulation frequency: 38 kHz
Receiver sensitivity: 10 mV/mACode Examples:### Example 1: Basic IR Communication using ArduinoIn this example, we will demonstrate how to use the 3mm IR Pair component to send and receive data between two Arduino boards.Transmitter Code (Arduino):
```c
const int irLedPin = 2; // IR LED connected to digital pin 2void setup() {
pinMode(irLedPin, OUTPUT);
}void loop() {
// Send a 38 kHz modulation frequency carrier wave
for (int i = 0; i < 100; i++) {
digitalWrite(irLedPin, HIGH);
delayMicroseconds(13); // 38 kHz period
digitalWrite(irLedPin, LOW);
delayMicroseconds(13); // 38 kHz period
}// Send a byte of data (e.g., 0x12)
for (int i = 0; i < 8; i++) {
if ((0x12 >> i) & 0x01) {
digitalWrite(irLedPin, HIGH);
delayMicroseconds(30); // 30 us pulse width
digitalWrite(irLedPin, LOW);
delayMicroseconds(30); // 30 us pulse width
} else {
digitalWrite(irLedPin, LOW);
delayMicroseconds(60); // 60 us pulse width
}
}delay(1000); // wait 1 second before sending next byte
}
```Receiver Code (Arduino):
```c
const int irReceiverPin = 3; // IR receiver connected to digital pin 3
volatile byte receivedData = 0;void setup() {
pinMode(irReceiverPin, INPUT);
attachInterrupt(digitalPinToInterrupt(irReceiverPin), irReceiverISR, CHANGE);
}void loop() {
// Process received data
if (receivedData != 0) {
Serial.print("Received data: 0x");
Serial.println(receivedData, HEX);
receivedData = 0;
}
}void irReceiverISR() {
static byte bitCount = 0;
static byte data = 0;if (digitalRead(irReceiverPin) == HIGH) {
// Rising edge
bitCount++;
data = (data << 1) | 0x01;
} else {
// Falling edge
bitCount++;
data = (data << 1) | 0x00;
}if (bitCount == 8) {
receivedData = data;
bitCount = 0;
}
}
```### Example 2: IR Remotes using Raspberry Pi (Python)In this example, we will demonstrate how to use the 3mm IR Pair component to receive and decode IR remote control signals using a Raspberry Pi.Receiver Code (Python):
```python
import RPi.GPIO as GPIO
import time# Set up GPIO mode
GPIO.setmode(GPIO.BCM)# Define IR receiver pin
ir_receiver_pin = 18# Set up IR receiver pin as input
GPIO.setup(ir_receiver_pin, GPIO.IN, pull_up_down=GPIO.PUD_UP)def decode_ir_signal(channel):
# Read IR signal
signal = []
while True:
signal.append(GPIO.input(ir_receiver_pin))
time.sleep(0.00001) # 10 us sampling rate
if len(signal) > 100:
break# Decode IR signal
# ... implementation of IR signal decoding algorithm ...return decoded_signal# Set up interrupt on IR receiver pin
GPIO.add_event_detect(ir_receiver_pin, GPIO.FALLING, callback=decode_ir_signal)while True:
time.sleep(1) # wait for IR signal
```Note: In this example, we assume a simple IR signal decoding algorithm is implemented in the `decode_ir_signal` function. The actual implementation may vary depending on the specific IR remote control protocol used.