Guest User

Untitled

a guest
Aug 27th, 2016
351
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.58 KB | None | 0 0
  1. #include <tiny_IRremote.h>
  2.  
  3. int RECV_PIN = 3; //infrared receiver
  4. int out = 0; //LED
  5.  
  6. IRrecv irrecv(RECV_PIN);
  7.  
  8. decode_results results;
  9.  
  10. void setup()
  11. {
  12.   irrecv.enableIRIn(); // Start the receiver
  13.   pinMode(out,OUTPUT);
  14. }
  15.  
  16. void loop() {
  17.   if (irrecv.decode(&results)) {
  18.     // The value of the button on my remote is 1CE3926D
  19.     if(results.value == 0x1CE3926D){
  20.       if(digitalRead(out) == HIGH){
  21.         digitalWrite(out,LOW);
  22.       }
  23.       else
  24.       {
  25.         digitalWrite(out,HIGH);
  26.       }
  27.     }
  28.     irrecv.resume(); // Receive the next value
  29.   }
  30.   delay(100);
  31. }
Advertisement
Add Comment
Please, Sign In to add comment