IR SENSOR basics

CAN ANY ONE SEND ME THE CODE TO RECIEVING AN OUTPUT FROM AN IR SENSOR MODULE AND SEND A SMS THROUGH GSM 900 MODULE .ANY HELP WILL BE APPRECIATED
I HAVE THE FOLLOWING CODE IS IT RIGHT OR SHOULD THERE BE ANY CHANGES

#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("ATD4444444446;");

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();
  
delay(10000);
   }
   else
   {
     digitalWrite(LED_alert,LOW);
     delay(100);

}
}
}

IS IT RIGHT

NO, AND YOU DON'T NEED TO SCREAM.

Use Tools + Auto Format before you embarrass yourself posting sloppy code again.

The code for sending an SMS depends on which shield you have. If you don't say, we can't help.

There is NO reason to be putting an infinite loop in loop(). Get rid of it!

manansh:
PaulS thank you ,can you elaborate further :slight_smile:

I thought it was quite clear.

  1. Don't write in capitals
  2. Format the program to make it easier to read using the commands suggested in the IDE
  3. Tell us what shield you have
  4. Get rid of the while(1) loop. It is not necessary