Advertisement
Jorge_moises

Codígo do Receptor

Nov 14th, 2015
142
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.53 KB | None | 0 0
  1. // O modulo maior é o Receptor
  2.  
  3. #include <LiquidCrystal595.h> // Biblioteca LCD com 595
  4. LiquidCrystal595 lcd (2,3,4); // Porta de saida com 595
  5.  
  6. #include <VirtualWire.h>
  7. int valorRecebido;
  8. char recebidoChar [4];
  9.  
  10. int valorRecebido2;
  11. char recebidoChar2 [4];
  12.  
  13. void setup(){
  14. lcd.begin (16,2);
  15. Serial.begin(9600);
  16. vw_set_rx_pin (8); // Ligado ao pino 8 e ao data do Receptor
  17.  
  18. vw_setup(3000); // Velocidade de comunicação
  19. vw_rx_start();
  20. Serial.println (" Recebendo os dados do Transmissor");
  21. }
  22. void loop(){
  23. uint8_t buf[VW_MAX_MESSAGE_LEN];
  24. uint8_t buflen = VW_MAX_MESSAGE_LEN;
  25. if(vw_get_message(buf, &buflen)){
  26. int i;
  27. for(i=0; i < buflen; i++){
  28. recebidoChar[i] = char (buf[i]); // Armazena os caracter recebidos
  29. }
  30.  
  31. recebidoChar [buflen] = '\0';
  32. valorRecebido = atoi(recebidoChar);
  33. lcd.setCursor (0,0);
  34. lcd.print ("Umidade ");
  35. lcd.print (recebidoChar); // Mostra na serial o valor recebido do Emissor
  36. Serial.println (recebidoChar);
  37. }
  38. }
  39.  
  40. void dois(){
  41. uint8_t buf[VW_MAX_MESSAGE_LEN];
  42. uint8_t buflen = VW_MAX_MESSAGE_LEN;
  43. if(vw_get_message(buf, &buflen)){
  44. int z;
  45. for(z=0; z < buflen; z++){
  46. recebidoChar2[z] = char (buf[z]); // Armazena os caracter recebidos
  47. }
  48.  
  49. recebidoChar2 [buflen] = '\0';
  50. valorRecebido2 = atoi(recebidoChar2);
  51. lcd.setCursor (0,1);
  52. lcd.print ("Temperatura ");
  53. lcd.print (recebidoChar2); // Mostra na serial o valor recebido do Emissor
  54. Serial.println (recebidoChar);
  55. }
  56. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement