Coding for checking GSM.
#include <GSM_Shield.h>
# define LED 13
# define BUTTON 7
# define LED 13
# define BUTTON 7
//**************************************************************************
char number[]="+60166638494"; //Destination number
char text[]="testing the GSM sent by GSM Arduino"; //SMS to send
byte type_sms=SMS_UNREAD; //Type of SMS
byte del_sms=0; //0: No deleting sms - 1: Deleting SMS
//**************************************************************************
GSM gsm;
char sms_rx[122]; //Received text SMS
//int inByte=0; //Number of byte received on serial port
char number_incoming[20];
int call;
int error;
int val = 0;
void setup()
{
Serial.begin(9600);
Serial.println("system startup");
gsm.TurnOn(9600); //module power on
gsm.InitParam(PARAM_SET_1);//configure the module
gsm.Echo(0); //enable AT echo
pinMode (LED, OUTPUT);
pinMode(BUTTON, INPUT);
}
void loop()
{
char inSerial[5];
int i=0;
delay(2000);
val = digitalRead(BUTTON);
if (val == HIGH)
if (val == HIGH)
{
digitalWrite(LED, HIGH);
{
Serial.print("Send SMS to ");
Serial.println(number);
error=gsm.SendSMS(number,text);
}
}
else
{
digitalWrite(LED, LOW);
}
if (Serial.available() > 0)
{
while (Serial.available() > 0)
{
inSerial[i]=(Serial.read()); //read data
i++;
}
inSerial[i]='\0';
Check_Protocol(inSerial);
}
}
void Check_Protocol(String inStr)
{
Serial.print("Command: ");
Serial.println(inStr);
Serial.println("Check_Protocol");
// switch (inStr[0])
delay(1500);
return;
}
No comments:
Post a Comment