我将Siemens ME45连接到Arduino Leonardo,如下所示:
手机对来自Arduino的AT命令作出反应,它会拨打电话,发送短信,但它不会对串口监视器提供任何反馈。例如,它应该返回" 0"或" 1"当被命令" AT + CMGF =?"询问时。什么都没发生。可能是什么原因?
#include <SoftwareSerial.h>
#define rxPin 0
#define txPin 1
SoftwareSerial mySerial(rxPin,txPin); // RX, TX
void setup(){
pinMode(rxPin, INPUT);
pinMode(txPin, OUTPUT);
Serial.begin(9600);
Serial.println("Arduino serial initialized!");
delay(1000);
mySerial.begin(9600);
Serial.println("Software serial initialized!");
delay(1000);
}
void loop(){
issueCommand("AT+CMGF=?");
readSerial();
delay(200);
while(true){
readSerial();
}
}
void issueCommand(char* msg){
mySerial.println(msg);
Serial.print(msg);
delay(10);
}
void readSerial(){
while (mySerial.available()){
Serial.println(mySerial.read());
delay(10);
}
}