Infrared Receiver, Remote Control

아두위키 : Arduwiki
ArduWiki (토론 | 기여)님의 2024년 3월 24일 (일) 12:41 판
(차이) ← 이전 판 | 최신판 (차이) | 다음 판 → (차이)


Infrared Receiver

  • A sensor that receives and outputs infrared signals in the 38KHz band.
  • It is capable of reception only.

IR Remote Control

  • A remote control device that transmits signals receivable by the infrared receiver.

Specifications

Infrared Receiver

  • Operating Voltage: 2.7V ~ 5.5V
  • Reception Angle: Approximately 90 degrees
  • Infrared Frequency: 38KHz

Remote Control

  • Operating Voltage: 5V
  • Frequency: 38KHz

Hardware

  • Arduino Uno
  • Infrared Receiver, Remote Control
  • LED 5mm
  • 220-ohm Resistor
  • Jumper cables

Connection

Arduino Uno Infrared Receiver LED Resistor
5V VCC
GND GND -
A0 connection
D8 +
OUT connection

Libraries (Install via Library Manager)

  • IRremote by shirriff
  • z3t0
  • ArminJo

Arduino Libraries

Example Code

Checking Infrared Reception Values per Button Press

Displays the value corresponding to the pressed button on the remote control to the serial monitor.

#include <IRremote.h>

#define irOut A0

IRrecv irrecv(irOut);

void setup() {
  Serial.begin(9600);
  Serial.println("Serial start");
  irrecv.enableIRIn();
}

void loop() {
  if (irrecv.decode()) {
    Serial.println(irrecv.decodedIRData.decodedRawData);
    irrecv.resume();
  }
}

Main Code

Turns on the LED when a button on the remote control is pressed.

#include <IRremote.h>

#define irOut A0

IRrecv irrecv(irOut);

void setup() {
  Serial.begin(9600);
  Serial.println("Serial start");
  irrecv.enableIRIn();
}

void loop() {
  if (irrecv.decode()) {
    Serial.println(irrecv.decodedIRData.decodedRawData);
    irrecv.resume();
  }
}

Execution Result