safwan092

Untitled

Oct 29th, 2022
163
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.23 KB | None | 0 0
  1. #include <SoftwareSerial.h>
  2. SoftwareSerial SIM900A(2,3);
  3. void setup()
  4. {
  5. SIM900A.begin(9600); // Setting the baud rate of GSM Module
  6. Serial.begin(9600); // Setting the baud rate of Serial Monitor (Arduino)
  7. Serial.println ("SIM900A Ready");
  8. delay(100);
  9. Serial.println ("Type s to send message or r to receive message");
  10. delay(15000);
  11. SendMessage();
  12. }
  13. void loop()
  14. {
  15. /*
  16. if (Serial.available()>0)
  17. switch(Serial.read())
  18. {
  19. case 's':
  20. SendMessage();
  21. break;
  22. case 'r':
  23. // RecieveMessage();
  24. break;
  25. }
  26. */
  27. if (SIM900A.available()>0)
  28. Serial.write(SIM900A.read());
  29.  
  30. }
  31. void SendMessage()
  32. {
  33. Serial.println ("Sending Message");
  34. SIM900A.println("AT+CMGF=1"); //Sets the GSM Module in Text Mode
  35. delay(1000);
  36. Serial.println ("Set SMS Number");
  37. // *********
  38. SIM900A.println("AT+CMGS=\"+966580224645\"\r"); //Mobile phone number to send message
  39. delay(1000);
  40. Serial.println ("Set SMS Content");
  41. SIM900A.println("Good 123?");// Messsage content
  42. delay(100);
  43. Serial.println ("Finish");
  44. SIM900A.println((char)26);// ASCII code of CTRL+Z
  45. delay(1000);
  46. Serial.println ("Message has been sent ->SMS Selesai dikirim");
  47. }
Advertisement
Add Comment
Please, Sign In to add comment