Hi ArduPeople
I am trying to compare the incoming call number with a predefined number,
I get it, but now I want to add more predefined numbers is this possible?
The Idea is that the Arduino do something only with authorized numbers
I Try this and work, but use to much lines
#include <SoftwareSerial.h>
char inchar; // Will hold the incoming character from the GSM shield
SoftwareSerial SIM900(7, 8);
void setup()
{
Serial.begin(19200);
// set up the digital pins to control
pinMode(13, OUTPUT); // se define el Pin13 como una salida
digitalWrite(13, LOW); // se define el Pin13 en estado bajo
// wake up the GSM shield
SIM900power();
SIM900.begin(19200);
delay(2000); // give time to log on to network.
SIM900.print("AT+CLIP=1\r"); // turn on caller ID notification
delay(100);
}
void SIM900power()
// software equivalent of pressing the GSM shield "power" button
{
digitalWrite(9, HIGH); // Pin9 se usara para encender modulo gsm via transistor
delay(1000);
digitalWrite(9, LOW);
delay(8000);
}
void doSomething()
{
digitalWrite(13, HIGH);
delay(1000);
digitalWrite(13, LOW);
Serial.println("Activando");
delay(1000);
SIM900.print("ATH\r");
}
void loop()
{
if(SIM900.available() >0)
{
delay(10);
inchar=SIM900.read();
if (inchar=='5')
{
delay(10);
inchar=SIM900.read();
if (inchar=='6')
{
delay(10);
inchar=SIM900.read();
if (inchar=='9')
{
delay(10);
inchar=SIM900.read();
if (inchar=='5')
{
delay(10);
inchar=SIM900.read();
if (inchar=='1')
{
delay(10);
inchar=SIM900.read();
if (inchar=='0')
{
delay(10);
inchar=SIM900.read();
if (inchar=='5')
{
delay(10);
inchar=SIM900.read();
if (inchar=='2')
{
delay(10);
inchar=SIM900.read();
if (inchar=='1')
{
delay(10);
inchar=SIM900.read();
if (inchar=='9')
{
delay(10);
inchar=SIM900.read();
if (inchar=='2')
{
Serial.println("Numero Autorizado");
delay(100);
doSomething(); // now the number is matched, do something
delay(1000); // arbitrary delay so the function isn't called again on the same phone call
}
}
}
}
}
}
}
}
}
}
}
}
}
I try to create an array for the predefined number and then compare, with
inchar with strcmp or strncmp, but the Ide say "error conversion "char" to "const char"
I want to do this for authorice predefined numbers and generate a log, if is possible I
want to add Date/Time in the log.
I am a new in Arduino and C.
Please help me!