Pages: [1]   Go Down
Author Topic: gsm900 programming problem....  (Read 628 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 27
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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);
   
  }
 
 
}
Logged

Pages: [1]   Go Up
Jump to: