Advertisement
RuiViana

Untitled

Jun 9th, 2015
340
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.47 KB | None | 0 0
  1. #include<SoftwareSerial.h>
  2. #include "sms.h"
  3. SMSGSM sms;
  4.  
  5. boolean started=false;
  6. char posicao_sms;
  7. char texto_sms[10];
  8. char num_fone[20];
  9. char num_cadastrado[] = "+557791991885";
  10. int i;
  11. int led1;
  12. int led2;
  13.  
  14. String xpto(texto_sms);
  15.  
  16. //------------------------------------------------
  17. void setup()
  18. {
  19. pinMode(led1, OUTPUT);
  20. pinMode(led2, OUTPUT);
  21. Serial.begin(9600);
  22. Serial.println("Testando Sistema....");
  23. if (gsm.begin(4800)){
  24. Serial.println("\nSistema Pronto!");
  25. started=true;}
  26. else
  27. Serial.println("\nSistema Inativo!");
  28. }
  29. //------------------------------------------------
  30. void loop()
  31. {
  32. if(started)
  33. {
  34. for(i=1;i<=20;i++)
  35. {
  36. sms.DeleteSMS(i);
  37. }
  38. posicao_sms=sms.IsSMSPresent(SMS_UNREAD);
  39. if (posicao_sms)
  40. {
  41. Serial.print("Posicao do SMS:");
  42. Serial.println(posicao_sms,DEC);
  43. sms.GetSMS(posicao_sms, num_fone, texto_sms, 10);
  44. Serial.println(num_fone);
  45. // Serial.println(texto_sms);
  46. Serial.println(xpto);
  47. }
  48.  
  49. /* if (texto_sms == 'v1on')
  50. digitalWrite(led1, HIGH);
  51.  
  52. if (texto_sms == 'v1off')
  53. digitalWrite(led1, LOW);
  54.  
  55. if (texto_sms == 'v2on')
  56. digitalWrite(led2, HIGH);
  57.  
  58. if (texto_sms == 'v2off')
  59. digitalWrite(led2, LOW);*/
  60. // }
  61. // else{
  62. Serial.println("Sem novos SMS's. AGUARDANDO!");
  63. //}
  64. // }
  65. delay(500);
  66. }
  67. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement