IR REMOTE SWITCH AND LCD

IR plus LCD

#include <IRremote.h>
#include <Wire.h>
#include <LCD.h>
#include <LiquidCrystal_I2C.h>

#define I2C_ADDR 0x27
#define BACKLIGHT_PIN 3
#define En_pin 2
#define Rw_pin 1
#define Rs_pin 0
#define D4_pin 4
#define D5_pin 5
#define D6_pin 6
#define D7_pin 7

LiquidCrystal_I2C lcd(I2C_ADDR,En_pin,Rw_pin,Rs_pin,D4_pin,D5_pin,D6_pin,D7_pin,BACKLIGHT_PIN,POSITIVE);
LCD *myLCD = &lcd;

int RECV_PIN = 3;
int OUTPUT_PIN = 4;
IRrecv irrecv(RECV_PIN);
decode_results results;
void setup()
{
lcd.begin(16,2); // initialize the lcd
lcd.home ();
pinMode(OUTPUT_PIN, OUTPUT);
pinMode(4, OUTPUT);
irrecv.enableIRIn(); // Start the receiver
}

int on = 0;
unsigned long last = millis();
void loop() {
/*===without specific code
if (irrecv.decode(&results)) {
if (millis() – last > 250) {
on = !on;
(on ? nyala():padam());
}
last = millis();
irrecv.resume(); // Receive the next value
}
*/
//===with specific code
if (irrecv.decode(&results)) {
if (results.value == 0xEF1001FE) { // code from IR button
if (millis() – last > 250) {
on = !on;
(on ? nyala():padam());
}
last = millis();
}
irrecv.resume(); // Receive the next value
}
}

void nyala(){
lcd.clear();
lcd.setCursor(0, 0);
lcd.print(“LAMPU ON”);
digitalWrite(OUTPUT_PIN,HIGH);
}
void padam(){
lcd.clear();
lcd.setCursor(0, 0);
lcd.print(“LAMPU OFF”);
digitalWrite(OUTPUT_PIN,LOW);
}