PROGRAM SMS MENGGUNAKAN ARDUINO

Assalamu’alaikum Wr. WB
kali ini saya akan menjelaskan
tentang tata cara pembuatan
jam digital pada aplikasi java eclipse
saya sangat berharap postingan  ini
dapat berguna dalam rangka
menambah wawasan serta pengetahuan
pertama alat alat yang digunakaN

1. arduino uno v3.0
2. gsm module SIM900A
3. 4 kabel jamper
4. 1 led
5. 1 kabel penghubung serial port
6. 1 buah kartu gsm


dibawah ini adalah foto rangkainyannya
keterangan :
  • kabel warna hijau  (Arduino pin  02  —->GSM Module 5VT  )
  • kabel warna putih (Arduino pin 03 ——>GSM Module  5VR )
  • kabel warna hitam (Arduino GND —–>GSM Module GND )
  • kabel warna hitam  (Arduino 5V ——> GSM Module  VCC5  )
  • led  (led negatif –>GND)
  • led  (led positih –>pin13)

dan di bawah ini code arduino

  1. /*

  2. SMS sender

  3.  

  4. This sketch, for the Arduino GSM shield,sends an SMS message

  5. you enter in the serial monitor. Connect your Arduino with the

  6. GSM shield and SIM card, open the serial monitor, and wait for

  7. the "READY" message to appear in the monitor. Next, type a

  8. message to send and press "return". Make sure the serial

  9. monitor is set to send a newline when you press return.

  10.  

  11. Circuit:

  12. * GSM shield

  13. * SIM card that can send SMS

  14.  

  15. created 25 Feb 2012

  16. by Tom Igoe

  17.  

  18. This example is in the public domain.

  19.  

  20. http://www.arduino.cc/en/Tutorial/GSMExamplesSendSMS

  21.  

  22. */

  23.  

  24. // Include the GSM library

  25. #include <GSM.h>

  26.  

  27. #define PINNUMBER ""

  28. #define pinReady 13

  29. #define pinSend 12

  30.  

  31. String strTampung;

  32. String mantap = "08xxxxxxxxxx";//sesuaikan dengan nomer yang mau dituju

  33. int LED_one = 13;

  34. // initialize the library instance

  35. GSM gsmAccess;

  36. GSM_SMS sms;

  37. char txtMsg[200]="bisa ko...";

  38. void setup() {

  39. pinMode(pinReady, OUTPUT);

  40. pinMode(pinSend, OUTPUT);

  41. // initialize serial communications and wait for port to open:

  42. Serial.begin(9600);

  43. while (!Serial) {

  44. ; // wait for serial port to connect. Needed for native USB port only

  45. }

  46.  

  47. Serial.println("SMS Messages Sender");

  48.  

  49. // connection state

  50. boolean notConnected = true;

  51.  

  52. // Start GSM shield

  53. // If your SIM has PIN, pass it as a parameter of begin() in quotes

  54. while (notConnected) {

  55. if (gsmAccess.begin(PINNUMBER) == GSM_READY) {

  56. notConnected = false;

  57. } else {

  58. Serial.println("Not connected");

  59. delay(1000);

  60. }

  61. }

  62.  

  63. Serial.println("GSM initialized");

  64. digitalWrite(pinReady, HIGH);

  65. }

  66.  

  67. void loop() {

  68.  

  69. /*

  70.  

  71. digitalWrite(pinSend, HIGH);

  72. //Serial.print("Enter a mobile number: ");

  73. char remoteNum[20]; // telephone number to send sms

  74. readSerial(remoteNum);

  75. //Serial.println(remoteNum);

  76. */

  77.  

  78. // sms text

  79. /*Serial.print("Now, enter SMS content: ");

  80. char txtMsg[200];

  81. readSerial(txtMsg);

  82. Serial.println("SENDING");

  83. Serial.println();

  84. Serial.println("Message:");

  85. Serial.println(txtMsg);

  86. */

  87.  

  88. /*

  89. // send the message

  90. digitalWrite(pinSend, LOW);

  91. sms.beginSMS(remoteNum);

  92. sms.print(txtMsg);

  93. sms.endSMS();

  94. Serial.println("\nCOMPLETE!\n");

  95. */

  96.  

  97. while (Serial.available()) {

  98. char charSerial = Serial.read();

  99. delay(10);

  100.  

  101. // ini berarti enter

  102. if (charSerial == '\n') {

  103. // Serial.println("n");

  104. break;

  105. } //ini karakter karakter apa gitu

  106. else if (charSerial == '\r') {

  107. // Serial.println("r");

  108. }

  109. else {

  110. // Serial.println("tambahkan");

  111. strTampung += charSerial;

  112. }

  113. }

  114.  

  115. if (strTampung.length() > 0) {

  116. Serial.println(strTampung);

  117. if (strTampung == mantap) {

  118. digitalWrite(pinSend, HIGH );

  119. //Serial.println("ini yg dicari");

  120. // send the message

  121. char remoteNum[20]; // telephone number to send sms

  122. strTampung.toCharArray(remoteNum, 20);

  123. sms.beginSMS(remoteNum);

  124. sms.print(txtMsg);

  125. sms.endSMS();

  126. Serial.println("\nCOMPLETE!\n");

  127.  

  128. digitalWrite( pinSend, LOW );

  129. } else {

  130.  

  131. }

  132. strTampung="";

  133. }

  134. }

  135.  

  136. /*

  137. Read input serial

  138. */

  139. int readSerial(char result[]) {

  140. int i = 0;

  141. while (1) {

  142. while (Serial.available() > 0) {

  143. char inChar = Serial.read();

  144. if ((inChar == '\n') || (inChar == '#')) {

  145. result[i] = '\0';

  146. Serial.flush();

  147. return 0;

  148. }

  149. if (inChar != '\r') {

  150. result[i] = inChar;

  151. i++;

  152. }

  153. }

  154. }

  155. }


Jika Ingin Lebih jelas nya anda bisa melihat video demo berikut :

Comments

Popular Posts