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
- 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
- /*
- SMS sender
- This sketch, for the Arduino GSM shield,sends an SMS message
- you enter in the serial monitor. Connect your Arduino with the
- GSM shield and SIM card, open the serial monitor, and wait for
- the "READY" message to appear in the monitor. Next, type a
- message to send and press "return". Make sure the serial
- monitor is set to send a newline when you press return.
- Circuit:
- * GSM shield
- * SIM card that can send SMS
- created 25 Feb 2012
- by Tom Igoe
- This example is in the public domain.
- http://www.arduino.cc/en/Tutorial/GSMExamplesSendSMS
- */
- // Include the GSM library
- #include <GSM.h>
- #define PINNUMBER ""
- #define pinReady 13
- #define pinSend 12
- String strTampung;
- String mantap = "08xxxxxxxxxx";//sesuaikan dengan nomer yang mau dituju
- int LED_one = 13;
- // initialize the library instance
- GSM gsmAccess;
- GSM_SMS sms;
- char txtMsg[200]="bisa ko...";
- void setup() {
- pinMode(pinReady, OUTPUT);
- pinMode(pinSend, OUTPUT);
- // initialize serial communications and wait for port to open:
- Serial.begin(9600);
- while (!Serial) {
- ; // wait for serial port to connect. Needed for native USB port only
- }
- Serial.println("SMS Messages Sender");
- // connection state
- boolean notConnected = true;
- // Start GSM shield
- // If your SIM has PIN, pass it as a parameter of begin() in quotes
- while (notConnected) {
- if (gsmAccess.begin(PINNUMBER) == GSM_READY) {
- notConnected = false;
- } else {
- Serial.println("Not connected");
- delay(1000);
- }
- }
- Serial.println("GSM initialized");
- digitalWrite(pinReady, HIGH);
- }
- void loop() {
- /*
- digitalWrite(pinSend, HIGH);
- //Serial.print("Enter a mobile number: ");
- char remoteNum[20]; // telephone number to send sms
- readSerial(remoteNum);
- //Serial.println(remoteNum);
- */
- // sms text
- /*Serial.print("Now, enter SMS content: ");
- char txtMsg[200];
- readSerial(txtMsg);
- Serial.println("SENDING");
- Serial.println();
- Serial.println("Message:");
- Serial.println(txtMsg);
- */
- /*
- // send the message
- digitalWrite(pinSend, LOW);
- sms.beginSMS(remoteNum);
- sms.print(txtMsg);
- sms.endSMS();
- Serial.println("\nCOMPLETE!\n");
- */
- while (Serial.available()) {
- char charSerial = Serial.read();
- delay(10);
- // ini berarti enter
- if (charSerial == '\n') {
- // Serial.println("n");
- break;
- } //ini karakter karakter apa gitu
- else if (charSerial == '\r') {
- // Serial.println("r");
- }
- else {
- // Serial.println("tambahkan");
- strTampung += charSerial;
- }
- }
- if (strTampung.length() > 0) {
- Serial.println(strTampung);
- if (strTampung == mantap) {
- digitalWrite(pinSend, HIGH );
- //Serial.println("ini yg dicari");
- // send the message
- char remoteNum[20]; // telephone number to send sms
- strTampung.toCharArray(remoteNum, 20);
- sms.beginSMS(remoteNum);
- sms.print(txtMsg);
- sms.endSMS();
- Serial.println("\nCOMPLETE!\n");
- digitalWrite( pinSend, LOW );
- } else {
- }
- strTampung="";
- }
- }
- /*
- Read input serial
- */
- int readSerial(char result[]) {
- int i = 0;
- while (1) {
- while (Serial.available() > 0) {
- char inChar = Serial.read();
- if ((inChar == '\n') || (inChar == '#')) {
- result[i] = '\0';
- Serial.flush();
- return 0;
- }
- if (inChar != '\r') {
- result[i] = inChar;
- i++;
- }
- }
- }
- }
Jika Ingin Lebih jelas nya anda bisa melihat video demo berikut :
Comments