Hi I am using a GSM shield with my arduino which works by serial AT commands.
What I am having problems with is including a variable in a serial command to send the phonebook position (Sch) to store a number. the Sch is incremented each time a new number is found so I cannot pass it a constant
.the problem line is at the end of the code.
I know I could do this with serial.printf is there something simalar for serial.write?
char number[20];
int Sch=10;//to store amount of numbers in phonebook
void setup()
{
........
};
void loop(){
..........
}
void storeNumbersOnSim(){
//Chekcs status of call
stat=gsm.CallStatusWithAuth(number,10,Sch);
//if number isnt on sim
if(stat != CALL_INCOM_VOICE_AUTH){
Sch=Sch++;//increase phonebook position
Serial.write("AT+CPBW=,%i,\r",Sch);
}
}
Thanks very much and sorry if I havent explained this clearly just let me know and I will try and explain a bit clearer.
Make sure the temp variable is big enough to store the entire formatted string plus the terminating null character. 20 is a guess that should work unless your number are more than 8 characters.
majenko:
Is your line ending correct? \r is character 13. Another common line ending is \n (character 10), or both together - \r\n.
I think so it works ok for all other commands like getting the gsm shield to send sms so it should be the same for this command.
I will try it with \n to see what happens though thanks again for your help.