#include <IRremote.h>
// Define the IR receiver pin
const int RECV_PIN = 11;
// Define the LED pins
const int ledPins[] = {2, 3, 4, 5, 6, 7};
// Create an instance of the IRremote library
IRrecv irrecv(RECV_PIN);
decode_results results;
void setup() {
// Initialize the IR receiver
irrecv.enableIRIn();
// Initialize the LED pins as outputs
for (int i = 0; i < 6; i++) {
pinMode(ledPins[i], OUTPUT);
digitalWrite(ledPins[i], LOW); // Turn off all LEDs initially
}
}
void loop() {
if (irrecv.decode(&results)) {
// If we received an IR signal, print the value to the serial monitor
Serial.println(results.value, HEX);
// Map the received IR code to control the LEDs
switch (results.value) {
case 0xFFA25D: // Power button
for (int i = 0; i < 6; i++) {
digitalWrite(ledPins[i], HIGH);
}
break;
case 0xFF629D: // 1 button
digitalWrite(ledPins[0], HIGH);
break;
case 0xFFE21D: // 2 button
digitalWrite(ledPins[1], HIGH);
break;
case 0xFF22DD: // 3 button
digitalWrite(ledPins[2], HIGH);
break;
case 0xFF02FD: // 4 button
digitalWrite(ledPins[3], HIGH);
break;
case 0xFFC23D: // 5 button
digitalWrite(ledPins[4], HIGH);
break;
case 0xFFE01F: // 6 button
digitalWrite(ledPins[5], HIGH);
break;
case 0xFF906F: // Vol+ button
// Add code to increase brightness or other actions
break;
case 0xFF9867: // Vol- button
// Add code to decrease brightness or other actions
break;
// Add more cases for other buttons as needed
default:
// Do nothing for unrecognizable IR signals
break;
}
// Resume receiving IR signals
irrecv.resume();
}
}
uno:A5.2
uno:A4.2
uno:AREF
uno:GND.1
uno:13
uno:12
uno:11
uno:10
uno:9
uno:8
uno:7
uno:6
uno:5
uno:4
uno:3
uno:2
uno:1
uno:0
uno:IOREF
uno:RESET
uno:3.3V
uno:5V
uno:GND.2
uno:GND.3
uno:VIN
uno:A0
uno:A1
uno:A2
uno:A3
uno:A4
uno:A5
led1:A
led1:C
led5:A
led5:C
led6:A
led6:C
led7:A
led7:C
led8:A
led8:C
led9:A
led9:C
r1:1
r1:2
r2:1
r2:2
r3:1
r3:2
r4:1
r4:2
r5:1
r5:2
r6:1
r6:2
r7:1
r7:2
ir1:GND
ir1:VCC
ir1:DAT