/* 
   Código demonstrativo para a aula de Bancos de Dados aplicados à Internet das Coisas,
   Curso de Engenharia e Administração de Sistemas de Banco de Dados,
   Faculdade de Tecnologia - UNICAMP.
*/ 

#include <IRremote.hpp>

const int RECV_PIN = A0;

void setup() {
  
  Serial.begin(9600);
  
  IrReceiver.begin(RECV_PIN, ENABLE_LED_FEEDBACK);
  
}

void loop() {
  
  if (IrReceiver.decode()) {
    
      IrReceiver.printIRResultShort(&Serial);
      Serial.println();

      Serial.println("Address");
      Serial.println("------------------------------------");
      Serial.print("Decimal: ");
      Serial.println(IrReceiver.decodedIRData.address, DEC);
      Serial.print("Hexa: ");
      Serial.println(IrReceiver.decodedIRData.address, HEX);
      Serial.print("Octal: ");
      Serial.println(IrReceiver.decodedIRData.address, OCT);
      Serial.print("Binario: ");
      Serial.println(IrReceiver.decodedIRData.address, BIN);
      Serial.println();
    
      Serial.println("Command");
      Serial.println("------------------------------------");
      Serial.print("Decimal: ");
      Serial.println(IrReceiver.decodedIRData.command, DEC);
      Serial.print("Hexa: ");
      Serial.println(IrReceiver.decodedIRData.command, HEX);
      Serial.print("Octal: ");
      Serial.println(IrReceiver.decodedIRData.command, OCT);
      Serial.print("Binario: ");
      Serial.println(IrReceiver.decodedIRData.command, BIN);
      Serial.println();
    
      Serial.println("Raw Data");
      Serial.println("------------------------------------");
      Serial.print("Decimal: ");
      Serial.println(IrReceiver.decodedIRData.decodedRawData, DEC);
      Serial.print("Hexa: ");
      Serial.println(IrReceiver.decodedIRData.decodedRawData, HEX);
      Serial.print("Octal: ");
      Serial.println(IrReceiver.decodedIRData.decodedRawData, OCT);
      Serial.print("Binario: ");
      Serial.println(IrReceiver.decodedIRData.decodedRawData, BIN);
      Serial.println();    

      // if (IrReceiver.decodedIRData.decodedRawData == 0XFD08F7) { }

      IrReceiver.resume();

  }
  
  delay(100);
  
}