#include <IRremote.h>
const int RECV_PIN = 2; // IR Receiver connected to D2
const int LED_PIN = 11; // Built-in LED for feedback
IRrecv irrecv(RECV_PIN); // Initialize the receiver
decode_results results;
void setup() {
pinMode(LED_PIN, OUTPUT); // Set LED pin as output
Serial.begin(9600); // Start serial communication
irrecv.enableIRIn(); // Start the IR receiver
Serial.println("Press remote buttons to simulate Eye Open and Eye Closed.");
}
void loop() {
if (irrecv.decode()) { // Check if an IR signal is received
unsigned long receivedCode = irrecv.decodedIRData.decodedRawData; // Get the raw data
// Map specific HEX codes to actions
if (receivedCode == 0x9768FF00) { // HEX code for "Eye Open"
Serial.println("Eye Open Detected");
digitalWrite(LED_PIN, LOW); // Turn off LED
}
else if (receivedCode == 0xCF30FF00) { // HEX code for "Eye Closed"
Serial.println("Eye Closed Detected");
digitalWrite(LED_PIN, HIGH); // Turn on LED
}
else {
Serial.print("Unknown Command: ");
Serial.println(receivedCode, HEX); // Print unknown HEX code
}
irrecv.resume(); // Prepare for the next signal
}
}
nano:12
nano:11
nano:10
nano:9
nano:8
nano:7
nano:6
nano:5
nano:4
nano:3
nano:2
nano:GND.2
nano:RESET.2
nano:0
nano:1
nano:13
nano:3.3V
nano:AREF
nano:A0
nano:A1
nano:A2
nano:A3
nano:A4
nano:A5
nano:A6
nano:A7
nano:5V
nano:RESET
nano:GND.1
nano:VIN
nano:12.2
nano:5V.2
nano:13.2
nano:11.2
nano:RESET.3
nano:GND.3
ir1:GND
ir1:VCC
ir1:DAT
led1:A
led1:C
r1:1
r1:2