In: Electrical Engineering
I have a sim 808 (fona 808) breakout connected to an adruino uno. write a code that makes it pick up automatically when called from certain numbers.
#include <sim900.h>/downld lbry from https://github.com/Seeed-Studio/GPRS_SIM900
#include <SoftwareSerial.h>/defalt lbry
#include <Wire.h>/deflt libry
int Incomingh;
String data,Fdata;
/Conct Tx stick of GSM to 9 of Arno
/Cnct Rx stick of GSM to 10 of Arduo
SoftwareSerial gprs(9,10);//tx,rx
void setup(){
Serial.begin(9600);
sim900_init(&gprs, 9600);/GSM modle wrks on 9600 baudrte
pinMode(8, OUTPUT);/stick to trn on Voice
Serial.println("Arduino - Automatic Voice Machine");
}
/*Function to peruse Incoming information from GSM to Arduino*/
void check_Incoming()
{
if(gprs.available())/If GSM is stating something
{
Incomingch = gprs.read();/Listen to it and store in this factor
in the event that (Incomingch == 10 || Incomingch ==13)/If it says space (10) or Newline (13) it implies it has finished single word
{Serial.println(data); Fdata =data; information = ""; }/Print the word and clear the variable to begin new
else
{
String newchar = String (char(Incomingch));/change over the roast to string by utilizing string objects
information = information +newchar;/After changing over to string, do string connection
}
}
}
/*##End of Function##*/
void loop(){
check_Incoming();/Read what GSM module is stating
if(Serial.available()){/Used for troubleshooting
gprs.write(Serial.read());/Used for troubleshooting
}/Used for troubleshooting
in the event that (Fdata == "RING")/If the GSM module says RING
{
delay(5000);/sit tight for 5sec to make 3 ring delay.
gprs.write ("ATA\r\n");/Answer the call
Serial.println ("Placed Received");/Used for investigating
while(Fdata != "alright")/Until call effectively replied
{check_Incoming();/Read what GSM module is stating
Serial.println ("Playing Recorded message");/Used for investigating
/Play the recorded voice message
delay(500);
digitalWrite(8, HIGH);/Go high
delay(200);/sit tight for 200 msec
digitalWrite(8, LOW);/Go low
}
}
}