/********* Complete project details at http://randomnerdtutorials.com *********/ #include // Configure software serial port SoftwareSerial SIM900(7, 8); //Variable to save incoming SMS characters char incoming_char=0; int i=0; char ricevuto[160]; String casting; void setup() { pinMode(3,OUTPUT); pinMode(4,OUTPUT); // Arduino communicates with SIM900 GSM shield at a baud rate of 19200 // Make sure that corresponds to the baud rate of your module SIM900.begin(19200); // For serial monitor Serial.begin(19200); // Give time to your GSM shield log on to network delay(3000); // AT command to set SIM900 to SMS mode SIM900.print("AT+CMGF=1\r"); delay(100); // Set module to send SMS data to serial out upon receipt SIM900.print("AT+CNMI=2,2,0,0,0\r"); delay(100); digitalWrite(3,HIGH); digitalWrite(4,HIGH); } void loop() { // Display any text that the GSM shield sends out on the serial monitor if(SIM900.available() >0) { int i = 0; casting = ""; while(SIM900.available() >0) { incoming_char=SIM900.read(); casting = casting + (String) incoming_char; } casting = casting.substring(51,casting.length()-1); Serial.print(casting); } String prova = "ANTANI"; if(casting=="antani") { Serial.print("ok"); digitalWrite(3,LOW); } }