fatima_just
Junior Member level 1
help me this code for gps to make led on then off(in loop on ---> off ) if ($) receive from gps but the code make led on always
(curcuit is 8051 connected with max232 an gps pathfinder pocket )(crystal frequncy is 11.0592)
#include<Reg51.H>
#include<string.h>
unsigned char i;
sbit led1=P1^0;
void delay(unsigned int x)
{
unsigned int i,j;
for(i=0;i<x;i++)
for(j=0;j<1275;j++);
}
void SerialInit()
{ //initialization
TMOD = 0x20; // timer 1 (8 bit auto-reloed)
TH1 = 0xFA; //to obtain 4800 baud rate
TR1 = 1; //start timer
SCON = 0x50;
return;
}
void make_on()
{
while(1)
{
led1=!led1;
delay(500);
}
}
unsigned char SerialRecvChar()
{
while(!RI); //waits till a byte is recieved
RI = 0;
return (SBUF);
}
//---------------------------------------------------------------
//-----------------------------------------------------
void GPS_data()//GPS format:$GGA,hhmmss.ss,ddmm.mmmm,n,dddmm.mmmm,e//ddmm.mmmm,n:the date recived of latitude //dddmm.mmmm,e:the date recived of longitude
{
unsigned char j;
SerialInit();
i = 0x24;
while(1)
{
if(SerialRecvChar() == '$' )
make_on();
}
}
void main()
{
GPS_data();
}
(curcuit is 8051 connected with max232 an gps pathfinder pocket )(crystal frequncy is 11.0592)
#include<Reg51.H>
#include<string.h>
unsigned char i;
sbit led1=P1^0;
void delay(unsigned int x)
{
unsigned int i,j;
for(i=0;i<x;i++)
for(j=0;j<1275;j++);
}
void SerialInit()
{ //initialization
TMOD = 0x20; // timer 1 (8 bit auto-reloed)
TH1 = 0xFA; //to obtain 4800 baud rate
TR1 = 1; //start timer
SCON = 0x50;
return;
}
void make_on()
{
while(1)
{
led1=!led1;
delay(500);
}
}
unsigned char SerialRecvChar()
{
while(!RI); //waits till a byte is recieved
RI = 0;
return (SBUF);
}
//---------------------------------------------------------------
//-----------------------------------------------------
void GPS_data()//GPS format:$GGA,hhmmss.ss,ddmm.mmmm,n,dddmm.mmmm,e//ddmm.mmmm,n:the date recived of latitude //dddmm.mmmm,e:the date recived of longitude
{
unsigned char j;
SerialInit();
i = 0x24;
while(1)
{
if(SerialRecvChar() == '$' )
make_on();
}
}
void main()
{
GPS_data();
}