Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //-------------------------------------------------------------------------
- void sms_mode(void)
- {
- while(1)
- {
- printf("AT+CMGF=1");
- putchar(0x0D); // CR
- while(getchar()!= 'K'){}; // <- looping sampai ketemu huruf "K" dari "OK" setelah dikirim "AT+CMGF=1"
- while(getchar()!=0x0A){};
- printf("AT+CMGR=1");
- putchar(0x0D);
- while(getchar()!=0x0A){}; //<< looping sampai ketemu "newLine"
- while(getchar()!=0x0A){}; //<< looping sampai ketemu "newLine"
- a=0;
- do{
- a++;
- cek[a]=getchar(); // ambil isi SMS sampai newLine (0x0A)
- }while(cek[a]!=0x0A);
- if(cek[1]=='S' || cek[1]=='s' || cek[1]=='?'){
- sms_status();
- }
- if(cek[1]=='1')
- {
- PORTC.5=1;
- lcd_gotoxy(0,1);
- lcd_puts("Lp1 on ");
- }
- if(cek[1]=='0')
- {
- PORTC.5=0;
- lcd_gotoxy(0,1);
- lcd_puts("Lp1 off");
- }
- if(cek[2]=='1')
- {
- PORTC.7=1;
- lcd_gotoxy(8,1);
- lcd_puts("Lp2 on ");
- }
- if(cek[2]=='0')
- {
- PORTC.7=0;
- lcd_gotoxy(8,1);
- lcd_puts("Lp2 off");
- }
- sms_not();
- delay_ms(1000);
- if(getchar()=='R'&&getchar()=='I')
- { lcd_clear();
- lcd_puts("Incomming call");
- delay_ms(100);
- //mode='R';
- PORTC.5=0;
- PORTC.7=0;
- xdata='-';
- sms_send("Lampu 1 off 2 off");
- delay_ms(2000);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment