Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int receive_pin = 2;
- #define MAX 120
- int value[MAX];
- unsigned long time[MAX];
- int changes;
- int printed;
- void setup() {
- Serial.begin(9600);
- pinMode(receive_pin, INPUT);
- changes = 0;
- printed = 0;
- attachInterrupt(0, change_handler, CHANGE);
- Serial.println("Receiver 433MHz setup");
- }
- void change_handler()
- {
- if (changes >= MAX) return;
- value[changes] = digitalRead(receive_pin);
- time[changes] = micros();
- changes++;
- }
- void loop() {
- if (printed + 1 < changes) {
- Serial.println(time[printed+1] - time[printed]);
- printed++;
- }
- }
Add Comment
Please, Sign In to add comment