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 :)
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
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();
Run it on your device and it will give you the answer
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