0% found this document useful (0 votes)
13 views2 pages

16

This document contains code for an Arduino project that controls an LCD display and relay using IR remote codes. The code initializes an IR receiver, defines codes for buttons, controls an LCD and relay based on button presses, and prints debug messages to serial.

Uploaded by

berlioz2546
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views2 pages

16

This document contains code for an Arduino project that controls an LCD display and relay using IR remote codes. The code initializes an IR receiver, defines codes for buttons, controls an LCD and relay based on button presses, and prints debug messages to serial.

Uploaded by

berlioz2546
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

#include<Wire.

h>

#include<LiquidCrystal_I2C.h>

LiquidCrystal_I2C lcd(0x27,16,2);

#include <IRremote.h>

int RECV_PIN = 11;

int relay = 8;

int ledred = 5;

#define code1 16716015

#define code2 16726215

IRrecv irrecv(RECV_PIN);

decode_results results;

void setup() {

lcd.begin();

lcd.backlight();

lcd.setCursor(2,0);

lcd.print("Hello word");

Serial.begin(9600);

irrecv.enableIRIn();

pinMode(relay, OUTPUT);

pinMode(ledred, OUTPUT);

digitalWrite(ledred, HIGH);

void loop() {

if (irrecv.decode(&results)) {

Serial.print("รหัสปุ่ มกด: ");

Serial.println(results.value);

if (results.value == code1) {

Serial.println("LED OFF");

digitalWrite(relay, HIGH);

lcd.clear();

lcd.setCursor(5,0);
lcd.print("Hello");

lcd.setCursor(3,1);

lcd.print("Pattarapon");

digitalWrite(ledred, LOW);

if (results.value == code2) {

Serial.println("LED ON");

digitalWrite(relay, LOW);

lcd.clear();

lcd.setCursor(3,0);

lcd.print("thank you");

delay(1000);

lcd.clear();

delay(1000);

lcd.setCursor(3,0);

lcd.print("thank you");

delay(1000);

lcd.clear();

delay(1000);

lcd.setCursor(3,0);

lcd.print("thank you");

delay(1000);

lcd.clear();

lcd.setCursor(2,0);

lcd.print("Hello word");

delay(1000);

digitalWrite(ledred, HIGH);

irrecv.resume();

You might also like