Advertisement
Guest User

Untitled

a guest
Sep 30th, 2016
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.34 KB | None | 0 0
  1. //==============================================================================
  2. #include <RCSwitch.h>
  3.  
  4. //Instacia a Biblioteca
  5. RCSwitch mySwitch = RCSwitch();
  6.  
  7. //Conexao 1 (IN1) do motor 1 (M1) = 1N1M1
  8. int led=13;
  9. int valor1 = 1;
  10.  
  11. void setup() {
  12.  
  13. //Seta os Pinos dos Motores como Saida
  14. pinMode(led,OUTPUT);
  15.  
  16. Serial.begin(9600);
  17. // delay para estabilizacao do Sinal
  18. ///////delay(500);
  19. delay(50);
  20.  
  21. //Seta como Receptor/ O "0" é para não interromper, deixar continuo
  22. //O Pino padrão é o 2
  23. mySwitch.enableReceive(0);
  24. }
  25.  
  26. void loop() {
  27.  
  28. //Quado estiver sinal disponivel
  29. if (mySwitch.available()){
  30.  
  31. //recebe na variavel value o Status
  32. long int value = mySwitch.getReceivedValue();
  33.  
  34. if (value == 0) {
  35. Serial.println("Codigo desconhecido");
  36. }
  37. //==============================================================================
  38. if (value == 5635843)
  39. { //Comparaçao de códigos do botão CH+ do controle remoto
  40. if (valor1 == 1)
  41. {
  42. liga_1(); //Chamada da função liga_1
  43. valor1=0;
  44. }
  45. else
  46. {
  47. desl_1(); //Chamada da função desl_1
  48. valor1=1;
  49. }
  50.  
  51.  
  52. void liga_1(){ //função ligar led
  53. digitalWrite(led, HIGH);
  54. }
  55. void desl_1(){ //função desliga o led
  56. digitalWrite(led, LOW);
  57. }
  58.  
  59.  
  60. mySwitch.resetAvailable();
  61. }
  62. }
  63. //==============================================================================
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement