Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <LiquidCrystal.h>
- #include <RCSwitch.h>
- RCSwitch mySwitch = RCSwitch();
- LiquidCrystal lcd(12, 11, 6, 5, 3, 4);
- int ix;//velocidade loop e transmissao
- void setup() {
- Serial.begin(9600);
- lcd.begin(16, 2);
- lcd.setCursor(3, 0);
- lcd.print("iniciando");
- Serial.println("iniciando");
- lcd.setCursor(1, 1);
- lcd.print("Esperando Dados");
- delay(555);
- ix=0;
- mySwitch.enableReceive(0); // pino padrao 2
- }
- void loop() {
- if (mySwitch.available()) {
- ix=ix+1;
- int value = mySwitch.getReceivedValue();
- if (value == 0) {
- lcd.clear();
- lcd.print("Unknown encoding"); //vericando se existe receptor
- Serial.print("Unknown encoding");
- } else {
- lcd.clear();
- lcd.setCursor(11, 1);
- lcd.print("BT:");
- lcd.setCursor(0, 0);
- lcd.print("Taxa");
- lcd.print(mySwitch.getReceivedValue());
- lcd.setCursor(9, 0);
- //getbits
- lcd.print(mySwitch.getReceivedBitlength());
- lcd.print( "bit:");
- lcd.setCursor(0, 1);
- lcd.print("CH:");
- lcd.setCursor(3, 1);
- lcd.print(mySwitch.getReceivedProtocol());
- lcd.setCursor(5, 1);
- lcd.print("VT:");
- lcd.setCursor(8, 1);
- lcd.print(ix);
- if(ix==101){ix=0;}
- }
- if(value==110){//Codigo recebido do transmissor
- lcd.setCursor(14, 1);
- lcd.print("ON");
- }
- if(value==111){
- lcd.setCursor(14, 1);
- lcd.print("OF");
- }
- mySwitch.resetAvailable(); //reset!
- }
- }
- bem10jfx.blogspot.com
Advertisement
Add Comment
Please, Sign In to add comment