Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Example 55.2
- #include <SoftwareSerial.h>
- SoftwareSerial SIM900(7, 8);
- void setup()
- {
- SIM900.begin(19200);
- while (!SIM900) {
- // ждём, пока не откроется монитор последовательного порта
- // для того, чтобы отследить все события в программе
- }
- SIM900power();
- delay(10000); // give time to log on to network.
- }
- void SIM900power()
- // software equivalent of pressing the GSM shield "power" button
- {
- pinMode(9, OUTPUT);
- digitalWrite(9, HIGH);
- delay(3000);
- digitalWrite(9, LOW);
- delay(1000);
- }
- void sendSMS()
- {
- SIM900.print("AT+CMGF=1\r"); // AT command to send SMS message
- delay(100);
- SIM900.println("AT + CMGS = \"+37529XXXXXXX\""); // recipient's mobile number, in international format
- delay(100);
- SIM900.println("Hello, world. This is a text message from an Arduino Uno."); // message to send
- delay(100);
- SIM900.println((char)26); // End AT command with a ^Z, ASCII code 26
- delay(100);
- SIM900.println();
- delay(5000); // give module time to send SMS
- SIM900power(); // turn off module
- }
- void loop()
- {
- sendSMS();
- do {} while (1);
- }
Add Comment
Please, Sign In to add comment