Show Posts
Pages: [1]
1  Using Arduino / Project Guidance / Transmitting SMS from a GSM modem on: November 13, 2012, 08:41:49 am
Hi!

Ive got an project going on bout trying to send an text-message from my arduino to my mobile-phone using an GSM. The program im now using is this:
Code:
#include <SoftwareSerial.h>

SoftwareSerial cell(2, 3); // RX, TX
char mobilenumber[]="99497322";  // Replace xxxxxxxx with the recipient's mobile number
char textmessage[160]; // used to hold contents of message to send
int b=0;
void setup()
{  //Initialize serial ports for communication.
cell.begin(9600);
delay(35000); // give the GSM module time to initialise, locate network etc.
// this delay time varies. Use example 26.1 sketch to measure the amount
// of time from board reset to SIND: 4, then add five seconds just in case
pinMode(13, OUTPUT); // use the LED for status
randomSeed(analogRead(0));
}
void startSMS()
// function to send a text message
{
digitalWrite(13, HIGH);
cell.println("AT+CMGF=1"); // set SMS mode to text
cell.print("AT+CMGS=");
cell.print("AT+CSCA=+4790002100");
cell.write((byte)34); // ASCII equivalent of "
cell.print(mobilenumber);
cell.write((byte)34);  // ASCII equivalent of " HOME MADE.
delay(500); // give the module some thinking time
}
void endSMS()
{
cell.write((byte)26);  // ASCII equivalent of Ctrl-Z
delay(15000); // the SMS module needs time to return to OK status
digitalWrite(13, LOW);
}
void loop()
{
b=random(0, 99);
for (int a=0; a<100; a++)
{
if (a==b)
{
startSMS();
cell.print("The random number is: ");
cell.print(b);
endSMS();
}
}
do
{
delay(1);
} while (1>0);
}
And I got som problem with getting it working, hope that someone maybe would be able to help me smiley-wink


Moderator edit: CODE TAGS
Pages: [1]