Getting caller id with GPRS module and Arduino

Hi,
I have got the GPRS shield working great but what I want is to get the caller id when a button is pushed during a call then hang up below is the code I have so far

[code]
boolean stateChange=false;//used to check if button state has changed since last trigger

int lastState;//used to hold last state

void setup()
{
Serial.begin(19200); //Default serial port setting for the GPRS modem is 19200bps 8-N-1

///////////////Turn GPRS on ////////////
pinMode(9, OUTPUT);
digitalWrite(9,LOW);
delay(1000);
digitalWrite(9,HIGH);
delay(2500);
digitalWrite(9,LOW);
delay(3500);
///////////////////////////////////////

Serial.write(“ATS0=3\r”);//answer after 3 rings
Serial.write("\r");
delay(1000); //Wait for a second while the modem sends an “OK”

/*Serial.write(“AT+CMGF=1\r”); //Because we want to send the SMS in text mode
delay(1000);

}

void loop()
{
char number;//used to store caller id when D6 button pressed

int val6= digitalRead(6);//read state of D6 pin

int currentState=val6;//load state of D6 into currentstate to test for change

//perform action below if the current state has change from the laststate
if(currentState != lastState){
//Check if D6 is high
if(val6==HIGH){
Serial.write(“AT+CLIP?\r”);//request caller id
number=Serial.read();//read caller id and store in number variable
Serial.print(number);//print caller id
delay(2000);//wait 2 seconds
Serial.write(“AT+HVOIC\r”);//hang up
}

lastState=currentState;//store current state in last state variable
delay(10000);//wait 10 secs before beginning test again
}

}[/code]

The hanging up works ok so the code is being run ok when the button is pressed I am just not sure how to get the caller id to print in serial monitor.

If anyone has any ideas i’d be very grateful

Thanks in advance

The serial port is a one byte of input and output.I think you need to create an array that storage number, then a serial port output.Hope this can help you.

Best regards,
Deray

you could read the return value from your GPRS module like this:

if (GSMSerial.available()) { while(GSMSerial.available()) { buffer[count++]=GSMSerial.read(); if(count == 64)break; } Serial.write(buffer,count); clearBufferArray(); count = 0; }