yaeseonggledel
Published

LED Remote Control

Remote control an LED.

IntermediateShowcase (no instructions)1,837
LED Remote Control

Things used in this project

Hardware components

Standard LCD - 16x2 White on Blue
Adafruit Standard LCD - 16x2 White on Blue
×1
Ultrasonic Sensor - HC-SR04 (Generic)
Ultrasonic Sensor - HC-SR04 (Generic)
×1
Arduino UNO
Arduino UNO
×1
Infrared Module (Generic)
×1

Software apps and online services

Arduino IDE
Arduino IDE

Story

Read more

Schematics

remote control

remote control

Code

remote control

Arduino
remote control
#include <IRremote.h>

#include <LiquidCrystal.h>

const int rs = 12, en = 11, d4 = 5, d5 = 4, d6 = 3, d7 = 2;

LiquidCrystal lcd(rs, en, d4, d5, d6, d7);

int RECV_PIN = 8;

IRrecv irrecv(RECV_PIN);

decode_results results;

int led_pin1 = 6;

int led_pin2 = 7;

int led_state1 = 0;

int led_state2 = 0;

#define code1 16724175

#define code2 16718055

 

void setup()

{

  irrecv.enableIRIn(); 

  lcd.begin(16, 2);

  pinMode(led_pin1, OUTPUT);

  pinMode(led_pin2, OUTPUT);

  lcd.setCursor(0,0);

  lcd.print("1 : LED1 ON/OFF");

  lcd.setCursor(0,1);

  lcd.print("2 : LED2 ON/OFF");

}

 

void loop() {

if (irrecv.decode(&results)) {

  unsigned int value = results.value;

  switch (value) {

  case code1 :

    lcd.setCursor(0,0);

    if(led_state1 == 1){

    digitalWrite(led_pin1, LOW);

     lcd.print("LED1 is OFF   ");

    led_state1 = 0;

 

    

    }

    else{

      lcd.print("LED1 is blink    ");

    

      digitalWrite(led_pin1, HIGH);

      delay(1000);

          led_state1 = 1;

 

      digitalWrite(led_pin1, LOW);

     

      led_state1 = 0;

      lcd.setCursor(0,0);

 lcd.print("LED1 is OFF   ");

     

    }

    

    break;

  case code2 :

    lcd.setCursor(0,1);

    if(led_state2 == 1){

    digitalWrite(led_pin2, LOW);

    lcd.print("LED2 is OFF     ");

    led_state2=0;

    }

    else{

      digitalWrite(led_pin2, HIGH);

      lcd.print("LED2 is ON      ");

      led_state2=1;

    }

    break;

    }

    irrecv.resume(); 

}

}

Credits

yaeseong

yaeseong

7 projects • 7 followers
Korean High School Student who wants to expand his knowledge of the World
gledel

gledel

100 projects • 115 followers
Looking back on my childhood, I was happy when I was making something and I was proud of myself. "Making is instinct!"

Comments