Arduino + LCD + PHP, Part 2

The epic adventure with Arduino, LCDs, and PHP continues. I’ve finally made some progress in terms of breaking up the words and lines appropriately. It felt like a huge achievement, since I had been trying to figure out this line-break thing for quite a while.

You can check the majority of the progress in the video below, and all of the steps along the way are below! Don’t mind the nonsensical example texts. So first off, I figured out I needed to send Arduino very specific information to know where to line break.

I used PHP wordwrap to break words appropriately, then sent Arduino a * to identify a line break.

Doing it this way also helped to make it more obvious where words needed to be wrapped, including when there was punctuation.

I used a SwitchCase to do some tests — I did this at first just to test to make sure the Serial port was receiving the appropriate information and to ensure that Arduino could act on receiving letters.

Then, I changed the code to be a bit to actually do what I needed it to do — in this case, set the cursor to the next line.

There was some trial and error along the way, the text wasn’t moving to the appropriate lines.

You can see, I was really just piecing this together from other code examples … but it turned out to help a lot and set the groundwork for this to work how I wanted.

Finally, the text being wrapped like it needed to!!!

A close up of the glory.

This code worked to print out each character.

Another random text, just to make sure this was working and not just a fluke.

I added some more switch cases to start identifying a page break, that is, spanning the text over two screens.

You can see here some of the testing I was doing in PHP.

And some more of the testing, having output into a browser so I could make sure that it was doing what I wanted it to.

And here’s the result — a 140 character message automatically spans across two screens and knows where to break words to span accordingly. Since then, I was speaking with Mike Beauchamp (ex-Windsorite / DIY tech genius) and he provided some interesting ideas in terms of how to work the communication portion of this project. Could be very useful, so I included a couple of those links below.

Next steps that I’ve already begun include working towards using PHP to parse a text file (I figure that’s one possibility to hold the text messages and Twitter tweets), or alternatively using an RSS feed to deliver both to the LCD (that is, assuming the email part of the text message configuration I’m currently considering could do that).

Annotated Bibliography

http://www.sparkfun.com/commerce/categories.php?c=66 (ideas from Mike Beauchamp)

http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1227581530/0 (ideas from Mike Beauchamp)

http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1264895784/9 (serial communication with PHP)

http://www.tizag.com/phpT/php-string-strpos.php (string position tutorial)

http://www.arduino.cc/en/Tutorial/TextString (potential to use Arduino rather than PHP for string manipulation)

http://www.tizag.com/phpT/fileread.php (open a text file and read data from it)

http://veritrope.com/tips/export-apple-mail-messages-and-notes-to-text-files/2 (export mail messages to text file)

http://www.tech-recipes.com/rx/878/check-google-e-mail-gmail-from-an-rss-feed/ (check gmail as rss feed)

http://googlesystem.blogspot.com/2008/03/feed-for-unread-gmail-messages.html (more info on gmail rss feeds, needs feed authentication)

http://davidwalsh.name/gmail-php-imap (php + imap + gmail output)

http://g33k.wordpress.com/2009/02/04/check-gmail-the-python-way/ (gmail + python)

http://www.hashbangcode.com/blog/disemvoweling-php-function-1077.html (disemvoewling PHP)

I would like to thank the Canada Council for the Arts for their generous support.

2 Replies to “Arduino + LCD + PHP, Part 2”

  1. I used a SwitchCase to do some tests — I did this at first just to test to make sure the Serial port was receiving the appropriate information and to ensure that Arduino could act on receiving letters.

Comments are closed.