Hi
Hope this will help others out there hoe is also just starting to learn Arduino. I played with diffend examples and made one sketch, i have been testing this for 3 weeks now and so far no problems, :
The sketch has two parts to it 1) Turn led on use a cellphone 2) Send Sms when A0 goes High.
Please comment if it can be improved
Thanks
/*
Modified by : Ivan Nair
1) Control Led connected to pin 13 via sms
2) Send Sms to Phone number pin is high
Board used 1) Ardunio Uno
2) GPRS/GSM Shield Sim 900
*/
void setup(){
setupControl();
setupSend();
}
void loop(){
loopControl();
loopSend();
}
#include <SoftwareSerial.h>
char inchar; // Will hold the incoming character from the GSM shield
SoftwareSerial SIM900(7, 8);
int led = 10;
void setupControl()
{
Serial.begin(19200);
// set up the digital pins to control
pinMode(led, OUTPUT);
digitalWrite(led, LOW);
// wake up the GSM shield
SIM900.begin(19200);
delay(20000); // give time to log on to network.
SIM900.print("AT+CMGF=1\r"); // set SMS mode to text
delay(100);
SIM900.print("AT+CNMI=2,2,0,0,0\r");
// blurt out contents of new SMS upon receipt to the GSM shield's serial out
delay(100);
Serial.println("Ready...");
}
void loopControl()
{
//If a character comes in from the cellular module...
if(SIM900.available() >0)
{
inchar=SIM900.read();
if (inchar=='#')
{
delay(10);
inchar=SIM900.read();
if (inchar=='a')
{
delay(10);
inchar=SIM900.read();
if (inchar=='0')
{
digitalWrite(led, LOW);
}
else if (inchar=='1')
{
digitalWrite(led, HIGH);
}
delay(10);
// SIM900.println("AT+CMGD=1,4"); // delete all SMS***** uncomment when done testing sim cards hold up to 50 sms
}
}
}
}