We will use the tiny infrared receiver to read the codes sent by TV or DVD remotes.

HOMEWORK:

2 things to download to your laptop’s desktop:

(1)

“IRREMOTE” library. Use the “download ZIP” button at bottom right on:
https://github.com/shirriff/Arduino-IRremote

 

(2)

The following sketch file:

(CTRL-C copy it, then CTRL-V paste it into either a new arduino “sketch” or into a blank text file in NotePad (& save it as something on desktop for now).

 

 

#include <IRremote.h>
#define DEBUG 1

int RECV_PIN = 8;
IRrecv irrecv(RECV_PIN);

decode_results results;

int LED_PIN = 13;

void setup()
{

  Serial.begin(9600);
  Serial.println("Hello");
  delay(200);
  irrecv.enableIRIn(); // Start the receiver
  Serial.println("IR start");
  digitalWrite(LED_PIN, LOW);
}

void loop() {
  if (irrecv.decode(&results)) {
    if (results.value != 0xFFFFFFFF) {
      digitalWrite(LED_PIN, HIGH);
      Serial.println("Addr / Key:");
      Serial.print(0xff & (results.value >> 16), HEX);   // address 
      Serial.print("    /  ");
      Serial.println((0xFF & results.value), HEX);   // function code
      Serial.println();
      delay(100);
      digitalWrite(LED_PIN, LOW);
    }

    irrecv.resume(); // Receive the next value
  }

}