SHARE
TWEET

Untitled

a guest Jun 20th, 2019 71 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include "IRremote.h"
  2.  
  3. int receiver = 11; // Signal Pin of IR receiver to Arduino Digital Pin 11
  4.  
  5. /*-----( Declare objects )-----*/
  6. IRrecv irrecv(receiver);     // create instance of 'irrecv'
  7. decode_results results;      // create instance of 'decode_results'
  8.  
  9. void setup()   /*----( SETUP: RUNS ONCE )----*/
  10. {
  11.   Serial.begin(9600);
  12.   Serial.println("IR Receiver Button Decode");
  13.   irrecv.enableIRIn(); // Start the receiver
  14.  
  15. }/*--(end setup )---*/
  16.  
  17.  
  18. void loop()   /*----( LOOP: RUNS CONSTANTLY )----*/
  19. {
  20.   if (irrecv.decode(&results)) // have we received an IR signal?
  21.  
  22.   {
  23.     translateIR();
  24.     irrecv.resume(); // receive the next value
  25.   }  
  26. }/* --(end main loop )-- */
  27.  
  28. /*-----( Function )-----*/
  29. void translateIR() // takes action based on IR code received
  30.  
  31. // describing Remote IR codes
  32.  
  33. {
  34.  
  35.   switch(results.value)
  36.  
  37.   {
  38.  
  39.   case 0xFFA25D: //1
  40.      digitalWrite(2, HIGH);
  41.      delay(2000);
  42.      digitalWrite(2, LOW);
  43.      break;
  44.  
  45.   case 0xFF629D: //2
  46.      Serial.println(" FORWARD");
  47.      break;
  48.  
  49.   case 0xFFE21D: //3
  50.      Serial.println(" FORWARD");
  51.      break;
  52.  
  53.   case 0xFF22DD: //4
  54.      Serial.println(" FORWARD");
  55.      break;
  56.  
  57.   case 0xFF02FD: //5
  58.      Serial.println(" FORWARD");
  59.      break;
  60.  
  61.   case 0xFFC23D: //6
  62.      Serial.println(" FORWARD");
  63.      break;
  64.  
  65.   case 0xFFE01F: //7
  66.      Serial.println(" FORWARD");
  67.      break;
  68.  
  69.   case 0xFFA857: //8
  70.      Serial.println(" FORWARD");
  71.      break;
  72.  
  73.   case 0xFF906F: //9
  74.      Serial.println(" FORWARD");
  75.      break;
  76.  
  77.   case 0xFF9867: //0
  78.      Serial.println(" FORWARD");
  79.      break;
  80.  
  81.   case 0xFF6897: //*
  82.      Serial.println(" FORWARD");
  83.      break;
  84.  
  85.   case 0xFFB04F: //#
  86.      Serial.println(" FORWARD");
  87.      break;
  88.  
  89.   case 0xFF18E7: //up
  90.      Serial.println(" FORWARD");
  91.      break;
  92.  
  93.   case 0xFF10EF: //left
  94.      Serial.println(" FORWARD");
  95.      break;
  96.  
  97.   case 0xFF5AA5: //right
  98.      Serial.println(" FORWARD");
  99.      break;
  100.  
  101.   case 0xFF4AB5: //down
  102.      Serial.println(" FORWARD");
  103.      break;
  104.  
  105.   case 0xFF38C7: //OK
  106.      Serial.println(" FORWARD");
  107.      break;
  108.  
  109.    
  110.  
  111.    
  112.  
  113.   default:
  114.     Serial.println(" other button   ");
  115.  
  116.   }// End Case
  117.  
  118.   delay(500); // Do not get immediate repeat
  119.  
  120.  
  121. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top