Advertisement
Krzyspx

UNO+433

Apr 28th, 2016
814
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.37 KB | None | 0 0
  1. /*
  2. * Baza dla sterowania ELWO - nadawanie i odbiór
  3. nadajnik pin 2 - przerwanie 0- odbiornik A5
  4. */
  5.  
  6. #include <RemoteTransmitter.h>
  7. #include <RemoteReceiver.h>
  8.  
  9. // Intantiate a new Elro remote, also use pin 11 (same transmitter!)
  10. ElroTransmitter elroTransmitter(A5);
  11.  
  12. void setup() {
  13.     Serial.begin(115200);
  14.  
  15.   // Initialize receiver on interrupt 0 (= digital pin 2), calls the callback "showCode"
  16.   // after 3 identical codes have been received in a row. (thus, keep the button pressed
  17.   // for a moment)
  18.   //
  19.   // See the interrupt-parameter of attachInterrupt for possible values (and pins)
  20.   // to connect the receiver.
  21.   RemoteReceiver::init(0, 3, showCode);
  22. }
  23.  
  24. void loop() {  
  25.   elroTransmitter.sendSignal(8,'A',true);  // Switch on Elro-device C on system code 1.
  26.  
  27.   delay(2000); // Wait 2 seconds
  28.  
  29.   elroTransmitter.sendSignal(8,'A',false);     // Switch off Elro-device C on system code 1.
  30.    
  31.   delay(4000);  // Wait 4 seconds
  32.   Serial.println("nowy cykl");
  33. }
  34. // Callback function is called only when a valid code is received.
  35. void showCode(unsigned long receivedCode, unsigned int period) {
  36.   // Note: interrupts are disabled. You can re-enable them if needed.
  37.  
  38.   // Print the received code.
  39.   Serial.print("Code: ");
  40.   Serial.print(receivedCode);
  41.   Serial.print(", period duration: ");
  42.   Serial.print(period);
  43.   Serial.println("us.");
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement