123456789101112131415161718192021222324252627282930313233343536373839404142 |
- // Define which pins to use for different tasks
- const int rxPinA = 7; // 433MHz RX, Connected to pin 7
- const int ledPin = 17; // The RX LED has a defined Arduino pin
- // This code is only run once at startup
- void setup()
- {
- // Setup mode of each pin that we will use
- pinMode(ledPin, OUTPUT); // Set LED-pin as an output
- pinMode(rxPinA, INPUT);
- // Call the function that configures the interrupts
- cli(); // Clear interrupt
- setup_timer_interrupt();
- sei(); // Enable interrupt
- // Setup the different serial communication channels
- Serial.begin(9600); // Serial monitor (Over USB, when debugging with Arduino)
- Serial1.begin(9600); // HW-UART (To Raspberry)
- }
- // This code is called over and oven again
- void loop()
- {
- static uint16_t width; // Stores the length of the received pulse
- static unsigned long totalRx = 0; // The total number of received pulses
- if ( rcvDeQueue(&width) ) {
-
- totalRx++; // Increase the total received pulses
- // Check if the received pulse is within limits for a start-pulse
- if ( 3400 <= width && width <= 3800 ) {
- Serial.print("Received one ! Total pulses: ");
- Serial.println(totalRx);
- }
- }
- }
|