Help in gsm programming

I am making a project to take part in the school's science exhibition .the project uses an arduino and gsm module (900)to send a message when motion is detected .I want it to some the message only once
I have written the following code -:

#define SEN_input 10
#define LED_alert 12

void setup()
{
Serial.begin(9600);  
 pinMode(SEN_input, INPUT);
  pinMode(LED_alert, OUTPUT);
Serial.println('AT+CMGF=1'); 
delay(200);
}
void loop()
{
  int thief;
  while(1)
  {
   thief=digitalRead(SEN_input);
   if(thief)
{
digitalWrite(LED_alert,HIGH);
Serial.print('AT+CMGS=\'');
Serial.print("ATD123;");
Serial.println("\"");
Serial.print("manansh!");  
delay(1000);
Serial.write(0x1A);  
Serial.write(0x0D);  
Serial.write(0x0A);  
delay(10000);
   }
   else
   {
     digitalWrite(LED_alert,LOW);
     delay(100);

}
}
}
[code\]
any help will be appreciated, :)  thank you  :)

Firstly I'd suggest you put your code inside code tags (simply put

 [code] in front of it and [/code] at the end of it.)

Next I'd suggest you run it and see what happens.

KenF first of all thanks your help ,I have uploaded the above code in my arduino but whenever i connect a jumper in pin10, pin12 goes high irrespective of the sensor input

What are you using to detect motion? Could you perhaps post a schematic.

I am using an ir sensor here is the schematic attached

"infra red sensor" is quite vague. Do you have a link for the actual device. (better still a datasheet but a link would be a good start)

Serial.println('AT+CMGF=1');

The ' simbol is just for representing a single caracter not a full string!

   thief=digitalRead(SEN_input);
   if(thief)

Are you debouncing the signal from your sensor?

if(thief)
{
digitalWrite(LED_alert,HIGH);
Serial.print('AT+CMGS='');
Serial.print("ATD9871180166;");

Ok if you have movement then you send the message but why are you using the ATD comand?
ATD is for dial a number...
The rigth sintax to send an SMS is:

Serial.println("AT + CMGS = \"9871180166\"");
  delay(100);
  Serial.println("A test message!");//the content of the message
  delay(100);
  Serial.println((char)26);//the ASCII code of the ctrl+z is 26
  delay(100);
  Serial.println();

thank you hugopt, is this right

Run it on your device and it will give you the answer :slight_smile:
Note some SIM900 boards have a small switch to start the modem.If this is your case you will need to press it during boot of just use a pin to do that on your setup() function