#define CHARCMD 128 #define ENTER 13 #include SoftwareSerial GSM(3, 2); void send_AT_cmd(const char *at_cmd); void setup() { GSM.begin(19200); Serial.begin(19200); delay(500); Serial.println("ATM Command tester for Arduino & SIM900 Modules"); Serial.println(""); Serial.print(">"); } void loop() { char inStr[CHARCMD] = ""; int ByteCMD = 0; int strCount = 0; while(1) { if(Serial.available()) { ByteCMD = Serial.read(); Serial.print(char(ByteCMD)); if(ByteCMD != ENTER) { inStr[strCount] = char(ByteCMD); strCount++; } } if(ByteCMD == ENTER) { // Detection de la touche entree //inStr[strCount+1] = char(ENTER); Serial.println(""); send_AT_cmd(inStr); delay(100); strCount = 0; ByteCMD = 0; //Flush de la variable for(int i = 0; inStr[i] != '\0'; i++) { inStr[i] = '\0'; } Serial.print(">"); } } } void send_AT_cmd(const char *at_cmd) { GSM.println(at_cmd); delay(150); while(GSM.available()!=0) Serial.write(GSM.read()); }