Hi all
iv got my GSM Shield up and running , im getting text comming in sooo that is all fine but
i would like to send a message with the word "on" in it and it would then turn on a led or relay
here is my code , i hope that some one could help me
#include "SIM900.h"
#include <SoftwareSerial.h>
#include <LiquidCrystal.h>
//If not used, is better to exclude the HTTP library,
//for RAM saving.
//If your sketch reboots itself proprably you have finished,
//your memory available.
//#include "inetGSM.h"
//If you want to use the Arduino functions to manage SMS, uncomment the lines below.
#include "sms.h"
SMSGSM sms;
LiquidCrystal lcd(8, 9, 4, 5, 6, 7);
int backLight = 13; // pin 13 will control the backlight
int ledpin = 11;
char msg[160];
int numdata;
boolean started=false;
char smsbuffer[160];
char n[12];
int lcd_key = 0;
int adc_key_in = 0;
char nr = 4040xxxx;
void setup()
{
//LCD Setup
pinMode(backLight, OUTPUT);
digitalWrite(backLight, HIGH); // turn backlight on. Replace 'HIGH' with 'LOW' to turn it off.
lcd.begin(16,2); // columns, rows. use 16,2 for a 16x2 LCD, etc.
lcd.print("Starting up"); // start with a "blank screen"
// Tricker setup
pinMode(ledpin, OUTPUT);
//Serial connection.
Serial.begin(9600);
Serial.println("GSM Shield testing.");
//Start configuration of shield with baudrate.
//For http uses is raccomanded to use 4800 or slower.
if (gsm.begin(2400)) {
lcd.setCursor(0,0); // set cursor to column 0, row 0 (the first row)
lcd.print("\nstatus=READY");
Serial.println("\nstatus=READY");
started=true;
} else Serial.println("\nstatus=IDLE");
lcd.setCursor(0,0); // set cursor to column 0, row 0 (the first row)
lcd.print("\nstatus=READY");
if(started) {
//Enable this two lines if you want to send an SMS.
//if (sms.SendSMS("4040xxxx", "Arduino SMS"))
Serial.println("Ready To Send");
lcd.setCursor(0,0); // set cursor to column 0, row 0 (the first row)
lcd.print("Ready to send");
}
}
void loop()
{
//lcd.setCursor(9,1); // place cursor
//lcd.print(millis()/1000); // display seconds
lcd.setCursor(0,1); // move cursor
lcd_key = analogRead(0); // read the buttons
if (lcd_key<50){
if(started) {
//Enable this two lines if you want to send an SMS.
if (sms.SendSMS("4040xxxx", "Button Right"))
Serial.println("\nSMS sent OK");
lcd.setCursor(0,0); // set cursor to column 0, row 1 (the first row)
lcd.print("Ready to send");
lcd.setCursor(0,1); // set cursor to column 0, row 1 (the first row)
lcd.print("SMS sent OK");
}
}
else if (lcd_key<250){
if(started) {
//Enable this two lines if you want to send an SMS.
if (sms.SendSMS("4040xxxx", "Button UP"))
Serial.println("\nSMS sent OK");
lcd.setCursor(0,0); // set cursor to column 0, row 0 (the first row)
lcd.print("Ready to send");
lcd.setCursor(0,1); // set cursor to column 0, row 1 (the first row)
lcd.print("SMS sent OK");
}
}
else if (lcd_key<450)
{
lcd.setCursor(0,0); // set cursor to column 0, row 1 (the first row)
lcd.print("Ready to send");
lcd.setCursor(0,1); // set cursor to column 0, row 1 (the first row)
lcd.print(" ");
}
else if (lcd_key>550)
{
if(started) {
//Read if there are messages on SIM card and print them.
if(gsm.readSMS(smsbuffer,160,n,12)) {
Serial.println(n);
Serial.println(smsbuffer);
lcd.setCursor(0,0); // set cursor to column 0, row 1 (the first row)
lcd.print(" ");
lcd.setCursor(0,0); // set cursor to column 0, row 1 (the first row)
lcd.print(n);
lcd.setCursor(0,1); // set cursor to column 0, row 1 (the first row)
lcd.print(smsbuffer);
}
if(gsm.readSMS(smsbuffer,160,n,12) == 'On, +454040xxxx')
{
Serial.println("led on");
analogWrite(ledpin, 255);
}
}
delay(1000);
}
}