Go Down

Topic: gsm900 programming problem.... (Read 718 times) previous topic - next topic

Please i need help i m doing my final year project...... what i want is when send sms "On" led should turn on and when i send sms "Off" led should turn off but when i send sms "Off" PIR sensor should start work..... but i dont know its not working here is my code please anyone can help meee


#include "SIM900.h"
#include <SoftwareSerial.h>
//#include "inetGSM.h"
#include "sms.h"
SMSGSM sms;
int numdata;
boolean started=false;
char smsbuffer[160];
char n[20];
int ledPin = 13; // led connected to control pin 13
int PIRSensor = 2; // the PIR sensor will be plugged at digital pin 2
int val=0;
void setup() {
pinMode(ledPin, OUTPUT); // declare the ledPin as as OUTPUT
pinMode(PIRSensor, INPUT); // declare the PIRSensor as as OUTPUT
Serial.begin(9600); // use the serial port
  Serial.println("GSM Shield testing.");
  //Start configuration of shield with baudrate.
  //For http uses is raccomanded to use 4800 or slower.
  if (gsm.begin(2400)){
    Serial.println("\nstatus=READY");
    started=true; 
  }
  else Serial.println("\nstatus=IDLE");
 
  if(started){
    //Enable this two lines if you want to send an SMS.
    //if (sms.SendSMS("3471234567", "Arduino SMS"))
      //Serial.println("\nSMS sent OK");
  }

};
void PIRON(){

if(digitalRead(PIRSensor==HIGH)){   // read the input pin
  digitalWrite(ledPin, HIGH);      // sets the LED to the button's value
  delay(1000);   
digitalWrite(ledPin, LOW);   // delay in milisecond. 3000 = 3 second
  }

}


void loop() {
   if(started){
    //Read if there are messages on SIM card and print them.
    if(gsm.readSMS(smsbuffer, 160, "On", 20))
    {
       digitalWrite(ledPin, HIGH);
      Serial.println(n);
      Serial.println(smsbuffer);

    }
     if(gsm.readSMS(smsbuffer, 160, "Off", 20))
    {

  digitalWrite(ledPin, LOW);
     
       PIRON();
Serial.println(n);
      Serial.println(smsbuffer);
 
    }
    delay(1000);
   
  }

 
}

Go Up
 


Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

Arduino
via Egeo 16
Torino, 10131
Italy