Advertisement
ander_sa

Sinais RC

Dec 7th, 2015
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.74 KB | None | 0 0
  1. #define canal1 13
  2. #include <RCSwitch.h>
  3. RCSwitch mySwitch = RCSwitch();
  4.  
  5. bool led = false;
  6.  
  7. void setup()
  8. {
  9. pinMode(canal1 ,OUTPUT);
  10. digitalWrite(canal1 , LOW);
  11. Serial.begin(9600);
  12. mySwitch.enableReceive(0);
  13. }
  14.  
  15. void loop()
  16.  
  17. {
  18.  
  19. if (mySwitch.available())
  20. {
  21.  
  22. long int value = mySwitch.getReceivedValue();
  23. if (value == 0)
  24.  
  25. {
  26. Serial.println("ERRO DE CODIGO");
  27. }
  28. else
  29. {
  30. Serial.println("Codigo desconhecido");
  31. Serial.println(mySwitch.getReceivedValue());
  32.  
  33. if(value == 5633795)
  34. {
  35.  
  36. if (led)
  37. {
  38. digitalWrite(canal1 , HIGH);
  39. Serial.println("LED LIGADO");
  40. }
  41. else
  42. {
  43. digitalWrite(canal1 , LOW);
  44. Serial.println("LED DESLIGADO");
  45. }
  46.  
  47. led != led;
  48.  
  49. }
  50.  
  51. mySwitch.resetAvailable();
  52.  
  53. }
  54.  
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement