hi i am trying to control devices using DTMF and 89s52, the code i wrote is
#include <REGX52.H>
/*MOTOR*/
sbit rm1 = P0^0;
sbit rm2 = P0^1;
sbit lm1 = P0^2;
sbit lm2 = P0^3;
/**/
sbit led1 = P1^0;
sbit led2 = P1^1;
sbit led3 = P1^2;
sbit led4 = P1^3;
unsigned char z=0,y=0,value=0,tem=0,hum=0,i=0,hum1,j=50,l=0;
bit flag=0;
unsigned int dec=3;
//unsigned char ch=0;
void init()
{
P1=0XFF;
P0=0XFF;
P2=0XFF;
P3=0XFF;
IE=0X00;
}
void led_check()
{
if(led1==1&&led2==0&&led3==0&&led4==0)
{
//key=1; STORE DATA
}
if(led1==0&&led2==1&&led3==0&&led4==0)
{
//key=2; FORWARD
rm1 = 0;
rm2 = 1;
lm1 = 0;
lm2 = 1;
}
if(led1==1&&led2==1&&led3==0&&led4==0)
{
///key=3;
}
if(led1==0&&led2==0&&led3==1&&led4==0)
{
//key=4; MOVE LEFT
flag=0;
rm1 = 0;
rm2 = 1;
lm1 = 1;
lm2 = 1;
}
if(led1==1&&led2==0&&led3==1&&led4==0)
{
//key=5; STOP
flag=0;
rm1 = 1;
rm2 = 1;
lm1 = 1;
lm2 = 1;
}
if(led1==0&&led2==1&&led3==1&&led4==0)
{
//key=6; MOVE RIGHT
flag=0;
rm1 = 1;
rm2 = 1;
lm1 = 0;
lm2 = 1;
}
if(led1==1&&led2==1&&led3==1&&led4==0)
{
//key=7;
}
if(led1==0&&led2==0&&led3==0&&led4==1)
{
//key=8; BACK
flag=0;
rm1 = 1;
rm2 = 0;
lm1 = 1;
lm2 = 0;
}
if(led1==1&&led2==0&&led3==0&&led4==1)
{
//key=9;
}
}
void main()
{
init();
while(1)
{
led_check();
}
}
but my professor wants me to use a 4 digit code to control each motor. can anyone help???