Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <RCSwitch.h>
- RCSwitch mySwitch = RCSwitch();
- unsigned long Received;
- #define LED1 3 // LED1 na porta 3
- #define LED2 4 // LED1 na porta 4
- //----------------------------------------------------------
- void setup()
- {
- Serial.begin(9600);
- mySwitch.enableReceive(0); // Receiver on inerrupt 0 => that is pin #2
- }
- //----------------------------------------------------------
- void Aciona()
- {
- switch (Received)
- {
- case 5633795:
- {
- digitalWrite(LED1 , 1);
- break;
- }
- case 5633804:
- {
- digitalWrite(LED2 , 1);
- break;
- }
- }
- }
- //----------------------------------------------------------
- void loop()
- {
- if (mySwitch.available())
- {
- int value = mySwitch.getReceivedValue();
- if (value == 0)
- {
- Serial.print("Unknown encoding");
- }
- else
- {
- Serial.print("Received ");
- Serial.print( mySwitch.getReceivedValue() );
- Received =( mySwitch.getReceivedValue() );
- Aciona();
- Serial.print(" / ");
- Serial.print( mySwitch.getReceivedBitlength() );
- Serial.print("bit ");
- Serial.print("Protocol: ");
- Serial.println( mySwitch.getReceivedProtocol() );
- }
- mySwitch.resetAvailable();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement