Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
/* NEC REMOT CANTROL INTERFACE WITH 8051 MCU ADD. AND CMD. DISPLAY ON HYPERTERMINAL*/
/*PROGRAM BY ARUN KUMAR SHARMA JHUNJHUNU RAJASTHAN INDIA */
/*PHONE +919829147145*/
#include<reg51.h>
//#include<stdio.h>
#define T 516//560us 11.0592MHz
#define _9MS 8295//9000ms 11.0592MHz
#define _4MS 4198//4500ms 11.0592MHz
#define _2T ((T)+(T))//1120us 11.0592MHz
#define _3T (T*3)//1680us 11.0592MHz
#define POW 0x12
#define V_UP 0x02
#define V_DW 0x13
#define uint unsigned int
#define cmp(VALUE,MS) (VALUE>=(MS-MS*.1)&&VALUE<=(MS+MS*.1))?1:0
#define uint unsigned int
#define lint long int
#define uchar unsigned char
static uchar DATAPORT,key;
uchar add1,add2,cmd1,cmd2;
sbit ir=P3^2;
sbit Power=P3^0;
sbit io=P3^1;
uint value,value1;
static uchar count;
uchar irtemp,i,j;
/*void send_TX(unsigned char *c)
{
while(*c)
{
if(*c=='\n')
{
SBUF=0x0D;
*c++;
}
else
SBUF=*c++;
while(TI==0);
TI=0;
}
}
*/
void delay(uint a)
{
uint r,t;
for(r=0;r<a;r++)
for(t=0;t<120;t++);
}
void ir_data() interrupt 0 using 1
{
TH0=TL0=0;
EX0=0;
IE0=0;
TR0=1;
io=0;
while((!ir)&&(TH0<<8|TL0)<9500);
TR0=0;
value=(TH0<<8)|TL0;
TH0=TL0=0;
TR0=1;
while(ir&&(TH0<<8|TL0)<5000);
TR0=0;
value1=(TH0<<8)|TL0;
if(cmp(value,_9MS)&&cmp(value1,_4MS))
{
{
for(i=0;i<4;i++)
{
for(j=0;j<8;j++)
{
irtemp>>=1;///* Recive 'byte' bit-by-bit from MSB to LSB. */
TH0=TL0=0;
while(!ir);
TR0=1;
while(ir);
TR0=0;
value=TH0<<8|TL0;
irtemp|=(cmp(value,_3T))?0x80:0x00;
}
switch(i)
{
case 0:
add1=irtemp;break;
case 1:
add2=irtemp;break;
case 2:
cmd1=irtemp;break;
case 3:
cmd2=irtemp;break;
default :;break;
}
irtemp=0x00;
}
}i=0,j=0;
}
irtemp=0;
if((cmd1==~cmd2)&&(add1==~add2))
{
key=cmd1;
//printf("%X %X %X %X\n",add1,cmd1,add2,cmd2);//Display on hyperterminal
}
else
;//printf("Recive Errer\n");
add1=add2=cmd1=cmd2=0;
delay(200);
io=1;
IE0=0;
EX0=1;
}
void main()
{
EA=0;
TMOD=0x01;
//SCON=0x50;
//PCON=0x80; //for high baud rate SMOD=1
//TH1=0xFD; //19200 baud rate
//TI=0;
TR1=1;
ET1=1;
TH0=0;TL0=0;
IT0=1;
EX0=1;
PX0=1;
DATAPORT=0x0F;
P1=DATAPORT;
Power=0;
io=1;
EA=1;
//send_TX(" *CREATED BY ARUN*\n");
//send_TX("CHIRAWA JHUNJHUNU Rajasthan\n");
while(1)
{
while(key==0x00);
switch (key)
{
case POW :
Power^=0x01;P1=DATAPORT=0x0F; break;
case V_UP:
if(DATAPORT>0x00&&Power)
{
DATAPORT=DATAPORT-1;
P1=DATAPORT;
//printf("%X",P1);
//puts("VOL+");
}break;
case V_DW :
if(DATAPORT<0x0F&&Power)
{
DATAPORT=DATAPORT+1;
P1=DATAPORT;
//printf("%X",P1);
//puts("VOL-");
}break;
default :
break;
}
key=0x00;
}
}
you can use RC5/NEC format for remotepls modify as per your applicationCode:/* NEC REMOT CANTROL INTERFACE WITH 8051 MCU ADD. AND CMD. DISPLAY ON HYPERTERMINAL*/ /*PROGRAM BY ARUN KUMAR SHARMA JHUNJHUNU RAJASTHAN INDIA */ /*PHONE +919829147145*/ #include<reg51.h> //#include<stdio.h> #define T 516//560us 11.0592MHz #define _9MS 8295//9000ms 11.0592MHz #define _4MS 4198//4500ms 11.0592MHz #define _2T ((T)+(T))//1120us 11.0592MHz #define _3T (T*3)//1680us 11.0592MHz #define POW 0x12 #define V_UP 0x02 #define V_DW 0x13 #define uint unsigned int #define cmp(VALUE,MS) (VALUE>=(MS-MS*.1)&&VALUE<=(MS+MS*.1))?1:0 #define uint unsigned int #define lint long int #define uchar unsigned char static uchar DATAPORT,key; uchar add1,add2,cmd1,cmd2; sbit ir=P3^2; sbit Power=P3^0; sbit io=P3^1; uint value,value1; static uchar count; uchar irtemp,i,j; /*void send_TX(unsigned char *c) { while(*c) { if(*c=='\n') { SBUF=0x0D; *c++; } else SBUF=*c++; while(TI==0); TI=0; } } */ void delay(uint a) { uint r,t; for(r=0;r<a;r++) for(t=0;t<120;t++); } void ir_data() interrupt 0 using 1 { TH0=TL0=0; EX0=0; IE0=0; TR0=1; io=0; while((!ir)&&(TH0<<8|TL0)<9500); TR0=0; value=(TH0<<8)|TL0; TH0=TL0=0; TR0=1; while(ir&&(TH0<<8|TL0)<5000); TR0=0; value1=(TH0<<8)|TL0; if(cmp(value,_9MS)&&cmp(value1,_4MS)) { { for(i=0;i<4;i++) { for(j=0;j<8;j++) { irtemp>>=1;///* Recive 'byte' bit-by-bit from MSB to LSB. */ TH0=TL0=0; while(!ir); TR0=1; while(ir); TR0=0; value=TH0<<8|TL0; irtemp|=(cmp(value,_3T))?0x80:0x00; } switch(i) { case 0: add1=irtemp;break; case 1: add2=irtemp;break; case 2: cmd1=irtemp;break; case 3: cmd2=irtemp;break; default :;break; } irtemp=0x00; } }i=0,j=0; } irtemp=0; if((cmd1==~cmd2)&&(add1==~add2)) { key=cmd1; //printf("%X %X %X %X\n",add1,cmd1,add2,cmd2);//Display on hyperterminal } else ;//printf("Recive Errer\n"); add1=add2=cmd1=cmd2=0; delay(200); io=1; IE0=0; EX0=1; } void main() { EA=0; TMOD=0x01; //SCON=0x50; //PCON=0x80; //for high baud rate SMOD=1 //TH1=0xFD; //19200 baud rate //TI=0; TR1=1; ET1=1; TH0=0;TL0=0; IT0=1; EX0=1; PX0=1; DATAPORT=0x0F; P1=DATAPORT; Power=0; io=1; EA=1; //send_TX(" *CREATED BY ARUN*\n"); //send_TX("CHIRAWA JHUNJHUNU Rajasthan\n"); while(1) { while(key==0x00); switch (key) { case POW : Power^=0x01;P1=DATAPORT=0x0F; break; case V_UP: if(DATAPORT>0x00&&Power) { DATAPORT=DATAPORT-1; P1=DATAPORT; //printf("%X",P1); //puts("VOL+"); }break; case V_DW : if(DATAPORT<0x0F&&Power) { DATAPORT=DATAPORT+1; P1=DATAPORT; //printf("%X",P1); //puts("VOL-"); }break; default : break; } key=0x00; } }
yes its work with nec remote proto.Dear Mr. Arun is it tested and working code ???