Controlling Only One Load using Tv Remote

on Saturday, 15 March 2014


Do you ever thought to switch ON and OFF your tube light, fan or any other home appliances  just by pressing  one button of T.V remote ? You might be thought long back, but you might not get the correct source to help you to build such project..
Now you can do it,in this post i'm going to explain you pretty good project with comprehensive way. Lets start...

Basic understanding:

We need to have basic understanding of few modules to design this project.Next thing is to write software code for it.
We are going to look at few important things how they work,  like Relays, IR sensor,etc
Before going to this section, first we should have clear picture of aim of the project.
AIM: Our aim is to switch ON and OFF any of the home appliance(i.e we are using light bulb here)  by using Tv remote.
In general to do this, we need something like sensor to detect the IR pulses from tv remote and a relay.
In general the output of micro-controller gives 5v output but in order to switch ON any home device in general we require 230v AC , so to get this we use device 'Relay'. Relay acts as switch. Lets have look on these two....


I strictly recommend you to read this tutorial post based on 'relay' before continuing further 

IR sensor: We are using Tsop1738 sensor. Observe the pins shown below

>>we connect 'out pin' to microcontroller.
>>vs=5v, Gnd=ground.
I will not go much deep into its working, just one important point to note is that, its output is active high(1), i.e whenever it senses the ir rays then its output will be low(0).

Output from remote: when ever remote key is pressed it transmit pulses. These pulses have different frequencies depending upon the different key pressed.Dont worry about the protocols of the remote , just we need to know the above step that's enough for our project.

How it works internally(Algorithm):

>> When ever Tsop sensor senses the IR pulses then it also produce pulses, which are given as input to microcontroller

>>As soon as  microcontroller gets the input then it makes particular pin(i.e pin connected to relay) will be flipped or inverted( i.e first time ON , next time OFF, so on)

>> Above step means, if we press remote  once then device will be made ON, if we press remote again then device will be turned OFF.
Project requirements:
>> MikroC compiler for Pic
>>Pic18f452 microcontroller
>>Tv remote( any remote will work)
>>Bulb( any home appliance may work)
>>Relay spst 5v DC
>>Tsop1738 sensor
>>4Mhz crystal osciallator
>>Resistors and Capacitors
>>9V battery, 7805 volate regulator IC
Power supply:

Relay connections:
(Note: I use to write articles for long back )

Total circuit diagram:


We use counter to count the number of input pulses, variable 'flip' is to flip the output i.e from ON to OFF and from OFF to ON.
Imp Note: For accuracy we are writing code in such a way that, only if we press remote for two times only then the device will be ON or OFF, i.e if we want to make ON then we need to press remote two times again to make it OFF we need to press two times. we can set this to any number of times by changing the value of the variable ''click'' in the below code i.e if click=3 then after pressing 3 times  remote then the device will be ON and after pressing 3 times the devices go to OFF, so on...
void main()
    unsigned char click=0,flip=0;
    TRISC=0x0;//protC as output
    trisa=0b00010000;// protA pin 4 used as input
    T0CON=0b11101000;//configuration for counter
    TMR0L=0X0;//counts are zero
         if(TMR0L>30)//if input pulses are more than 30 pulses then
           click++;//increment clicks
           if(click==2)//check above note 
             click =0;
             portc.f0=flip;// flip the output
     TMR0L=0X0;// again count to zero
This code will works well, i have tested it on hardware too.. 
In our next project we will see how to control multiple loads...

Author: Youstron Sic


Adam Ubaid said...

how to control led bargraph through sensor voltage using pic...

Shanthi Cabs said...

Amazing article. Your blog helped me to improve myself in many ways thanks for sharing this kind of wonderful informative blogs in live. I have bookmarked more article from this website. Such a nice blog you are providing ! Kindly Visit Us @ Best Travels in Madurai | Tours and Travels in Madurai | Madurai Travels

Post a Comment