with this code :
#include <GSM.h> // This includes the GSM library, included in your Arduino IDE
#define PINNUMBER "0462" // declaration of the constant PINNUMBER used to push the pin number of the SIM card
#define PIN 13 // declaration of the constant PIN, and setting it to output nr. 6
GSM gsmAccess; // opens up GSM access on the shield.
GSM_SMS sms;
char remoteNumber[20]; // Variable to store the remote number from the modem.
char c; //Variable for reading the sms messages from the SIM card
int x=0; //Counter for the number of SMS messages processed
char lastm; //Variable to stop SMS replying
String lastMess; //for storing the whole message
// **** 2 Setup ****
void setup() {
//Setup for SMS recieving. Serial setup makes it possible to monitor the status on your PC while connected
Serial.begin(9600);
Serial.println("SMS Recieving");
boolean notConnected = true; // this defines a variable that indicates no GSM connection if true
while(notConnected) { // if there is no connection, the program runs gsmAcess. gsmAcess returns GSM_READY when connected
if(gsmAccess.begin(PINNUMBER)==GSM_READY) // If you have a PIN number on your SIM card, write it as parameters here in quotes. PINNUMBER"9876"
notConnected = false;
else {
//messages printed on the serial monitor or LCD screen, then it tries again in 1000 milliseconds
Serial.println("No connection");
}
}
// if connection is established
Serial.println("GSM connected"); //GSM connected
Serial.println("Waiting"); //Waiting for SMS
}
// **** 3 The loop ****
void loop() {
//reading messages
if (sms.available()) // if there are SMS on the SIM card
{
x++; //message counter adds one
sms.remoteNumber(remoteNumber, 20);
//Show the message on monitor
Serial.println("Messages received from");
Serial.println(remoteNumber); //Prints senders number on the serial monitor
Serial.println("Message:");
while(c=sms.read()) {
if (c == 'H')
{
digitalWrite(13,HIGH);
}
else if (c == 'L')
{
digitalWrite(13,LOW);
}
String nextChar = String (c);
String Mess = (lastMess + nextChar);
lastMess = Mess;
/*sms.read collects one digit of the messages at time and stores it in the variable c.
This while loop builds a String variable "lastMess" from each byte in the messages for displaying.
*/
}
Serial.println(lastMess); // prints the whole messages on the monitor and LCD screen
}//end for
sms.flush(); //discards the SMS message
}
i managed when sending 'H' to turn on the led at pin 13 , but with very low brightness ,and when sending 'L' to turn off the led !
Why does this happen ,blinking the led with low brightness ? I measured 5 V at pin 13 ! do i need a stronger power supply ? i use a 12 V ,800 mA