Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * Baza dla sterowania ELWO - nadawanie i odbiór
- nadajnik pin 2 - przerwanie 0- odbiornik A5
- */
- #include <RemoteTransmitter.h>
- #include <RemoteReceiver.h>
- // Intantiate a new Elro remote, also use pin 11 (same transmitter!)
- ElroTransmitter elroTransmitter(A5);
- void setup() {
- Serial.begin(115200);
- // Initialize receiver on interrupt 0 (= digital pin 2), calls the callback "showCode"
- // after 3 identical codes have been received in a row. (thus, keep the button pressed
- // for a moment)
- //
- // See the interrupt-parameter of attachInterrupt for possible values (and pins)
- // to connect the receiver.
- RemoteReceiver::init(0, 3, showCode);
- }
- void loop() {
- elroTransmitter.sendSignal(8,'A',true); // Switch on Elro-device C on system code 1.
- delay(2000); // Wait 2 seconds
- elroTransmitter.sendSignal(8,'A',false); // Switch off Elro-device C on system code 1.
- delay(4000); // Wait 4 seconds
- Serial.println("nowy cykl");
- }
- // Callback function is called only when a valid code is received.
- void showCode(unsigned long receivedCode, unsigned int period) {
- // Note: interrupts are disabled. You can re-enable them if needed.
- // Print the received code.
- Serial.print("Code: ");
- Serial.print(receivedCode);
- Serial.print(", period duration: ");
- Serial.print(period);
- Serial.println("us.");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement