bambangSud

terima SMS AVR

Aug 4th, 2013
274
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.96 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'){};
  12. while(getchar()!=0x0A){};
  13.  
  14. printf("AT+CMGL=");
  15. putchar('"');
  16. printf("REC UNREAD");
  17. putchar('"');
  18. putchar(0x0D);
  19.  
  20. while(getchar()!=0x0A){};
  21. while(getchar()!=0x0A){};
  22.  
  23.  
  24. a=0;
  25. do{
  26. a++;
  27. cek[a]=getchar();
  28.  
  29. }while(cek[a]!=0x0A);
  30.  
  31. i=1;
  32. lcd_gotoxy(0,1);
  33. while(i<33)
  34. {
  35. if(cek[i]==13) break;
  36. lcd_putchar(cek[i++]);
  37. //delay_ms(100);
  38. }
  39.  
  40. if(cek[1]=='S' || cek[1]=='s' || cek[1]=='?'){
  41. sms_status();
  42. }
  43.  
  44. if(cek[1]=='1')
  45. {
  46. PORTC.5=1;
  47. lcd_gotoxy(0,1);
  48. lcd_puts("Lp1 on ");
  49. }
  50.  
  51. if(cek[1]=='0')
  52. {
  53. PORTC.5=0;
  54. lcd_gotoxy(0,1);
  55. lcd_puts("Lp1 off");
  56. }
  57.  
  58. if(cek[2]=='1')
  59. {
  60. PORTC.7=1;
  61. lcd_gotoxy(8,1);
  62. lcd_puts("Lp2 on ");
  63. }
  64.  
  65. if(cek[2]=='0')
  66. {
  67. PORTC.7=0;
  68. lcd_gotoxy(8,1);
  69. lcd_puts("Lp2 off");
  70. }
  71. sms_not();
  72. delay_ms(1000);
  73.  
  74. if(getchar()=='R'&&getchar()=='I')
  75. { lcd_clear();
  76. lcd_puts("Incomming call");
  77. delay_ms(100);
  78. //mode='R';
  79. PORTC.5=0;
  80. PORTC.7=0;
  81. xdata='-';
  82. sms_send("Lampu 1 off 2 off");
  83. delay_ms(2000);
  84. }
  85.  
  86.  
  87. }
  88.  
  89. }
Advertisement
Add Comment
Please, Sign In to add comment