I am new to micro controller programming.I am trying to connect SIM300 with Arduino duelmilanove ATmega168.
I was able to send SMS,call and other functions required for my project.I was even able to receive data from SIM300.Now I stuck at reading SMS from Memory.
For testing the reading part of my code is as follows:
Code: Select all
#include <SoftwareSerial.h>
SoftwareSerial mySerial(2,3);
const int buttonPin = 5;
int index = 0;
boolean stringComplete = false; // whether the string is complete
String inputString = "";
int buttonState = 0;
void setup() {
// initialize serial:
mySerial.begin(9600); // the GPRS baud rate
Serial.begin(9600);
// reserve 200 bytes for the inputString:
//inputString.reserve(1200);
mySerial.println("AT");
delay(2000);
}
void loop() {
mySerialEvent();
// print the string when a newline arrives:
if (stringComplete) {
Serial.println("Loop input String = " + inputString + "...");
// clear the string:
inputString = "";
stringComplete = false;
}
buttonState = digitalRead(buttonPin);
if (buttonState == LOW) {
mySerial.println("AT+CMGF=1");
delay(2500);
mySerial.print( "AT+CMGR=1" );
}
}
void mySerialEvent() {
while (mySerial.available()) {
// get the new byte:
char inChar = (char)mySerial.read();
// add it to the inputString:
inputString += inChar;
// if the incoming character is a newline, set a flag
// so the main loop can do something about it:
if (inChar == '\n') {
stringComplete = true;
}
}
//Serial.println("Outside while inputstring=" + inputString + "...");
}
Output is as follows:
Code: Select all
AT+CMGR=1
+CMGR: "REC READ","phonenumber","","9/9/13,03:40:
Thanks,
Pallavi