Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- #include <SoftwareSerial.h>
- SoftwareSerial SIM900A(10,11); // RX | TX
- // Connect the SIM900A TX to Arduino pin 2 RX.
- // Connect the SIM900A RX to Arduino pin 3 TX.
- char c = ' ';
- void setup()
- {
- // start th serial communication with the host computer
- Serial.begin(9600);
- while(!Serial);
- Serial.println("Arduino with SIM900A is ready");
- // start communication with the SIM900A in 9600
- SIM900A.begin(9600);
- Serial.println("SIM900A started at 9600");
- delay(1000);
- Serial.println("Setup Complete! SIM900A is Ready!");
- }
- void loop()
- {
- // Keep reading from SIM800 and send to Arduino Serial Monitor
- if (SIM900A.available())
- { c = SIM900A.read();
- Serial.write(c);}
- // Keep reading from Arduino Serial Monitor and send to SIM900A
- if (Serial.available())
- { c = Serial.read();
- SIM900A.write(c);
- }
- }
- */
- #include <SoftwareSerial.h>
- SoftwareSerial SIM900A(10,11);
- void setup()
- {
- SIM900A.begin(9600); // Setting the baud rate of GSM Module
- Serial.begin(9600); // Setting the baud rate of Serial Monitor (Arduino)
- Serial.println ("SIM900A Ready");
- delay(100);
- Serial.println ("Type s to send message or r to receive message");
- delay(15000);
- SendMessage();
- }
- void loop()
- {
- /*
- if (Serial.available()>0)
- switch(Serial.read())
- {
- case 's':
- SendMessage();
- break;
- case 'r':
- // RecieveMessage();
- break;
- }
- */
- if (SIM900A.available()>0)
- Serial.write(SIM900A.read());
- }
- void SendMessage()
- {
- Serial.println ("Sending Message");
- SIM900A.println("AT+CMGF=1"); //Sets the GSM Module in Text Mode
- delay(1000);
- Serial.println ("Set SMS Number");
- // *********
- SIM900A.println("AT+CMGS=\"+966*********\"\r"); //Mobile phone number to send message
- delay(1000);
- Serial.println ("Set SMS Content");
- SIM900A.println("Good 123?");// Messsage content
- delay(100);
- Serial.println ("Finish");
- SIM900A.println((char)26);// ASCII code of CTRL+Z
- delay(1000);
- Serial.println ("Message has been sent ->SMS Selesai dikirim");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement