lcd.begin(9600);
lcd.begin(16,2);
delay(500);
lcd.setCursor(2, 0); // Set LCD cursor position (column, row)
lcd.print("GSM Security"); // Print text to LCD
lcd.setCursor(5, 1); // Set LCD cursor position (column,row)
lcd.print("System"); // Print text to LCD
delay(4000); // wait 4s // Delay to read text
lcd.clear(); // clear LCD display // Clear the display
lcd.setCursor(2, 0); // Set LCD cursor position (column, row)
lcd.print("Developed By"); // Print text to LCD
lcd.setCursor(2, 1); // Set LCD cursor position (column, row)
lcd.print("Suman Ssk Vinit"); // Print text to LCD
delay(5000); // Delay to read text
lcd.clear(); // Clear LCD
lcd.setCursor(0, 0);
lcd.print("Processing Data.");
delay(3000);
lcd.clear();
lcd.setCursor(3, 0);
lcd.print("Waiting For");
lcd.setCursor(3, 1);
lcd.print("Motion...."); }
void loop()
{
int Check_Burglar();// subroutine to check sensor status and activation of outputs
Check_Reset(); // subroutine to check if alarm reset switch pressed or not
}
void Check_Burglar()
int {{
sensor_value = digitalRead(sensor); // Reading sensor value from pin 8
if (sensor_value == HIGH) // Checking if PIR sensor sends a HIGH signal to Arduino
{ digitalWrite(buzzer, HIGH); // Activating the buzzer
while (sms_count < 3) //Number of SMS Alerts to be sent limited at 3
{ SendTextMessage(); // Function to send AT Commands to GSM module
}
sensor_value = HIGH;
lcd.setCursor(0, 1);
lcd.print("Intruder Alert! SMS sent");
}
}}
void Check_Reset()
{
if (digitalRead(push_switch == HIGH)) // Checking if pushbutton was pressed
{
digitalWrite(buzzer, LOW); // turning OFF the buzzer
lcd.setCursor(0, 1);
lcd.print("Alarm OFF!");
sms_count = 0; // Reactivating the SMS Alert Facility
}
}
void SendTextMessage()
{
mySerial.println("AT+CMGF=1"); //To send SMS in Text Mode
delay(2000);
mySerial.println("AT+CMGS="09755750971"\r"); // change to the phone no.to which sms is sent
delay(2000);
mySerial.println("Intruder detected and alarm initiated!");//the content of the message
delay(200);
mySerial.println((char)26);//the stopping character
delay(5000);
mySerial.println("AT+CMGS="09755750971"\r"); // change to the phone no.to which sms is sent
delay(2000);
mySerial.println("Intruder detected and alarm initiated!");//the content of the message
delay(200);
mySerial.println((char)26);//the message stopping character
delay(5000);
sms_count++;
}
this now compiles but your pins assignement are all over the place and do not make sense!
I suspect you probably tried to merge 2 or more sketches together. Please check your connections and update the inputs and outputs and other relevant pin assigments accroding.
(not tested!)
// library for the LCD display:
#include <LiquidCrystal.h>
#include <SoftwareSerial.h>
LiquidCrystal lcd (4, 5, 10, 11, 12, 13);
SoftwareSerial mySerial(2, 3);
int ledPin = A0;
int PIRpin = A1;
int photocellPin = A2;
int pinSpeaker = A3;
int push_switch;
int buzzer;
int sensor_value;
int sms_count;
int sensor;
void setup()
{
pinMode(ledPin, OUTPUT);
pinMode(PIRpin, INPUT);
pinMode(photocellPin, INPUT);
pinMode(pinSpeaker, OUTPUT);
pinMode(sms_count, OUTPUT);
lcd.begin(16, 2);
delay(500);
lcd.setCursor(2, 0); // Set LCD cursor position (column, row)
lcd.print("GSM Security"); // Print text to LCD
lcd.setCursor(5, 1); // Set LCD cursor position (column,row)
lcd.print("System"); // Print text to LCD
delay(4000); // wait 4s // Delay to read text
lcd.clear(); // clear LCD display // Clear the display
lcd.setCursor(2, 0); // Set LCD cursor position (column, row)
lcd.print("Developed By"); // Print text to LCD
lcd.setCursor(2, 1); // Set LCD cursor position (column, row)
lcd.print("Suman Ssk Vinit"); // Print text to LCD
delay(5000); // Delay to read text
lcd.clear(); // Clear LCD
lcd.setCursor(0, 0);
lcd.print("Processing Data.");
delay(3000);
lcd.clear();
lcd.setCursor(3, 0);
lcd.print("Waiting For");
lcd.setCursor(3, 1);
lcd.print("Motion....");
}
void loop()
{
Check_Burglar();// subroutine to check sensor status and activation of outputs
Check_Reset(); // subroutine to check if alarm reset switch pressed or not
}
void Check_Burglar()
{
sensor_value = digitalRead(sensor); // Reading sensor value from pin 8
if (sensor_value == HIGH) // Checking if PIR sensor sends a HIGH signal to Arduino
{ digitalWrite(buzzer, HIGH); // Activating the buzzer
while (sms_count < 3) //Number of SMS Alerts to be sent limited at 3
{ SendTextMessage(); // Function to send AT Commands to GSM module
}
sensor_value = HIGH;
lcd.setCursor(0, 1);
lcd.print("Intruder Alert! SMS sent");
}
}
void Check_Reset()
{
if (digitalRead(push_switch == HIGH)) // Checking if pushbutton was pressed
{
digitalWrite(buzzer, LOW); // turning OFF the buzzer
lcd.setCursor(0, 1);
lcd.print("Alarm OFF!");
sms_count = 0; // Reactivating the SMS Alert Facility
}
}
void SendTextMessage()
{
mySerial.println("AT+CMGF=1"); //To send SMS in Text Mode
delay(2000);
mySerial.println("AT+CMGS=\"09755750971\"\r"); // change to the phone no.to which sms is sent
delay(2000);
mySerial.println("Intruder detected and alarm initiated!");//the content of the message
delay(200);
mySerial.println((char)26);//the stopping character
delay(5000);
mySerial.println("AT+CMGS=\"09755750971\"\r"); // change to the phone no.to which sms is sent
delay(2000);
mySerial.println("Intruder detected and alarm initiated!");//the content of the message
delay(200);
mySerial.println((char)26);//the message stopping character
delay(5000);
sms_count++;
}
PIRpin, photocellPin, pinSpeaker are not declared.
sensor needs an assignments because it is a pin number
Why are you using sms_count as an output pin?
pinMode(sms_count, OUTPUT);
Your loop() has a function declaration in it:
void loop()
{
int Check_Burglar();// subroutine to check sensor status and activation of outputs
Check_Reset(); // subroutine to check if alarm reset switch pressed or not
}
I'm not sure what you are trying to do here:
void Check_Burglar()
int {{
sensor_value = digitalRead(sensor); // Reading sensor value from pin 8
if (sensor_value == HIGH) // Checking if PIR sensor sends a HIGH signal to Arduino
{ digitalWrite(buzzer, HIGH); // Activating the buzzer
while (sms_count < 3) //Number of SMS Alerts to be sent limited at 3
{ SendTextMessage(); // Function to send AT Commands to GSM module
}
sensor_value = HIGH;
lcd.setCursor(0, 1);
lcd.print("Intruder Alert! SMS sent");
}
}}
Read the how get the most out of this forum sticky to see how to properly post code. Remove useless white space and format the code with the IDE autoformat tool (crtl-t or Tools, Auto Format) before posting code. Autoformat makes the code easier for us (and you) to follow.