Created
December 20, 2017 09:00
-
-
Save labajo/2838d748c21c43a94fd02995eb742389 to your computer and use it in GitHub Desktop.
MasterLamp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <IRLibDecodeBase.h> | |
#include <IRLib_P01_NEC.h> | |
#include <IRLib_P02_Sony.h> | |
#include <IRLib_HashRaw.h> | |
#include <IRLibCombo.h> | |
#ifdef __AVR__ | |
#include <avr/power.h> | |
#endif | |
#include <Wire.h> | |
#define I2C_SLAVE_ADDRESS 8 | |
IRdecode myDecoder; | |
#include <IRLibRecv.h> | |
IRrecv myReceiver(2); | |
void setup() { | |
Serial.begin(9600); | |
delay(2000); while (!Serial); | |
myReceiver.enableIRIn(); | |
Serial.println(F("Ready to receive IR signals")); | |
Wire.begin(); | |
Serial.println(F("Ready I2C")); | |
} | |
void loop() { | |
if(myReceiver.getResults()) { | |
myDecoder.decode(); | |
if(myDecoder.protocolNum==UNKNOWN) { | |
Serial.print(F("Unknown protocol. Hash value is: 0x")); | |
Serial.println(myDecoder.value,HEX); | |
} else { | |
myDecoder.dumpResults(false); | |
Serial.print(F("Result ==> ")); | |
String result = String(myDecoder.value, HEX); | |
Serial.println(result); | |
Wire.beginTransmission(I2C_SLAVE_ADDRESS); | |
Wire.write(result.c_str()); | |
Wire.endTransmission(); | |
}; | |
myReceiver.enableIRIn(); | |
} | |
delay(100); | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment