i have installed a GSM shield on the Arduino to create security alarm system using PIR SENSOR when ever there motion I will receive a call to my phone. but i want to add also a line of code which can make my system send me a txt message stating that my system is turned on so i can make sure that when ever i turn my system on i can doule check by getting a message that says that system is turned on successfully i dont know how to start doing that. this is the code i did:

int PIR = 6;

void setup() {
  // put your setup code here, to run once:
 pinMode (PIR , INPUT );

void loop() {
  // put your main code here, to run repeatedly:
if (digitalRead (PIR == HIGH)){
  Serial.println("thief detected");
  delay (200);
  Serial.println ("ATD+0197263315;");
  else digitalWrite (PIR, LOW );
  • 2
    if (digitalRead (PIR == HIGH)) is not doing what you think it does. Look at where your parenthesis are. – timemage May 5 at 13:51
  • can explain more – user76732 May 5 at 18:15
  • PIR == HIGH is false, because PIR is 6 and HIGH is 1. You have digitalRead(false). digitalRead takes type int. Converted to int, false is 0. You have effectively digitalRead(0). – timemage May 5 at 20:15

You can send an SMS using the Arduino GSM library. Here is a bare bones sketch that sends one pre-set SMS when it starts up, based on this tutorial:

#include <GSM.h>

#define PINNUMBER "1234"
#define REMOTENUMBER "07123456789"
#define TXTMESSAGE "System started!"

GSM gsmAccess;
GSM_SMS sms;

void setup() {
  boolean notConnected = true;

  while (notConnected) {
    if (gsmAccess.begin(PINNUMBER) == GSM_READY) {
      notConnected = false;
    } else {


void loop() {

If you can't or don't want to use the GSM library, it should also be possible to send an SMS by using the SoftwareSerial library to control your GSM shield using AT codes. Here's a tutorial on this approach, which is lighter weight but might be more fiddly to get working, especially if you need a PIN for your SIM card.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.