noam76

IR Sender Arduino

Oct 23rd, 2019
346
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // ## https://github.com/z3t0/Arduino-IRremote/ ##
  2.  
  3. // IR Transmitter
  4. #include <IRremote.h>
  5. IRsend irsend;
  6. void setup()
  7. {
  8.  delay(200);
  9.  irsend.sendNEC(volume_down, 32);
  10. }
  11.  
  12. void loop()
  13. {
  14. }
  15.  
  16. // IR Receiver
  17. #include <IRremote.h>
  18. const int RECV_PIN = 7;
  19. IRrecv irrecv(RECV_PIN);
  20. decode_results results;
  21.  
  22. void setup(){
  23.   Serial.begin(9600);
  24.   irrecv.enableIRIn();
  25.   irrecv.blink13(true);
  26. }
  27.  
  28. void loop(){
  29.   delay(5000); //5 second delay between each signal burst
  30.   if (irrecv.decode(&results)) {
  31.     if (results.decode_type == NEC) {
  32.       Serial.print("NEC: ");
  33.     } else if (results.decode_type == SONY) {
  34.       Serial.print("SONY: ");
  35.     } else if (results.decode_type == RC5) {
  36.       Serial.print("RC5: ");
  37.     } else if (results.decode_type == RC6) {
  38.       Serial.print("RC6: ");
  39.     } else if (results.decode_type == UNKNOWN) {
  40.       Serial.print("UNKNOWN: ");
  41.     }
  42.     Serial.println(results.value, HEX);
  43.     irrecv.resume(); // Receive the next value
  44.   }
  45. }
Advertisement
Add Comment
Please, Sign In to add comment