#include <SoftwareSerial.h>
SoftwareSerial mySerial(9,10);
char incomingByte=0;
void setup()
{
Serial.begin(9600);
mySerial.begin(9600);
//pinMode(13, OUTPUT);
mySerial.println("AT");
delay(1000);
mySerial.println("AT+CMGF=1");
delay(2000);
//mySerial.println("AT+CSMP=17,167,0,0");
mySerial.println("AT+CNMI=2,2,0,1,0");
delay(1000);
}
void loop()
{
mySerial.write("AT+CMGL=");
mySerial.write(34);
mySerial.write("ALL");
mySerial.write(34);
mySerial.write(13);//to move down one line
mySerial.write(10);//to place cursor on left margin.Equivalent to pressing "enter"
delay(1000);
while (mySerial.available() > 0)
{
incomingByte = mySerial.read();
if(incomingByte!='\n')
{
Serial.print(incomingByte);
}
if(incomingByte=='\n')
{
Serial.print(incomingByte);
Serial.write(13);
Serial.write(10);
}
}
}