GSM
Two door and send SMS that door is open.
void setup()
{
Serial.begin(9600); //Initialise serial to communicate with GSM Modem
}
void loop()
{
delay(10000); //Give enough time for GSM to register on Network
SendSMS(); //Send one SMS
while(1); //Wait forever
}
void SendSMS()
{
Serial.println("AT+CMGF=1"); //To send SMS in Text Mode
delay(1000);
Serial.println("AT+CMGS=\"+9198xxxxxxxx\"\r"); //Change to destination phone number
delay(1000);
Serial.println("Hello from GSM Modem!");//the content of the message
delay(200);
Serial.println((char)26); //the stopping character Ctrl+Z
delay(1000);
}
Two door and send SMS that door is open.
void setup()
{
Serial.begin(9600); //Initialise serial to communicate with GSM Modem
pinMode(8,INPUT);
digitalWrite(8,HIGH);
pinMode(9,INPUT);
digitalWrite(9,HIGH);
}
void loop()
{
delay(10000); //Give enough time for GSM to register on Network
if(!digitalRead(8))
{
SendSMS(0);
while(!digitalRead(8));
}
if(!digitalRead(9))
{
SendSMS(1);
while(!digitalRead(9));
}
while(1); //Wait forever
}
void SendSMS(int st)
{
Serial.println("AT+CMGF=1"); //To send SMS in Text Mode
delay(1000);
Serial.println("AT+CMGS=\"+9198xxxxxxxx\"\r"); //Change to destination phone number
delay(1000);
if(st==0)
{
Serial.println("Hello from door1!");//the content of the message
}
if(st==1)
{
Serial.println("Hello from door2!");//the content of the message
}
delay(200);
Serial.println((char)26); //the stopping character Ctrl+Z
delay(1000);
}
Count the number of person pass from the door using GSM.
#include<LiquidCrystal.h>
LiquidCrystal lcd(12,11,5,4,3,2);
int c;
void setup()
{
lcd.begin(16,2);
Serial.begin(9600); //Initialise serial to communicate with GSM Modem
pinMode(8,INPUT);
digitalWrite(8,HIGH);
pinMode(9,INPUT);
digitalWrite(9,HIGH);
c=0;
}
void loop()
{
delay(10000); //Give enough time for GSM to register on Network
if(!digitalRead(8))
{
SendSMS(0);
c++;
lcd.setCursor(0,1);
lcd.print(c);
while(!digitalRead(8));
}
if(!digitalRead(9))
{
SendSMS(1);
c--;
lcd.setCursor(0,1);
lcd.print(c);
while(!digitalRead(9));
}
while(1); //Wait forever
}
void SendSMS(int st)
{
Serial.println("AT+CMGF=1"); //To send SMS in Text Mode
delay(1000);
Serial.println("AT+CMGS=\"+9198xxxxxxxx\"\r"); //Change to destination phone number
delay(1000);
if(st==0)
{
Serial.println("Hello from door1!");//the content of the message
}
if(st==1)
{
Serial.println("Hello from door2!");//the content of the message
}
delay(200);
Serial.println((char)26); //the stopping character Ctrl+Z
delay(1000);
}
Comments
Post a Comment