docs

a slatepencil documentail site

View on GitHub

Button

Press one certain key (CH-) of a remote control, both the LED and attached LED will light up, then press any other key, and the LEDS will go out

hardware

wire

Infrared reciver

2-color LED

code

#include <IRremote.h>

const int irReceiverPin = 7;  // the SIG of receiver module attach to pin 7;
const int ledPin = 13;        // built-in LED
IRrecv irrecv(irReceiverPin);
decode_results results;

void setup() {
  pinMode(ledPin, OUTPUT);
  Serial.begin(9600);
  irrecv.enableIRIn();  // enable ir receiver module
}

void loop() {
  if (irrecv.decode(&results)) {  // if the ir receiver module receive data
    Serial.print("irCode: ");
    Serial.print(results.value, HEX);
    Serial.print(", bits: ");
    Serial.println(results.bits);
    irrecv.resume();
  }
  delay(600);
  if (results.value == 0xFFA25D) {  // CH-
    digitalWrite(ledPin, HIGH);
  } else {
    digitalWrite(ledPin, LOW);  // turn off the LED
  }
}