Hello everyone
I´m using these shield: https://docs.google.com/file/d/0B7YYTsMTTwiLSTBiSmUzQ0IxdVk/edit?usp=sharing&pli=1
the SIM900 shield and using this code to send messages,as I write the messages on the serial monitor, and to turn off calls, as I type 'R' on the serial monitor :
/*
Software serial multple serial test
Receives from the hardware serial, sends to software serial.
Receives from software serial, sends to hardware serial.
created back in the mists of time
modified 25 May 2012
by Tom Igoe
based on Mikal Hart's example
This example code is in the public domain.
*/
#include <SoftwareSerial.h>
SoftwareSerial mySerial(5, 6); // RX, TX pins selected by the jumpers of the shield
char state=0;
int c=0;
uint8_t string_a_ser_env[128];
void setup()
{
// Open serial communications and wait for port to open:
Serial.begin(9600);
while (!Serial) {
; // wait for serial port to connect. Needed for Leonardo only
}
Serial.println("Goodnight moon!");
// set the data rate for the SoftwareSerial port
mySerial.begin(9600);
mySerial.println("Hello, world?");
}
void loop() // run over and over
{
if (mySerial.available())
Serial.write(mySerial.read());
while(Serial.available() >0)
{
string_a_ser_env[c] = Serial.read();
c++;
state=1;
Serial.write("FINISHED READING \n");
delay(10);
}
if (state==1 && string_a_ser_env[0] != 82)
{
//Serial.write("STADO 2 \n");
state=2;
}
if (state==1 && string_a_ser_env[0] == 82) //cancels the call when reads 'R'
{
delay(1000);
mySerial.println("ATH");
state = 0;
c=0;
}
if (state == 2)
{
//Serial.write(string_a_ser_env,c);
mySerial.write("AT+CMGS=\"+*************\"\r");
delay(1000);
mySerial.write(string_a_ser_env,c);
mySerial.write(0x1A);
state=0;
c=0;
Serial.write("SENT A SMS\n");
}
}
So, what I need now is to identify a signal when I´m receiving a call(like to read something on the serial port, or any code that the shield sends to me) and to get the phone number that is calling me. Does anyone has any idea of how to do it?
Thanks