I haven’t posted for a while, but that doesn’t mean I haven’t been working on the ongoing Arduino + LCD project, which is moving along towards connecting external data to be displayed on the LCD screen.
The last bit of time I’ve put into the project has been focused on printing text to the LCD screen from a text file. It’s an easy enough process using a PHP serial class that I mentioned in the last post, combined with PHP’s basic file manipulation functions.
Getting started again, loading the test PHP script to print out a message from the serial port.
Plugging in the Arduino, waiting for it to respond to a message over its serial port.
Remembering that, for a reason I’ve yet to fully understand, I need the Arduino IDE open with the serial monitor window open to get serial communications happening between Arduino and PHP.
But to kill the PHP script hanging while trying to talk over the serial port, I have to unplug the Arduino.
You can see that in Arduino, the Serial port isn’t being found if PHP tries to use it first. I’m still having issues with the Arduino+LCD wanting to listen over the serial port without the Arduino IDE and Serial Monitor open. How is this usually automated in an installation? Or am I having some kind of specific difficulties??
Plugging Arduino back in.
All is clear on the LCD.
Sending a simple test over the Arduino serial monitor, it’s all working.
I ran the PHP file with a message in the script itself and it still worked — I’m always paranoid I’m going to forget some important part of this between the times that I’m working on it.
The print out from my PHP script in the browser.
Here’s the file from which I needed to copy the fopen command that I had worked on previously, again pulling from a tutorial somewhere online to get going.
Here’s the basics of the PHP code to open a file and read it line by line.
Here’s the test text file.
And then, integrating the file open functions from the other file into the larger PHP script.
It worked, well, one line anyways.
There were some issues with my code transfer.
A few changes, and it was working, appearing OK in the browser…
…but not so well on the LCD screen itself. Those strange characters were due to the newlines or carriage returns in the text file.
I tried some more basic troubleshooting text so I could better keep track of the lines.
Again, I wasn’t exactly sure how to correct the problem, but I knew it was connected to the newlines in the text file.
Some code changes to pull out the newline characters, now leaving spaces, but not maintaining the newlines, which is fine for this purpose.
And, the corresponding PHP output.
And on the LCD! It worked!!!!!
On another note, I was wondering if I needed to just use some kind of simple regex tool to pull out the title from a Twitter RSS feed. For the purposes of this project, I’m not really concerned about a whole lot of the information, and really, I’d just like to have the text from each tweet to be found in a text file. I could set up a database and all the rest, but it feels a bit like overkill. As well, since I’m generally feeling behind schedule, I don’t want to cloud this with certain details that are likely unnecessary.
Next steps are going to be parsing some RSS and displaying it on the LCD, and integrating a second Arduino and LCD through a wireless connection.
I would like to thank the Canada Council for the Arts for their generous support.