Serial.begin(9600);
delay(3000);
Serial.println("AT+CPMS="ME""); // AT commands for sony T610
delay(3000);
Serial.println("ATE=0"); // ECHO off
delay(3000);
Serial.println("AT+CMGF=1"); //text format
delay(3000);
Serial.println("AT+CMGR=1"); //read text message from the location 1 of the phone
delay(3000);
if (Serial.available() > 0) {
/* Now i cant understand how to assign that
data string received in the form of text message to a memory
locaton on arduino and compare with another string and
then do the appropriate action.*/
/* I want to compare the received message with string "ON" and "OFF"
and if the message contains ON then set a digital pin high for 30 minutes max and
if off is received then set that digital pin Low
Embedding your questions in the comments is a good way to get ignored. I'd recommend that you not do that again.
I'd recommend that you learn how to read serial data, how to save it an an array, and how to parse that data, before you worry about what to do with a value received from the phone.
Below is some simple on/off test code Use the # post tool bar to use the code tags.
// zoomkat 8-6-10 serial I/O string test
// type a string in serial monitor. then send or enter
// for IDE 0019 and later
int ledPin = 13;
String readString;
void setup() {
Serial.begin(9600);
pinMode(ledPin, OUTPUT);
Serial.println("serial on/off test 0021"); // so I can keep track
}
void loop() {
while (Serial.available()) {
delay(1);
char c = Serial.read();
readString += c;
}
if (readString.length() >0) {
Serial.println(readString);
if (readString == "on")
{
digitalWrite(ledPin, HIGH);
}
if (readString == "off")
{
digitalWrite(ledPin, LOW);
}
readString="";
}
}
i dont understand this ......please clarify...this code line
readString.indexOf("96xxxxxxxx")>0 &&(readString.indexOf("44FA33106")>0)..
may be 96xxxxxxx in the no.
and hex code..... "44fa33106" meant?
s2sobhani:
i used sony ericsson k810i + arduino uno but thats not work..
"Not work" doesn't give us any idea what you want it to do or what it's actually doing.
Your sketch seems to be writing AT commands to the hardware serial port, and reading responses from the same port. Usually this port would be used for communication with the PC so that you can see what is going on. Trying to connect more than one device to a given serial port is asking for trouble. How is the Arduino connected to the modem and to the PC?
hi thanks for repply
sony ericsson k810i rx tx is connected to pins 0 and 1..i use pin 13 for output..
i wanna switch pin 13 to ON(with ON1) and OFF (with OFF1)..
every thing work correct but when send sms to k810i nothing heppend..
i tested it with usb power and 12V 1.5A power adaptor
arduinu connected to pc with usb and pins 0 1 connected to k810i but when i wanna send sms i plug out usb..
thanks for help