从c#发送短信gsm arduino联系人

时间:2016-07-20 06:06:29

标签: c# arduino gsm

美好的一天,我正在做一个项目,其中我正在获取我将从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);

    }

0 个答案:

没有答案