Created
May 29, 2022 21:22
-
-
Save Blaxdemir/0f20adf334bf76de054d542754268ef1 to your computer and use it in GitHub Desktop.
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 <IRremote.hpp> | |
#define RELAY_PIN 5 | |
#define IR_RECEIVER_PIN 2 | |
long last = millis(); | |
relay_state = LOW; | |
IRrecv irrecv(IR_RECEIVER_PIN, ENABLE_LED_FEEDBACK); | |
void setup() { | |
Serial.begin(9600); | |
pinMode(RELAY_PIN, OUTPUT); | |
pinMode(IR_RECEIVER_PIN, OUTPUT); | |
irrecv.enableIRIn(); | |
// put your setup code here, to run once: | |
} | |
void loop() { | |
// put your main code here, to run repeatedly: | |
if (irrecv.decode()){ | |
int command = irrecv.decodedIRData.command; | |
if (command == 8){ | |
if (millis() - last < 500){ | |
relay_state = !relay_state; | |
digitalWrite(RELAY_PIN,relay_state); | |
last = millis(); | |
} | |
} | |
irrecv.resume(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment