Hello all,
I faced some problems in this code,there errors and I don't know where,can someone help me please?
Thank you in advance.
This is the code:
#include<SoftwareSerial.h>
SoftwareSerial SIM900(7, 8);
const int error1 = 2; // Input D2 named error1
const int error2 = 3;
const int error3 = 4;
const int error4 = 5;
const int error5 = 6;
const int error6 = 10;
const int error7 = 11;
const int error8 = 12;
const int error9 = 13;
int SMS_error1 = 0; // Variable for reading error1
int SMS_error2 = 0;
int SMS_error3 = 0;
int SMS_error4 = 0;
int SMS_error5 = 0;
int SMS_error6 = 0;
int SMS_error7 = 0;
int SMS_error8 = 0;
int SMS_error9 = 0;
void setup()
{
pinMode(error1, INPUT); // Initialize error1 pin as an input
pinMode(error2, INPUT);
pinMode(error3, INPUT);
pinMode(error4, INPUT);
pinMode(error5, INPUT);
pinMode(error6, INPUT); // Initialize error1 pin as an input
pinMode(error7, INPUT);
pinMode(error8, INPUT);
pinMode(error9, INPUT);
// activate GSM Sheild
SIM900.begin(19200); // Start the exchange between GSM Sheild and arduino Uno by speed of 19200 baud
SIM900power(); // Wake up the GSM Sheild
delay(20000); // Give time to log on to network
}
void SIM900power(){
// Software equivalent of pressing the GSM shield "power" button
digitalWrite(9 ,HIGH);
delay(1000);
digitalWrite(9 ,LOW);
delay(5000);
}
void loop()
{
SMS_error1 = digitalRead(error1); // Reading of the input error1 and put it in SMS_error1
SMS_error2 = digitalRead(error2);
SMS_error3 = digitalRead(error3);
SMS_error4 = digitalRead(error4);
SMS_error5 = digitalRead(error5);
SMS_error6 = digitalRead(error6);
SMS_error7 = digitalRead(error7);
SMS_error8 = digitalRead(error8);
SMS_error9 = digitalRead(error9);
if(SMS_error1 == HIGH)
{
SendSMS_error1();
do{} while{};
}
if(SMS_error2 == HIGH)
{
SendSMS_error2();
do{} while{1};
}
if(SMS_error3 == HIGH)
{
SendSMS_error3();
do{} while{1};
}
if(SMS_error4 == HIGH)
{
SendSMS_error4();
do{} while{1};
}
if(SMS_error5 == HIGH)
{
SendSMS_error5();
do{} while{1};
}
if(SMS_error6 == HIGH)
{
SendSMS_error6();
do{} while{1};
}
if(SMS_error7 == HIGH)
{
SendSMS_error7();
do{} while{1};
}
if(SMS_error8 == HIGH)
{
SendSMS_error8();
do{} while{1};
}
if(SMS_error9 == HIGH)
{
SendSMS_error9();
do{} while{1};
}
}
void SendSMS_error1()
{
SIM900.print("AT+CMGF=1\r"); // AT command to send SMS message
delay(100);
SIM900.println("AT + CMGS = \"+2126xxxxxxxx\""); // recipient's mobile number
delay(100);
SIM900.println("Station 85: error 1"); // message to send
delay(100);
SIM900.println((char)26); // End AT command with a ^Z, ASCII code 26
delay(100);
SIM900.println();
delay(5000); // give module time to send SMS
SIM900power();
}
void SendSMS_error2()
{
SIM900.print("AT+CMGF=1\r");
delay(100);
SIM900.println("AT + CMGS = \"+2126xxxxxxxxx\"");
delay(100);
SIM900.println("Station 85: error 2");
delay(100);
SIM900.println((char)26);
delay(100);
SIM900.println();
delay(5000);
SIM900power();
}
void SendSMS_error3()
{
SIM900.print("AT+CMGF=1\r");
delay(100);
SIM900.println("AT + CMGS = \"+2126xxxxxxx\"");
delay(100);
SIM900.println("Station 85: error 3");
delay(100);
SIM900.println((char)26);
delay(100);
SIM900.println();
delay(5000);
SIM900power();
}
void SendSMS_error4()
{
SIM900.print("AT+CMGF=1\r");
delay(100);
SIM900.println("AT + CMGS = \"+2126xxxxxxxxx\"");
delay(100);
SIM900.println("Station 85: error 4");
delay(100);
SIM900.println((char)26);
delay(100);
SIM900.println();
delay(5000);
SIM900power();
}
void SendSMS_error5()
{
SIM900.print("AT+CMGF=1\r");
delay(100);
SIM900.println("AT + CMGS = \"+2126xxxxxxxx\"");
delay(100);
SIM900.println("Station 85: error 5");
delay(100);
SIM900.println((char)26);
delay(100);
SIM900.println();
delay(5000);
SIM900power();
}
void SendSMS_error6()
{
SIM900.print("AT+CMGF=1\r"); // AT command to send SMS message
delay(100);
SIM900.println("AT + CMGS = \"+2126xxxxxxxx\""); // recipient's mobile number
delay(100);
SIM900.println("Station 85: error 6"); // message to send
delay(100);
SIM900.println((char)26); // End AT command with a ^Z, ASCII code 26
delay(100);
SIM900.println();
delay(5000); // give module time to send SMS
SIM900power();
}
void SendSMS_error7()
{
SIM900.print("AT+CMGF=1\r"); // AT command to send SMS message
delay(100);
SIM900.println("AT + CMGS = \"+2126xxxxxxxx\""); // recipient's mobile number
delay(100);
SIM900.println("Station 85: error 7"); // message to send
delay(100);
SIM900.println((char)26); // End AT command with a ^Z, ASCII code 26
delay(100);
SIM900.println();
delay(5000); // give module time to send SMS
SIM900power();
}
void SendSMS_error8()
{
SIM900.print("AT+CMGF=1\r"); // AT command to send SMS message
delay(100);
SIM900.println("AT + CMGS = \"+2126xxxxxxx\""); // recipient's mobile number
delay(100);
SIM900.println("Station 85: error 8"); // message to send
delay(100);
SIM900.println((char)26); // End AT command with a ^Z, ASCII code 26
delay(100);
SIM900.println();
delay(5000); // give module time to send SMS
SIM900power();
}
void SendSMS_error9()
{
SIM900.print("AT+CMGF=1\r"); // AT command to send SMS message
delay(100);
SIM900.println("AT + CMGS = \"+2126xxxxxxxx\""); // recipient's mobile number,
delay(100);
SIM900.println("Station 85: error 9"); // message to send
delay(100);
SIM900.println((char)26); // End AT command with a ^Z, ASCII code 26
delay(100);
SIM900.println();
delay(5000); // give module time to send SMS
SIM900power();
}