// libraries
#include <GSM.h>
// PIN Number
//#define PINNUMBER ""
// initialize the library instance
GSM gsmAccess; // include a 'true' parameter for debug enabled
GSM_SMS sms;
char remoteNumber[20]; // Holds the emitting number
void setup()
{
// initialize serial communications
Serial.begin(9600);
Serial.println("SMS Messages Receiver");
// connection state
boolean notConnected = true;
// Start GSM shield
// If your SIM has PIN, pass it as a parameter of begin() in quotes
while(notConnected)
{
if(gsmAccess.begin()==GSM_READY)
notConnected = false;
else
{
Serial.println("Not connected");
delay(1000);
}
}
Serial.println("GSM initialized");
Serial.println("Waiting for messages");
}
void loop()
{
char c;
// If there are any SMSs available()
if (sms.available())
{
Serial.println("Message received from:");
// Get remote number
sms.remoteNumber(remoteNumber, 20);
Serial.println(remoteNumber);
// This is just an example of message disposal
// Messages starting with # should be discarded
if(sms.peek()=='#')
{
Serial.println("Discarded SMS");
sms.flush();
}
// Read message bytes and print them
while(c=sms.read())
Serial.print(c);
Serial.println("\nEND OF MESSAGE");
// delete message from modem memory
sms.flush();
Serial.println("MESSAGE DELETED");
}
delay(1000);
}
錯誤:GSM_SMS不名稱類型.... ,所以我不明白什麼是真正的錯誤是...... PLZ給我一個正確的答案。 確切地說,我想閱讀使用arduino Gboard的短信,並通過手機開啓或關閉。如何從Arduino的Gboard讀短信
請你可以發佈你得到的確切的錯誤信息。 「GSM_SMS不是名稱類型」是毫無意義的。也許你的錯誤是「」GSM_SMS「沒有命名類型」,也許這個鏈接有類似的錯誤可能會給你一個提示:https://github.com/GROUNDLAB/GSM-ARDUINO/issues/2 – 2013-04-12 08:39:14