Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <SoftwareSerial.h>
- // Makes a SoftwareSerial object in order to communicate with SIM800L module
- SoftwareSerial gsmSerial(12, 11); // SIM800L TXD and RXD is connected to the Arduino pins 12 and 11 respectively
- void setup()
- {
- // Starts the serial communication between the SIM800L module and the Arduino.
- gsmSerial.begin(9600);
- // Starts the serial communication between the Arduino and serial monitor.
- Serial.begin(9600);
- delay(100);
- gsmSerial.println("AT"); // Handshake to check if the module is running. If returns OK, then its fine.
- }
- void loop()
- {
- if (Serial.available() > 0)
- switch(Serial.read())
- {
- case 's':
- SendSMS();
- break;
- case 'r':
- ReadSMS();
- break;
- }
- if (gsmSerial.available() > 0) // if theres any data to collect from the GSM module
- Serial.write(gsmSerial.read()); // then print it to the serial monitor
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement