Guest User

ReceptorRFarduino

a guest
May 18th, 2017
985
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.74 KB | None | 0 0
  1. #include <LiquidCrystal.h>
  2.  #include <RCSwitch.h>
  3.  
  4. RCSwitch mySwitch = RCSwitch();
  5. LiquidCrystal lcd(12, 11, 6, 5, 3, 4);
  6. int ix;//velocidade loop e transmissao
  7.  
  8. void setup() {
  9.   Serial.begin(9600);
  10. lcd.begin(16, 2);
  11. lcd.setCursor(3, 0);
  12.  lcd.print("iniciando");
  13.  Serial.println("iniciando");
  14.   lcd.setCursor(1, 1);
  15.  lcd.print("Esperando Dados");
  16. delay(555);
  17. ix=0;
  18.  mySwitch.enableReceive(0);  // pino padrao 2
  19. }
  20.  
  21. void loop() {
  22.  
  23.  if (mySwitch.available()) {
  24.     ix=ix+1;
  25.     int value = mySwitch.getReceivedValue();
  26.    
  27.  if (value == 0) {
  28.       lcd.clear();
  29.       lcd.print("Unknown encoding"); //vericando se existe receptor
  30.       Serial.print("Unknown encoding");
  31.     } else {
  32.       lcd.clear();
  33.        lcd.setCursor(11, 1);
  34.        lcd.print("BT:");
  35.       lcd.setCursor(0, 0);          
  36.       lcd.print("Taxa");
  37.                   lcd.print(mySwitch.getReceivedValue());
  38.                   lcd.setCursor(9, 0);
  39.                   //getbits
  40.        
  41.                   lcd.print(mySwitch.getReceivedBitlength());
  42.                   lcd.print( "bit:");  
  43.                   lcd.setCursor(0, 1);
  44.                   lcd.print("CH:");
  45.                   lcd.setCursor(3, 1);
  46.                   lcd.print(mySwitch.getReceivedProtocol());
  47.                   lcd.setCursor(5, 1);
  48.                   lcd.print("VT:");
  49.                   lcd.setCursor(8, 1);
  50.                   lcd.print(ix);
  51.                   if(ix==101){ix=0;}
  52.                  
  53.           }
  54.  
  55.     if(value==110){//Codigo recebido do transmissor
  56.      lcd.setCursor(14, 1);
  57.      lcd.print("ON");            
  58.      }
  59.  
  60.     if(value==111){
  61.      lcd.setCursor(14, 1);
  62.       lcd.print("OF");
  63.      }
  64.  
  65.  mySwitch.resetAvailable(); //reset!
  66.    }
  67.   }
  68. bem10jfx.blogspot.com
Advertisement
Add Comment
Please, Sign In to add comment