Advertisement
RuiViana

Pseudo_WDog

Oct 25th, 2015
255
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.75 KB | None | 0 0
  1. #include <RCSwitch.h>
  2.  
  3. RCSwitch mySwitch = RCSwitch(); // Instacia a Biblioteca
  4.  
  5. int led=13; // Conexao 1 (IN1) do motor 1 (M1) = 1N1M1
  6. int value =-1; // variavel responsavel em receber os dados do RF
  7. unsigned int WDog = 0;
  8. //-----------------------------------------------------
  9. void setup()
  10. {
  11. pinMode(led,OUTPUT); // Seta os Pinos dos Motores como Saida
  12. Serial.begin(9600);
  13. delay(50); ///delay(500); // delay para estabilizacao do Sinal
  14. //Seta como Receptor/ O "0" é para não interromper, deixar continuo
  15. mySwitch.enableReceive(0); //O Pino padrão é o 2
  16. }
  17. //------------------------------------------------------
  18. void loop()
  19. {
  20. if (mySwitch.available()) //Quado estiver sinal disponivel
  21. {
  22. value = mySwitch.getReceivedValue(); //recebe na variavel value o Status
  23. switch(value)
  24. {
  25. case 0: {
  26. Serial.println("Codigo desconhecido");
  27. WDog = 0;
  28. break;
  29. }
  30. case 1: {
  31. Serial.println(mySwitch.getReceivedValue());
  32. digitalWrite(led, LOW);
  33. WDog = 0;
  34. break;
  35. }
  36. case 2: {
  37. Serial.println(mySwitch.getReceivedValue());
  38. digitalWrite(led, HIGH);
  39. WDog = 0;
  40. break;
  41. }
  42. case 3: {
  43. WDog = 0;
  44. break;
  45. }
  46. }
  47. WDog++;
  48. if (WDog > 1000) digitalWrite(led, HIGH);
  49. mySwitch.resetAvailable();
  50. }
  51. }
  52. //========================================
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement