I basically took two codes from the internet one for an earthquake detector and a second to attach that with a GSM.
I compiled both codes, did some basic things but I am getting this error while I run it. and in the end, it says "error: exit status 1". Please help me with this, this is for my school project.
The code is :
#define buzzer 12
#define x A0
#define y A1
#define z A2
int xsample=0;
int ysample=0;
int zsample=0;
long start;
int b=0;
#define samples 50
#define maxVal 20
#define minVal -20
#define buzTime 2000
void setup()
{
Serial.begin(9600);
delay(1000);
pinMode(buzzer, OUTPUT);
b=0;
digitalWrite(buzzer, b);
for(int i=0;i<samples;i++)
{
xsample+=analogRead(x);
ysample+=analogRead(y);
zsample+=analogRead(z);
}
xsample/=samples;
ysample/=samples;
zsample/=samples;
#include<SoftwareSerial.h>
SoftwareSerial gsm(2,3);
delay(10000);
Serial.begin(9600);
gsm.begin(9600);
gsm.println("AT+CMGF=1");
delay(1000);
gsm.println("AT+CMGS="+91xxxxxxxxxx"\r"); //replace x by your number
delay(1000);
gsm.println("hello");
delay(100);
gsm.println((char)26);
delay(1000);
}
void loop()
{
int value1=analogRead(x);
int value2=analogRead(y);
int value3=analogRead(z);
int xValue=xsample-value1;
int yValue=ysample-value2;
int zValue=zsample-value3;
if(xValue < minVal || xValue > maxVal || yValue < minVal || yValue > maxVal || zValue < minVal || zValue > maxVal)
{
if(b == 0)
start=millis();
b=1;
}
else if(b == 1)
{
if(millis()>= start+buzTime)
b=0;
}
digitalWrite(buzzer, b);
Serial.print("x=");
Serial.println(xValue);
Serial.print("y=");
Serial.println(yValue);
Serial.print("z=");
Serial.println(zValue);
Serial.println(" $");
}