美好的一天,我正在做一个项目,其中我正在获取我将从c#发送消息的号码,当我手动输入它将发送的号码但是,如果它来自c#它不会。这是我的arduino代码。:
boolean stringComplete = false;
String inputString = "";
void loop()
{
if(stringComplete)
{
SIM900.print("AT+CMGF=1\r");
delay(100);
SIM900.println("AT + CMGS = \"" +inputString+ "\"");
delay(100);
SIM900.println("This message is from HD Robot. Medicine not enough.");
delay(100);
SIM900.println((char)26);
delay(100);
SIM900.println();
delay(5000);
inputString = "";
stringComplete = false;
}
}
void serialEvent() {
while (Serial.available()) {
char inChar = (char)Serial.read();
inputString += inChar;
if (inChar == '\n') {
stringComplete = true;
}
}
}
这是我的c#代码:
DataTable contact = new DataTable();
contact = database.getContactInformation();
foreach (DataRow rows in contact.Rows)
{
fam = rows["CPNumber"].ToString();
added = "+63" + fam;
serial.Write(added);
}