Professional Documents
Culture Documents
{
int i,k;
char flag,read_cmd[10];
i=0;
sprintf(read_cmd,"AT+CMGR=%d\r",position);
USART_SendString(read_cmd);
MSdelay(1000);
GSM_Msg_Display();
}
void GSM_Msg_Display()
{
void main()
{
CMCON=0x07;
TRISA=0;
TRISB=0b00000010;
LED=0;
/*output[1]=' ';
output[2]=' ';
output[3]=' ';
output[4]=' ';*/
UART1_Read_Text(&RX,"\r\n",6);
}
Delay_ms(2000);
for(i=0;i<5;i++) //string length is 5
{
if(SR[i]==RX[i]) //here a[] is the string which is received through uart and
x[] is predefined string
{
b++; //increment b value by one
}
}
if(b==5)
{
b=0;
UART1_Write_Text("ATH\r");
LED=~LED;//write your output
}
void main() {
/* we first have to do the init of the serial comm port, the adcon, etc. */
Init_System();
while (1==1) {
/*****************************************************************************/
/* */
/* */
/* */
/*****************************************************************************/
void Init_System() {
ADCON1 = 0x06;
INTCON = 0xC0;
OPTION_REG = 0x80;
/*****************************************************************************/
/* */
/* */
/* */
/****************************************************************************
if (UART1_Data_Ready()) {
portb = 0x040;
UART1_Read_Text(trash,"\r\n",4);
Delay_ms(100);
} else {
portb = 0x020;
Delay_ms(100);
}
}
dim i as word
dim receive as string[25]
dim delimiter as string[2]
dim tempb as byte
dim tempst as string[3]
...
delimiter[0]=chr(13)
delimiter[1]=chr(10)
delimiter[2]=0
UART1_Write_Text("AT*REG1?"+delimiter)
i = 0
receive=""
while i<2000
delay_us(500)
if UART1_Data_Ready = 1 then
tempb=UART1_Read
if tempb >= 32 then
receive=receive+chr(tempb)
else
receive=receive+"#"
ByteToStr(tempb,tempst)
ltrim(tempst)
strcat(receive,tempst)
end if
end if
inc(i)
wend
Lcd_Out(1, 1,receive)
void main()
{
RCSTA.RX9D = 0;
RCSTA.ADDEN = 0;
RCSTA.CREN = 1; // eneble reception.
RCSTA.SPEN = 1; //Serial port enable
RCSTA.RX9 = 0;
UART1_Init(9600);
while(1)
{
if (UART1_Data_Ready())
{
//Blink the LED, indication data is coming in.
PORTA = 4;
delay_ms(50);
PORTA = 0;
sVal = UART1_Read();
if (sVal == '3')
motor_run_fast();
else
motor_stop();
} //UART ready
}
}