IR Remote Demo

Remote Control LED Operation

The following was used to test the function of the IR remote kit, ST071.

It uses a Funduino Uno (M009) to decode the infrared transmissions and light red, yellow and green leds in response only to presses of keys 1, 2 and 3 respectively on the remote control keypad. A press on the key marked CH turns off any lit led.

The circuit arrangement is as shown below:


Sample code:

#include <IRremote.h>
const int RECV_PIN = 8; //IR input pin
const int RED = 13; // Red led output
const int YELLOW = 12; // Yellow led output
const int GREEN = 11; // Green led output
IRrecv irrecv(RECV_PIN);
decode_results results;

void setup()
{
    pinMode(RED, OUTPUT);
    pinMode(YELLOW, OUTPUT);
    pinMode(GREEN, OUTPUT);
    Serial.begin(9600);
    irrecv.enableIRIn(); // Start the receiver
}

void loop()
{
    if (irrecv.decode(&results))
    {
        Serial.println(results.value, HEX); //show code received.

        switch(results.value)
        {
            case 0xFF30CF:  //hex code key 1
                digitalWrite(RED, HIGH); //light RED
                break;
            case 0xFF18E7:  //hex code key 2
                digitalWrite(YELLOW, HIGH);  //light YELLOW
                break;
            case 0xFF7A85:  //hex code key 3  //light GREEN
                digitalWrite(GREEN, HIGH);
                break;
            case 0xFF629D:  //hex code key CH
                digitalWrite(RED, LOW); //turn all off
                digitalWrite(YELLOW, LOW);
                digitalWrite(GREEN, LOW);
                break;
        }
    irrecv.resume(); // Receive the next value  
    }

}
Your IP Address is: 18.189.170.17
Copyright © 2024 Bitsbox. Powered by Zen Cart