IR Remote Code Example 1

/*
   IRremote: IRrecvDemo - demonstrates receiving IR codes with IRrecv
   An IR detector/demodulator must be connected to the input RECV_PIN.
   Version 0.1 July, 2009
   Copyright 2009 Ken Shirriff
   http://arcfn.com
*/

#include <IRremote.h>

int RECV_PIN = 11;
int irVal;
String working1;
String working2;

IRrecv irrecv(RECV_PIN);

decode_results results;

void setup()
{
  Serial.begin(9600);
  // In case the interrupt driver crashes on setup, give a clue
  // to the user what's going on.
  Serial.println("Enabling IRin");
  irrecv.enableIRIn(); // Start the receiver
  Serial.println("Enabled IRin");
}

void loop() {
  if (irrecv.decode(&results)) {
    irVal = results.value;
    delay(10);
//    Serial.println(irVal);
    working1 = dCode(irVal);
     if (working1 != "Repeat") {
      working2 = working1;
    }
    Serial.println(working2);
    irrecv.resume(); // Receive the next value
  }
  delay(100);
}

String dCode(int val) {
  String ansVal;
  switch (val) {
    case 16738455:
      ansVal = "One";
      return ansVal;
      break;
    case 16750695:
      ansVal = "Two";
      return ansVal;
      break;
    case 16756815:
      ansVal = "Three";
      return ansVal;
      break;
    case 16724175:
      ansVal = "Four";
      return ansVal;
      break;
    case 16718055:
      ansVal = "Five";
      return ansVal;
      break;
    case 16743045:
      ansVal = "Six";
      return ansVal;
      break;
    case 16716015:
      ansVal = "Seven";
      return ansVal;
      break;
    case 16726215:
      ansVal = "Eight";
      return ansVal;
      break;
    case 16734885:
      ansVal = "Nine";
      return ansVal;
      break;
    case 16730805:
      ansVal = "Zero";
      return ansVal;
      break;
    case 16728765:
      ansVal = "Star";
      return ansVal;
      break;
    case 16732845:
      ansVal = "Pound";
      return ansVal;
      break;
    case 16736925:
      ansVal = "Forward";
      return ansVal;
      break;
    case 16761405:
      ansVal = "Right";
      return ansVal;
      break;
    case 16754775:
      ansVal = "Reverse";
      return ansVal;
      break;
    case 16720605:
      ansVal = "Left";
      return ansVal;
      break;
    case 16712445:
      ansVal = "OK";
      return ansVal;
      break;
    default:
      ansVal = "Repeat";
      return ansVal;
      break;

  }
}