Reading a txt file for LED matrix - Noob!

Hi,

Just want to say great forum.

I hope someone will be able to help me with what i imagine is quite a simple thing.

I have a 8x8 LED matrix that i have set up and works well:

http://oomlout.com/8X8M/8X8M-Guide.pdf

Code:

http://oomlout.com/8X8M/8X8M-ScrollMessage.txt

I now want to change the message dynamically by reading a txt file so I can use PHP to write a txt file that Arduino reads.

I already have set up a local webserver and writing the txt file so its just the reading of that txt via serial. Its on a Mac if that helps.

Thanks for any help

Best

Jim

Is PHP going to be reading and writing from the serial port and the text file?

It's capable of reading the text file, and writing data to the serial port.

The Arduino is capable of reading from and writing to the serial port.

There are issues with PHP being able to read from the serial port on Windows. It can on Linux. I don't know about on Macs.

However, unless you are using a web interface that uses PHP to create the text file, there are easier ways to get the text data from the file to the Arduino.

http://Processing.org comes to mind. It can read text files, and communicates well with the Arduino over the serial port. The Processing application comes with several examples that would get you 90% of the way.

Thanks for the quick response.

I chose PHP as my plan is to have a webcam on my LED matrix. People can then visit my site, type in a message on the webpage and then see this message displayed on the LED matrix.

If there is a better way of doing it i would be very happy to hear.

I will eventually have it running via a Linux webserver here in my office

Make eventually now. Connect the Arduino to the Linux web server, and have PHP write directly to the serial port, skipping the text file altogether.

If you want to prove that you can send text to the Arduino, via the serial port, Processing is a good way to learn all about how that process works.

Thanks - i will take your advice and set up the Linux box.

Currently I have this:

char requestString[] = " HELLO WORLD ";

Can you give me a pointer how this should look if its taking the text direct from Serial port?

In the sketch, you need to create an array that is the size of the maximum number of characters you intend to send to the Arduino:

char serialIn[24]; // as an example;

Then, you need an index that defines where to store a character:

int serialIndex;

Then, in loop, you read the data:

void loop()
{
   if(Serial.available() > 0) // Is there anything to read?
   {
       serialIndex = 0;
       while(Serial.available() > 0)
       {
           char aChar = Serial.read();
           serialIn[serialIndex] = aChar; // Store the character read
           serialIndex++; // Point to the next position
           serialIn[serialIndex] = '\0'; // NULL terminate the string
       }

       // Now do something with the string...
   }
}

Thanks very much PaulS - i will let you know how it goes.