Hello, I start in arduino and I made a code that can send sms / phone calls. My code is not perfect and I'm asking you for some help to improve it:
I do not know how to get a SMS / phone call by cons. I would like to display the SMS I get in the void function Get_SMS (), but I found 2-3 things on the net but I did not understand how to do it. if anyone could teach me.
#include <SoftwareSerial.h>
SoftwareSerial SIM900(7, 8);
char message=0;
void setup()
{
SIM900.begin(19200);
delay(25000);
Serial.begin(19200);
Serial.println("OK");
digitalWrite(9, HIGH);
delay(1000);
}
void Send_Call()
{
SIM900.println("ATD 0608446677;");
delay(100);
SIM900.println();
//delay(120000);
while(Serial.read() != '1') {
delay(100);
}
SIM900.println("ATH");
delay(1000);
}
void Send_SMS()
{
SIM900.print("AT+CMGF=1\r");
delay(100);
SIM900.println("AT+CMGS=\"0608446677\"");
delay(100);
SIM900.println("test sms");
delay(100);
SIM900.println((char)26);
delay(100);
SIM900.println();
delay(5000);
Serial.println("SMS sent successfully");
}
void Get_SMS()
{
message=SIM900.read();
Serial.print(message);
}
void Get_Call()
{
}
void loop() {
if(Serial.read() == 'p') {
Send_Call();
}
if(Serial.read() == 's') {
Send_SMS();
}
Get_SMS();
Get_Call();
}