aliraza786
Full Member level 4
- Joined
- Nov 10, 2009
- Messages
- 210
- Helped
- 14
- Reputation
- 28
- Reaction score
- 14
- Trophy points
- 1,298
- Location
- Lahore, Pakistan, Pakistan
- Activity points
- 2,914
i wana decode a simple wave form genertaing from one controller and the other controller is programed to decode it ......i write simple code for this here but it is not working i dnt know what is the problem in this or there are other methods one can use for decoding wave form...here is the code
Transmiter:
________________________________________
#include<reg51.h>
sbit sw=P2^0; sbit sw1=P2^1; unsigned int x,g;
sbit relay=P1^6;
void delay(x)
{
for(g=0;g<x;g++)
{
TMOD=0x01;
TH0=0xFC;
TL0=0x67;
TR0=1;
while(TF0==0);
TR0=0;
TF0=0;
}
}
void main()
{
while(1)
{
if (sw==0)
{
sw1=1;
delay(2);
sw1=0;
delay(4);
sw1=1;
delay(8);
sw1=0;
delay(4);
}
}
}
____________________________________________________
RECIVER:
______________________________________________________
#include<reg51.h>
sbit sw=P2^0; sbit sw1=P2^1; unsigned int x,g;
sbit relay=P1^6;
void delay(x)
{
for(g=0;g<x;g++)
{
TMOD=0x01;
TH0=0xFC;
TL0=0x67;
TR0=1;
while(TF0==0);
TR0=0;
TF0=0;
}
}
void main()
{ relay=0;
while(1)
{
if(sw==0)
{
delay(2);
{
if(sw==1)
{
delay(4);
{
if(sw==0);
{
delay(8);
{
if(sw==1)
{
delay(4);
relay=1;
}
}
}
}
}
}
}
}
}
_____________________________________________________
here is the protious simulation...
Transmiter:
________________________________________
#include<reg51.h>
sbit sw=P2^0; sbit sw1=P2^1; unsigned int x,g;
sbit relay=P1^6;
void delay(x)
{
for(g=0;g<x;g++)
{
TMOD=0x01;
TH0=0xFC;
TL0=0x67;
TR0=1;
while(TF0==0);
TR0=0;
TF0=0;
}
}
void main()
{
while(1)
{
if (sw==0)
{
sw1=1;
delay(2);
sw1=0;
delay(4);
sw1=1;
delay(8);
sw1=0;
delay(4);
}
}
}
____________________________________________________
RECIVER:
______________________________________________________
#include<reg51.h>
sbit sw=P2^0; sbit sw1=P2^1; unsigned int x,g;
sbit relay=P1^6;
void delay(x)
{
for(g=0;g<x;g++)
{
TMOD=0x01;
TH0=0xFC;
TL0=0x67;
TR0=1;
while(TF0==0);
TR0=0;
TF0=0;
}
}
void main()
{ relay=0;
while(1)
{
if(sw==0)
{
delay(2);
{
if(sw==1)
{
delay(4);
{
if(sw==0);
{
delay(8);
{
if(sw==1)
{
delay(4);
relay=1;
}
}
}
}
}
}
}
}
}
_____________________________________________________
here is the protious simulation...