GSM constructor
描述
GSM 類別是 GSM 函式庫的基礎,在使用任何 GSM 函式庫的功能前,都要用 GSM 類別初始化 Arduino GSM shield。
語法
GSM GSMAccess
GSM GSMAccess(debug)
參數
debug:debug 是 boolean 型態的參數,如果給予 true 將會把傳送給 Arduino GSM shield 的 AT 指令輸出至序列埠監控視窗,反之不會輸出 AT 指令。如果沒給參數,預設為 false。
範例
// 函式庫
#include <GSM.h>
// PIN 碼
#define PINNUMBER ""
// 初始化 GSM 函式庫
GSM gsmAccess;
void setup()
{
// 初始化 Serial
Serial.begin(9600);
// 連線狀態
boolean notConnected = true;
// 啟動 Arduino GSM shield,如果你的 SIM 卡有 PIN 碼,請當作 begin() 的參數
while(notConnected)
{
if(gsmAccess.begin(PINNUMBER)==GSM_READY)
{
notConnected = false;
Serial.println("Connected to network");
}
else
{
Serial.println("Not connected");
delay(1000);
}
}
}
void loop()
{
// 不做任何事
}
See also
- begin()
- shutdown()
The text of the 86Duino reference is a modification of the Arduino reference, and is licensed under a Creative Commons Attribution-ShareAlike 3.0 License. Code samples in the reference are released into the public domain.
