Guest User

Untitled

a guest
Mar 19th, 2018
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.59 KB | None | 0 0
  1. int receive_pin = 2;
  2.  
  3. #define MAX 120
  4. int value[MAX];
  5. unsigned long time[MAX];
  6. int changes;
  7. int printed;
  8.  
  9. void setup() {
  10. Serial.begin(9600);
  11. pinMode(receive_pin, INPUT);
  12.  
  13. changes = 0;
  14. printed = 0;
  15. attachInterrupt(0, change_handler, CHANGE);
  16. Serial.println("Receiver 433MHz setup");
  17. }
  18.  
  19. void change_handler()
  20. {
  21. if (changes >= MAX) return;
  22. value[changes] = digitalRead(receive_pin);
  23. time[changes] = micros();
  24. changes++;
  25. }
  26.  
  27. void loop() {
  28. if (printed + 1 < changes) {
  29. Serial.println(time[printed+1] - time[printed]);
  30. printed++;
  31. }
  32. }
Add Comment
Please, Sign In to add comment