I found a sketch that did work it send a text message to my cellphone
#include <SoftwareSerial.h>
SoftwareSerial GPRS(7, 8);
void setup()
{
GPRS.begin(19200);// the GPRS baud rate
Serial.begin(19200);// the Serial port of Arduino baud rate.
// attach to GPRS service
GPRS.println("AT+CPAS?");//Check Phone Status
delay(2000);
if (GPRS.available()>0) // Check to see if GPRS Shield is on
{
toSerial(); //print response to serial
}
else { //Turn on shield if it is off
powerUpOrDown();
delay(2000);
}
// bearer settings
GPRS.println("AT+SAPBR=3,1,\"CONTYPE\",\"GPRS\"");
delay(1000);
toSerial();
//Replace "epc.tmobile.com" with APN of your provider
GPRS.println("AT+SAPBR=3,1,\"APN\",\"epc.tmobile.com\"");
delay(4000);
toSerial();
// bearer settings
GPRS.println("AT+SAPBR=1,1");
delay(2000);
toSerial();
}
void loop()
{
GPRS.println("AT+CMGF=1"); //Tell SIM 900 you are about to send a text
delay(100);
GPRS.println("AT + CMGS = \"5554443333\""); //Replace with number to text
delay(100);
GPRS.println("This is your text message");//Replace with your message
delay(100);
GPRS.println((char)26); //tells sim900 to send text
delay(100);
toSerial();
delay(60000); //wait one min to not flood your phone
}
void toSerial() //Write SIM 900 response to serial
{
while(GPRS.available()!=0)
{
Serial.write(GPRS.read());
}
}
void powerUpOrDown() //Power off or on GPRS Shirld
{
pinMode(9, OUTPUT);
digitalWrite(9,LOW);
delay(1000);
digitalWrite(9,HIGH);
delay(2000);
digitalWrite(9,LOW);
delay(3000);
}
and this is the code that doesn't work
#include <SoftwareSerial.h>
char inchar; // Will hold the incoming character from the GSM shield
SoftwareSerial SIM900(7, 8);
int led1 = 10;
int led2 = 11;
int led3 = 12;
int led4 = 13;
void setup()
{
Serial.begin(19200);
// set up the digital pins to control
pinMode(led1, OUTPUT);
pinMode(led2, OUTPUT);
pinMode(led3, OUTPUT);
pinMode(led4, OUTPUT);
digitalWrite(led1, LOW);
digitalWrite(led2, LOW);
digitalWrite(led3, LOW);
digitalWrite(led4, LOW);
// wake up the GSM shield
SIM900power();
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 SIM900power()
// software equivalent of pressing the GSM shield "power" button
{
digitalWrite(9, HIGH);
delay(1000);
digitalWrite(9, LOW);
delay(7000);
}
void loop()
{
//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(led1, LOW);
}
else if (inchar=='1')
{
digitalWrite(led1, HIGH);
}
delay(10);
inchar=SIM900.read();
if (inchar=='b')
{
inchar=SIM900.read();
if (inchar=='0')
{
digitalWrite(led2, LOW);
}
else if (inchar=='1')
{
digitalWrite(led2, HIGH);
}
delay(10);
inchar=SIM900.read();
if (inchar=='c')
{
inchar=SIM900.read();
if (inchar=='0')
{
digitalWrite(led3, LOW);
}
else if (inchar=='1')
{
digitalWrite(led3, HIGH);
}
delay(10);
inchar=SIM900.read();
if (inchar=='d')
{
delay(10);
inchar=SIM900.read();
if (inchar=='0')
{
digitalWrite(led4, LOW);
}
else if (inchar=='1')
{
digitalWrite(led4, HIGH);
}
delay(10);
}
}
SIM900.println("AT+CMGD=1,4"); // delete all SMS
}
}
}
}
}
trying to control 4 leds using text messages can you help i have no clue i try to mod the good code with some of the led control from the bad code and no luck.