Skip to content

Instantly share code, notes, and snippets.

@netmaniac
Last active July 6, 2018 09:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save netmaniac/6ea09dc182f2ebe18ea773b7952c3126 to your computer and use it in GitHub Desktop.
Save netmaniac/6ea09dc182f2ebe18ea773b7952c3126 to your computer and use it in GitHub Desktop.
#include <IRremote.h>
#define IRRECV 11 // Numer pinu odbiornika IR
#define RELAY 8 // Numer pinu przekaźnika
IRrecv irrecv(IRRECV);
void setup() {
irrecv.enableIRIn();
pinMode(RELAY, OUTPUT);
}
void loop() {
unsigned long code = readIRCode();
if(code == 0xFFA25D) { // CH_MINUS
digitalWrite(RELAY, LOW);
}
if(code == 0xFFE21D) { // CH_PLUS
digitalWrite(RELAY, HIGH);
}
}
unsigned long readIRCode() {
decode_results results;
unsigned long resultValue = results.value;
irrecv.resume();
return resultValue;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment