This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

intelligent ambulance with automatic traffic control

-> Error is mentioned in the program givem below in voi GSM_Init(void) function(3rd statement.

#include<reg51.h>
#include<lcd.h>
sbit gl= P3^4;
sbit rl= P3^5;
sbit rf= P3^7;
void Enter (void);
void GSM_Init(void);
void modem_send(unsigned char *);
void send_sms(unsigned char * , unsigned char *);
void Delay(unsigned int);
sbit Id= P3^3;
sbit ir = P3^4;
void amb()
{ SCON = 0X50; //Mode 1..8 bit data ,..1 stop bit,..1 start bit TMOD = 0X20;// Timer1….Mode2…8 bit Auto Reload TMOD = 0XFD; // Baud Rate 9600
TR1 = 1;
Id = 0;
Lcd_Delay(500);
Id = 1;
Lcd4_Init();
Lcd4_Write_String("INTELLIGENT AMBULANCE"); Lcd_Delay(500); GSM_Init(); Id = 0; Lcd_Delay(500);
Id =1; while(1) { while(ir==1) //no ambulance { Lcd4_Cmd(0x01); Lcd4_Cmd(0x80); Lcd4_Write_String("NO AMBULANCE"); Id=1; rf=1; P2=0x42; Lcd_Delay(50); rf=0; rf=1; P2=0x65; Lcd_Delay(50); rf=0;

} while(ir==0) //ambulance arrived { Lcd4_Cmd(0x01); Lcd4_Cmd(0*80); Lcd4_Write_String("AMBULANCE ARRIVED"); Id=0; rf=1; P2=0x66; Lcd_Delay(50); rf=0; send_sms("AT+CMGS=\"8142154992\" ", "PATIENT UNDER CRITICAL CONDITION"); Lcd_Delay(50); }
} } void GSM_Init(void) { Lcd4_Cmd(0*01); Lcd4_Write_String("GSM Initializing"); Lcd_Delay1(100); //<---- error in this statement Modem_send("AT"); Modem_send("ATE0"); Modem_send("AT+CSMS=0"); Modem_send("AT+IPR=9600"); Modem_send("AT+CMGF=1"); Modem_send("AT&W"); Modem_send("AT+CNMI=2,1,0,0,0"); Lcd4_Cmd(0*01); Lcd4_Write_String("GSM Intialized"); Lcd_Delay1(100); }

void Modem_send (unsigned char*ch) { unsigned char cha; while(*ch) { SBUF = *ch; while(TI==0); TI = 0 ; ch++ ; }

Enter(); TI = 0; RI = 0; while(1) { while(RI == 0); RI = 0; cha = SBUF ; if(cha == ‘0’);
while(RI == 0);
RI = 0;
cha = SBUF;
if(cha == ‘K’)
break;
SBUF = ‘A’;
while(TI == 0);
TI = 0 ;
SBUF =’/’;
while(TI == 0);
TI = 0 ;
} TI = 0;
RI = 0;
} void send_sms(unsigned char * No,unsigned char *v)
{ unsigned char chl = 'X' ;
while(*NO)
{ SBUF = *NO;
while(T1 ==0);
TI =0;
No++ ;
} Enter()
{ while(ch1!=’>’);
while( R1==0);
ch1=SBUF;
RI = 0;
} while(*v)
{ SBUF=*v;
while(T1==0);
TI=0;
v++;
} RI = 0;
TI = 0 ;
SBUF =0*1A;
while(T1==0);
TI=0;
RI=0;
} void Lcd_Delay1(unsigned int itime )
} unsigned int i,k = 0;
{ unsigned int i,k=0;
for(i=0;i<itime;i++) for(k=0;k<1000;k++);
}

/*_____*/

void main()
{ unsigned char ch;
Lcd4_Init(); amb(); Lcd4_Write_String("INTELLIGENT AMBULANCE"); Lcd_Delay(600); Lcd_Delay(600);
while(1)
{

Lcd4_Cmd(0x01); Lcd4_Cmd(0x80); while(rf==1); //wait to receive data(VT monitor) while (rf==0); ch=P2; if(ch == 0x65) {

Lcd4_Cmd(0x80);
Lcd4_Write_String("NO AMBULANCE");
gl= 1 ;
rl= 0 ;
Lcd_Delay(100);

}
if(ch==0x66) {

Lcd4_Cmd(0x80);
Lcd4_Write_String("AMBULANCE ARRIVED");
gl= 0;;
rl= 1;
Lcd_Delay(100);
} if(ch== 0x42)
{

Lcd4_Cmd(0x80);
Lcd4_Write_String("NO AMBULANCE");
gl= 1;
rl=0;
Lcd_Delay(100);
} if(ch==0x35)

{
Lcd4_Cmd(0x80);
Lcd4_Write_String("AMBULANCE ARRIVED");
gl=0;;
rl=1;

Lcd_Delay(100);
} }
}

Parents Reply Children
No data