Advertisement
Guest User

Untitled

a guest
Mar 20th, 2018
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.74 KB | None | 0 0
  1.  
  2.  
  3. // Include the GSM library
  4. #include <GSM.h>
  5.  
  6. #define PINNUMBER ""
  7.  
  8. // initialize the library instance
  9. GSM gsmAccess;
  10. GSM_SMS sms;
  11.  
  12. #define phone_num "+33652949179"; //portable Medalle.
  13. String toto = "Il faut travaillé";
  14.  
  15. void setup()
  16. {
  17. // initialize serial communications and wait for port to open:
  18. Serial.begin(9600);
  19. while (!Serial) {
  20. ; // wait for serial port to connect. Needed for Leonardo only
  21. }
  22.  
  23. Serial.println("SMS Messages Sender");
  24.  
  25. // connection state
  26. boolean notConnected = true;
  27.  
  28. // Start GSM shield
  29. // If your SIM has PIN, pass it as a parameter of begin() in quotes
  30. while (notConnected)
  31. {
  32. if (gsmAccess.begin(PINNUMBER) == GSM_READY)
  33. notConnected = false;
  34. else
  35. {
  36. Serial.println("Not connected");
  37. delay(1000);
  38. }
  39. }
  40.  
  41. Serial.println("GSM initialized");
  42.  
  43. }
  44.  
  45. void loop()
  46. {
  47.  
  48.  
  49. Serial.print("Enter a mobile number: ");
  50. char remoteNum[20] = phone_num; // telephone number to send sms
  51. Serial.println(remoteNum);
  52.  
  53. // sms text
  54. Serial.print("Now, enter SMS content: ");
  55. char txtMsg[200];
  56.  
  57.  
  58. Serial.println("SENDING");
  59. Serial.println();
  60. Serial.println("Message:");
  61. Serial.println(toto);
  62.  
  63. // send the message
  64. sms.beginSMS(remoteNum);
  65. sms.print(toto);
  66. sms.endSMS();
  67. Serial.println("\nCOMPLETE!\n");
  68. delay (10);
  69. }
  70.  
  71. /*
  72. Read input serial
  73. */
  74. int readSerial(char result[])
  75. {
  76. int i = 0;
  77. while (1)
  78. {
  79. while (Serial.available() > 0)
  80. {
  81. char inChar = Serial.read();
  82. if (inChar == '\n')
  83. {
  84. result[i] = '\0';
  85. Serial.flush();
  86. return 0;
  87. }
  88. if (inChar != '\r')
  89. {
  90. result[i] = inChar;
  91. i++;
  92. }
  93. }
  94. }
  95. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement