Ler controle de remoto de portão com Arduino

Posted by

Este artigo é parte de uma série de posts antigos que estou trazendo de volta para o blog, com o objetivo de não deixar se perder. Hoje vamos ler o código de controle remoto de portão (não funciona com rolling code, tipo Peccinin).

O código está abaixo:

/*
  Simple example for receiving
 
  https://github.com/sui77/rc-switch/
*/
 
#include <RCSwitch.h>
 
RCSwitch mySwitch = RCSwitch();
int oldvalue;
int value;
 
void setup() {
  Serial.begin(9600);
  mySwitch.enableReceive(0);  // Receiver on interrupt 0 => that is pin #2
}
 
void loop() {
  if (mySwitch.available()) {
   
    oldvalue = value;
    value = mySwitch.getReceivedValue();
    if (value == oldvalue){
       
      } else{
   
    if (value == 0) {      
      Serial.println("Codigo desconhecido");
    } else {
        Serial.print("Recebido: ");
        Serial.print( mySwitch.getReceivedValue() );      
        Serial.print(" / ");
        Serial.print( mySwitch.getReceivedBitlength() );
        Serial.print("bit ");
        Serial.print("Protocolo: ");
        Serial.println( mySwitch.getReceivedProtocol() );
       
        }
   
    mySwitch.resetAvailable();
  }
}
}

E o vídeo do teste está abaixo:

Uma resposta

Deixe um comentário

O seu endereço de email não será publicado. Campos obrigatórios marcados com *