Hi
As im new to programming, I have being playing with different examples and trying to get them to work.
Finally i got this working. The sketch sends a SMS when A0 goes HIGH. Also ifI send a command "#a0 or #a1 from my cellphone I can switch led connected to pin13 on or off. I hope this can help some out there like me hoe is also starting with Arduino and spends a lot of trying to get thing to work.
For those more experenced programmers out there can you please comment one how the two coded are put together. Some info would be nice
Regards
Ivan nair
/*
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
:grin: :grin: 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 = 13;
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
}
}
}
}