Advertisement
alveoten

Untitled

May 4th, 2018
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.71 KB | None | 0 0
  1. #include <IRremote.h>
  2.  
  3. int RECV_PIN = 11;
  4.  
  5. IRrecv irrecv(RECV_PIN);
  6.  
  7. decode_results results;
  8.  
  9. void setup()
  10. {
  11. Serial.begin(9600);
  12. // In case the interrupt driver crashes on setup, give a clue
  13. // to the user what's going on.
  14. Serial.println("Enabling IRin");
  15. irrecv.enableIRIn(); // Start the receiver
  16. Serial.println("Enabled IRin");
  17. }
  18.  
  19. unsigned int last_read = 0;
  20. int last_index = 0;
  21. int readed[10];
  22.  
  23. void loop() {
  24. if (irrecv.decode(&results)) {
  25. if(millis()-last_read > 1000){
  26. last_index = 0;
  27. }
  28. else{
  29. last_index++;
  30. }
  31.  
  32. readed[last_index] = results.value;
  33. last_read = millis();
  34. irrecv.resume(); // Receive the next value
  35. }
  36. delay(100);
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement