For my YOUTUBE Subscriber 😊
For my YOUTUBE Subscriber 😊
#include <IRremote.h>
#define IR_PIN 2 // Pin for the IR receiver
#define LED_PIN 13 // Pin for the LED (built-in)
IRrecv irReceiver(IR_PIN); // Create an IR receiver object
decode_results irResults;
void setup() {
// Initialize the LED pin as OUTPUT
pinMode(LED_PIN, OUTPUT);
// Begin receiving IR signals
irReceiver.enableIRIn();
// Start with the LED on since no signal is received initially
digitalWrite(LED_PIN, HIGH);
}
void loop() {
if (irReceiver.decode(&irResults)) { // Check if an IR signal is detected
irReceiver.resume(); // Prepare to receive the next IR signal
digitalWrite(LED_PIN, LOW); // Turn off the LED (signal detected)
} else {
digitalWrite(LED_PIN, HIGH); // Turn on the LED (no signal detected)
}
}
Comments
Post a Comment