Mobile Phone number from SD Card

Hi all, I'm trying to read a mobile phone number from as SD Card, then use that phone number as a variable but I'm really struggling to get it into a variable.

The number is stored in a file called phone.txt which I can read and that's all working.

I've been using this:

while(myFile.available())
{
Serial.write(myFile.read());
}
myFile.close();

and then something like phonenumber = myFile.read();

but it's not working!!

I've been searching for a couple of days and my searches are telling me that I need to read each number of the phone number into an array and then use that.

Please help me as it's driving me up the wall :slight_smile:

Many thanks in advance.

Cowpi3:
Hi all, I'm trying to read a mobile phone number from as SD Card, then use that phone number as a variable but I'm really struggling to get it into a variable.

The number is stored in a file called phone.txt which I can read and that's all working.

I've been using this:

and then something like phonenumber = myFile.read();

but it's not working!!

I've been searching for a couple of days and my searches are telling me that I need to read each number of the phone number into an array and then use that.

Please help me as it's driving me up the wall :slight_smile:

Many thanks in advance.

I bet if used "Serial.print(phonenumber)" After reading the phone number, you would have quickly debugged you program.

Paul

There was an almost identical problem recently in this Thread in which I suggested a solution.

...R

Robin2:
There was an almost identical problem recently in this Thread in which I suggested a solution.

...R

Hi Robin,

Your example in that thread is exactly what I was looking for, however your example is the easiest that someone has put it - so thank you very much. I'll give it a trial asap and let you know how I get on.

Apologies for posting another thread, I didn't see yours!