Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

cell phone interface

Status
Not open for further replies.

abbas1707

New Member
i want to test that if my cellphone is responding to AT commands sent by AT89c51.
i have written a c program and before wirting this code to controller i want to confirm about the code. is it ok???? or i must correct it?? i am just sending AT and checking wether "OK" recieved and if so, led will be turned on!!!. can anyone help me out??
********************************
#include <reg51.h>
sbit led=P1^0;
void init()
{
TMOD=0x20;
TH1=0xFD;
SCON=0x50;
TR1=1;
}
void transmit(unsigned char *a)
{
while(*a!='\0')
{
SBUF=*a;
while(TI==0);
TI=0;
a++;
}
}
unsigned char rcv()
{
while(RI==0);
return SBUF;
}
void main()
{
unsigned char ok[2];
unsigned char j;
led=0;
init();
transmit("AT");
transmit(0x0d);
for(j=0;j<2;j++)
ok[j]=rcv();
if(ok[0]=='O'&&ok[1]=='K')
led=1;

}
 
Last edited:
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top