Hardware Reference
In-Depth Information
Your sketch should look like Listing 17-1
Listing 17-1: Sketch (fi lename: chapter17.ino )
1 #include <GSM.h>
2
3 #define PINNUMBER "0000" // Replace with your SIM card PIN
4 #define CONTACT "01234567" // Replace with your mobile telephone
number
5 #define GPRS_APN "GPRS_APN" // Replace your GPRS APN
6 #define GPRS_LOGIN "login" // Replace with your APN login
7 #define GPRS_PASSWORD "password" // Replace with your APN password
8 #define SERVER "yourhomesecurity"
9 #define PORT 8080
10
11 // initialize the library instance
12 GSM gsmAccess;
13 GSM_SMS sms;
14 GSMClient client;
15 GPRS gprs;
16
17 // Variables
18 bool intrusion = false;
19
20 void setup()
21 {
22 // initialize serial communications and wait for port to open:
23 Serial.begin(9600);
24
25 // connection state
26 boolean notConnected = true;
27
28 // Start GSM shield
29 // If your SIM has PIN, pass it as a parameter of begin() in
quotes
30 while(notConnected)
31 {
32 if((gsmAccess.begin(PINNUMBER)==GSM_READY) &
33 (gprs.attachGPRS(GPRS_APN, GPRS_LOGIN, GPRS_PASSWORD)
34 ==GPRS_READY))
35 notConnected = false;
36 else
37 {
38 Serial.println("Not connected");
39 delay(1000);
40 }
41 }
42
43 pinMode(8, INPUT_PULLUP);
44 45 Serial.println("GSM initialized");
46 }
Search WWH ::




Custom Search