#include<reg51.h>
sbit Std=P1^0; // tone Detector bit
void ini() // Initialize Timer 1 for serial communication
{
TMOD=0x20; //Timer1, mode 2, baud rate 9600 bps
TH1=0xFD; //Setting a baudrate of 9600
SCON=0x50;
TR1=1;
}
void transmit() // Funtion to transmit serial data
{
unsigned char output;
output=(P2 & 0x0F)+48;
switch(output)
{
case '1':
SBUF='1';
break;
case '2':
SBUF='2';
break;
case '3':
SBUF='3';
break;
case '4':
SBUF='4';
break;
case '5':
SBUF='5';
break;
case '6':
SBUF='6';
break;
case '7':
SBUF='7';
break;
case '8':
SBUF='8';
break;
case '9':
SBUF='9';
break;
case ':':
SBUF='0';
break;
case ';':
SBUF='*';
break;
case '<':
SBUF='#';
break;
}
while(TI==0);
TI=0;
}
void main()
{
P2=0xFF; // Declare P1 as input port.
ini();
while(1)
{
unsigned long z;
while(Std == 0);
transmit();
for (z=0;z<=3000;z++);
}
}