KY-022 INFRARED RECEIVER MODULE
Short description :
The KY-022 Infrared Receiver module reacts to 38kHz IR light. It can be used to receive commands from IR remote controllers from TVs, stereos, and other devices.
Working with (Compatible)
Arduino, ESP32, Nodemcu, ESP8266, Raspberry Pi, and ......
ARDUINO IDE CODE
Example description :
the module detects to switch on/off led
#include <IRremote.h>
int led = 13; //Define the LED pin
int RECV_PIN = 11; // define input pin on Arduino
IRrecv irrecv(RECV_PIN);
decode_results results; // decode_results class is defined in IRremote.h
void setup() {
Serial.begin(9600);
irrecv.enableIRIn(); // Start the receiver
pinMode(led,OUTPUT);
}
void loop() {
if (irrecv.decode(&results)) {
Serial.println(results.value, HEX);
irrecv.resume(); // Receive the next value
switch(results.value){
case 0xFFA25D:
digitalWrite(led,HIGH);
break;
case 0xFF629D:
digitalWrite(led,LOW);
break;
}
}
delay (100); // small delay to prevent reading errors
}