bambangSud

baca isi SMS tanpa interupt

Aug 19th, 2013
216
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.89 KB | None | 0 0
  1. //-------------------------------------------------------------------------
  2. void sms_mode(void)
  3. {
  4.  
  5. while(1)
  6. {
  7.  
  8. printf("AT+CMGF=1");
  9. putchar(0x0D); // CR
  10.  
  11. while(getchar()!= 'K'){}; // <- looping sampai ketemu huruf "K" dari "OK" setelah dikirim "AT+CMGF=1"
  12. while(getchar()!=0x0A){};
  13.  
  14. printf("AT+CMGR=1");
  15. putchar(0x0D);
  16.  
  17. while(getchar()!=0x0A){}; //<< looping sampai ketemu "newLine"
  18. while(getchar()!=0x0A){}; //<< looping sampai ketemu "newLine"
  19.  
  20.  
  21. a=0;
  22. do{
  23. a++;
  24. cek[a]=getchar(); // ambil isi SMS sampai newLine (0x0A)
  25.  
  26. }while(cek[a]!=0x0A);
  27.  
  28.  
  29. if(cek[1]=='S' || cek[1]=='s' || cek[1]=='?'){
  30. sms_status();
  31. }
  32.  
  33. if(cek[1]=='1')
  34. {
  35. PORTC.5=1;
  36. lcd_gotoxy(0,1);
  37. lcd_puts("Lp1 on ");
  38. }
  39.  
  40. if(cek[1]=='0')
  41. {
  42. PORTC.5=0;
  43. lcd_gotoxy(0,1);
  44. lcd_puts("Lp1 off");
  45. }
  46.  
  47. if(cek[2]=='1')
  48. {
  49. PORTC.7=1;
  50. lcd_gotoxy(8,1);
  51. lcd_puts("Lp2 on ");
  52. }
  53.  
  54. if(cek[2]=='0')
  55. {
  56. PORTC.7=0;
  57. lcd_gotoxy(8,1);
  58. lcd_puts("Lp2 off");
  59. }
  60. sms_not();
  61. delay_ms(1000);
  62.  
  63. if(getchar()=='R'&&getchar()=='I')
  64. { lcd_clear();
  65. lcd_puts("Incomming call");
  66. delay_ms(100);
  67. //mode='R';
  68. PORTC.5=0;
  69. PORTC.7=0;
  70. xdata='-';
  71. sms_send("Lampu 1 off 2 off");
  72. delay_ms(2000);
  73. }
  74.  
  75.  
  76. }
  77.  
  78. }
Advertisement
Add Comment
Please, Sign In to add comment