#include <IRremote.h>
#include <LiquidCrystal_I2C.h>
#define PIN_RECEIVER 2 // Signal Pin of IR receiver
LiquidCrystal_I2C lcd(0x27, 20, 4);
IRrecv receiver(PIN_RECEIVER);
int remoteVal = 0;
int resultAnalog, resutlRemote;
const byte relay = 13;
const int jumlahLed = 10; // Tentukan jumlah LED yang akan digunakan
int pinLed[jumlahLed] = {3, 4, 5, 6, 7, 8, 9, 10, 11, 12}; // Tentukan pin untuk masing-masing LED
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
pinMode(relay, OUTPUT);
for (int i = 0; i < jumlahLed; i++) {
pinMode(pinLed[i], OUTPUT);
digitalWrite(pinLed[i], LOW); // Awalnya matikan semua LED
}
digitalWrite(relay, LOW);
lcd.init(); // initialize the lcd
lcd.backlight();
receiver.enableIRIn(); // Start the receiver
}
void loop() {
readRemote();
lcd.setCursor(0, 0);
lcd.print("Remote: ");
lcd.setCursor(8, 0);
lcd.print(remoteVal);
lcd.print(" ");
}
void readRemote() {
if (receiver.decode()) {
remoteVal = receiver.decodedIRData.command;
Serial.print("Data Remote: ");
Serial.println(remoteVal);
receiver.resume();
}
}