More Arduino + LCD + PHP fun
My work on this ongoing LCD Arduino project has been continuing over the last couple of weeks, I just haven’t had the time to update appropriately.
So, I switched over my plan of attack from Processing to PHP. I figured this made sense for a couple reasons: first, I’m already very well-acquainted with PHP, I’ve written and hacked together a good amount of code in this language before and so I feel like I’ll spend a lot less time just figuring this out and more time actually doing; second, I don’t think I was really going to use Processing for its strengths, and instead, I was going to rely on its string functions, which pale in comparison to PHP.
I’ve made quite a lot of progress over the last week or so — all of which is detailed below. There are still some major problems I need to sort out, but for the most part things are about where I’d hoped them to be at this point.
First off, I had to spend some time getting the server up and PHP and running on my MacBook Pro again. I had set this up a while back, probably before I upgraded to Leopard (and having since upgraded to Snow Leopard), some things needed some manual attention. I wish I had saved the links, but the gist of it was that I needed to change the user.conf file.
I also started working with the PHP Serial class, which is awesome, there are a few versions out there, but the one I’m using came from Rizwan Kassim who made changes to the oft-circulated Rémy Sanchez version.
So, I tweaked the example script to spit out the text that would appear on my LCD screen in my browser window.
Here’s the script.
And the result.
Then I moved onto a looped script.
This worked fairly well.
The script … wrapping the $serial -> sendMessage($i) in a while statement.
My diagram for what exactly I want this to do…
The counting numbers script was a bit wonky for reasons I’m not entirely clear about. Basically it would count up to a certain number, but then clear the screen and print the rest of the numbers. That is, if I wanted it to write up to 11, it would split the number sequence somewhere near 6 or 7, and then show the rest on a freshly cleared screen. I’m not sure why this was happening, but I wondered if the script was just moving too slowly (or too quickly) for the Arduino to catch it all at once.
Then I spent a long time trying to figure out how to break up the text correctly. The thing is, I had hoped for this project to be able to take a text string and display it all at once on the LCD screen. However, the LCD screen and Arduino don’t know how to automatically display this as I might wish. There are some inherent difficulties in this — while PHP can find me letters or entire words and break them up accordingly, I’m not sure how to signal Arduino to tell the LCD to start a new line. You can see above, I had momentarily programmed the PHP script to display correctly in the browser, but it made me think that if I could just find the right catch character, I could get this to work as I imagined.
The other thing that you’ll notice is that the Arduino sketch as I had written it at the moment, wasn’t right in its placement of characters on the LCD.
As I understand it, these LCDs are meant to write to the 1st line, then the 3rd, then the 2nd, then the 4th.
In this case, I had the Arduino sketch printing out one letter at a time — and I realized I actually liked this effect (simple I know), but I think it helps to communicate some level of this thing actually receiving new data.
One of the many Arduino sketches I was trying to piece together from other tutorials, etc. At some point I think I was trying to use command characters that I saw on Serial LCD tutorials — my LCD is parallel, so I have to imagine this is a big reason why it wasn’t working.
So, back to the drawing board…
This time, I got it to work…
See the comma — it went to the 2nd line, like it was supposed to!
The string carried on, though it’s awkward with not being able to determine in PHP where the string should break for a new line and have that information sent on to Arduino.
Here’s a screenshot of the Arduino code I’d settled on. Those letter variables are a counter for each line, allowing me to have Arduino automatically wrap the entire string when it’s reached the end of each line properly so that the string continues onto the next line, rather than the 1-3, 2-4 thing I described above.
So the string continues.
And here’s the string completed. Really awkward line breaks in the string, as Arduino will print until its reached 20 characters on each line. You can see why I need to figure out how to translated information from something like wordwrap() in PHP to Arduino.
And again, here’s the code that finally made this work, all those counters…
The other part of this project that I started to work towards is the process through which I will receive text messages and put them into the system. Sending text messages from computers is easy, but receiving text messages in an email or something like that is much more difficult. However, I found
Problems that remain at the moment:
I’m still not sure why I need the Arduino Serial Monitor open for this to work. Unless it’s open, the PHP script won’t work and because it doesn’t work, it gets stuck with the Serial port open, it crashes the Arduino IDE and the LCD itself obviously has no output.
I still need to figure out how to signal a line break earlier than 20 characters when appropriate. I can get this information about a string and split it up in PHP, but I’m not sure how to pass that along to Arduino. I’m guessing using something like a case break type of loop would do it. iPiPi seems to provide the technology that I need, which is essentially a number that can receive text messages and automatically route them to an email. The service that I need is going to be fairly costly, given that I’d want a dedicated number or long code, but would be worth it to see this project work as I imagined it … that part of the project is a little while off anyways. But, I’m just happy that I found what I was looking for.
–
Annotated bibliography for the last couple of weeks:
http://dorkbotpdx.org/blog/kmat/serial_lcd (serial –> LCD … this is making more sense now, using case breaks to look for specific characters to insert a function, such as starting a new line)
http://blog.datasingularity.com/?p=50 (control arduino through html)
http://stackoverflow.com/questions/899098/arduino-serial-reading (arduino serial reading)
http://www.ipipi.com/ContactUs.do (potential sms forwarding to email option)
http://www.ipipi.com/help/ipipi_in_out.htm (this is what I would need to receive messages, not as simple as a number, but maybe the best way to avoid having to get another phone number, I should also ask about a potential shortcode)
http://docs.upsidewireless.com/index.php?title=MO_HTTP (notes on how to bring sms messages into an application using HTTP POST)
http://www.upsidewireless.com/how_virtual_sms_works.htm (this is the kind of service I’ll need for this project … SMS messages forwarded to email or accessible through HTTP requests … with the possibility of getting a Windsor-based number AKA longcode)
http://www.mydarkmaterials.co.uk/2008/11/interfacing-php-with-the-arduino/ (this is an example of interfacing PHP Serial with Arduino, and I suspect old enough that many of the problems the author ran into aren’t there any longer … maybe it’s been silly of me to ignore PHP … I actually have a decent idea of what I’m doing there)
http://www.procata.com/blog/archives/2007/10/28/working-with-php-5-in-mac-os-x-105/ (helpful to get PHP running properly on 10.6)
http://opensourceprojects-torchris.blogspot.com/2009/09/arduino-pop3-email-checker.html (maybe or maybe not useful in some capacity, using arduino to check email)
http://www.arduino.cc/playground/Learning/SparkFunSerLCD (serial commands)
http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?action=print;num=1192470251 (word wrapping in Arduino)
http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1252901403/4 (word wrapping more)
I would like to thank the Canada Council for the Arts for their generous support.


























![SRSI, Day 1: Cleaning up the Storefronts Day 1 of the Storefront Residencies for Social Innovation: we get the keys and begin massive clean up. Vinyl is being cut, walls will be painted, carpets are vacuumed, windows are washed, but still things to do. However, great things are ahead. Josh and Michelle at the very start of the day, before the cleaning [...]](http://d1ugx41kvdwavn.cloudfront.net/wp-content/uploads/2010/06/IMG_9785-150x150.jpg)
![City Counseling (Session #1) Last night, in front of city hall, we had a conversation about the ways we want to shape our city. In the midst of rising tensions around existing city services and new infrastructures, there seems to be a renewed wish for not just more public dialogue with the city, but a dialogue based on transparency [...]](http://d1ugx41kvdwavn.cloudfront.net/wp-content/uploads/2011/06/IMG_0088-150x150.jpg)
![Wrapping up Production for Hamilton: a quick look at some recent work As we wrap up production on our upcoming installation, Two Tales of a City, at Hamilton Artists Inc., our Friday night meeting was shifted to Lebel where we set out to coat the bunting with some scotch guard and just started laying everything out. Rosina braved the quick spray The rest of the crew helped [...]](http://d1ugx41kvdwavn.cloudfront.net/wp-content/uploads/2012/03/IMG_70601-150x150.jpg)
![How we use this site for research (in-part) Over the last week or so, we’ve added a few new things to our little website here. It’s funny because there’s a lot of research that goes on in the background, in terms of things we come across and don’t blog about, ideas that we email to one another, and documenting our process and posting [...]](http://d1ugx41kvdwavn.cloudfront.net/wp-content/uploads/2009/12/bcl-sidebar-dec09-150x150.jpg)
![Two Tales Of A City: Hamilton History Hunters Michelle and I headed up to Hamilton to continue the research portion of Two Tales Of A City. The three and a half hour car ride gave us plenty of time to develop a working plan of exactly what we wanted to accomplish for the next two days in Hamilton, Ontario. To get a [...]](http://d1ugx41kvdwavn.cloudfront.net/wp-content/uploads/2012/02/IMG_5855-150x150.jpg)

![Thinking About Borders We’ve noted before that we’re working on a proposal for CAFKA, as we’re interested in the border between Kitchener and Waterloo. Though certainly every place is bordered with another, it’s the kind of K-W relationship that intrigues us, as we’re wondering about the potential possibilities in thinking about Windsor and Detroit as D-W. We’re wondering about examining [...]](http://d1ugx41kvdwavn.cloudfront.net/wp-content/uploads/2010/04/IMG_8680-ps-150x150.jpg)
![New Workshop Series Starting in January: Building Electronics / Designing Originally Starting on January 15, 2013, we’ll be offering a new workshop series for anyone and everyone interested in learning about electronics and physical computing. Hosted by Paul Anderson – a man of too many hobbies who holds the advanced qualification for ham radio in Canada, and has been working with electronics on and off since childhood [...]](http://d1ugx41kvdwavn.cloudfront.net/wp-content/uploads/2012/12/BEDO-POSTER-150x150.jpg)
![Researching Planters We’ve been working on paper planters for a while, but over the last couple of days I started experimenting with magnets as well. Ideally, these could work with having some rare earth magnets embedded in the paper. Still more research and development to be done, but I think it’s getting closer. The first step was [...]](http://d1ugx41kvdwavn.cloudfront.net/wp-content/uploads/2009/04/img_3950-150x150.jpg)
![How to Forget the Border Completely, continued: 707PX Following up on our How to Forget the Border Completely project from last year, collaborator Tom Provost continues to work on ideas around pedestrian border crossings (which you can read all about in the HFBC book!) Photos and text by Tom Provost In the summer of 2011, I was in dialogue with Broken City Lab [...]](http://d1ugx41kvdwavn.cloudfront.net/wp-content/uploads/2012/02/03_707px_provost_640-trim-150x150.jpg)
![9:30pm tonight, an open conversation on the walls of city hall, you’re invited It would be great if you could come. We’ll be at 350 City Hall Sq West, across the street from Charles Clark Square at 9:30pm. We’ll have a projector and a bunch of bristol board. We want to look at what public consultation could look like and how we might imagine the changes we want [...]](http://d1ugx41kvdwavn.cloudfront.net/wp-content/uploads/2011/06/bcl-citycounsel-150x150.jpg)
![Being Productive Again: Day 2 Today was another great, amazingly fun and productive day in 406 Pelissier! We did a lot of material tests, figured out some more details on our book, met some new people, and generally enjoyed having a dedicated workspace. It’s going to be very hard to give up this space. The day started by spreading out [...]](http://d1ugx41kvdwavn.cloudfront.net/wp-content/uploads/2009/06/IMG_0742-150x150.jpg)
![BCL @ PSU MFA Art and Social Practice Conversation Series Justin heads to Portland to present at the PSU MFA Art and Social Practice Conversation Series this week. The PASPWACS is a brand new series of presentations by people and organizations related to Art and Social Practice including artists, non-profits, writers, and architects. The presentations are free and open to the public and take place [...]](http://d1ugx41kvdwavn.cloudfront.net/wp-content/uploads/2013/02/PSU-logo-150x150.jpg)
![Poster Sketches, outcomes from the Workshop with All Tomorrow’s Problems All Tomorrow’s Problems doesn’t aim to necessarily solve anything, but it takes up the position that we can’t wait for anyone else’s solutions either. Every Monday night, a group of people (artists, communicators, designers, academics, students, researchers, strangers, and just all-around passionate people) get together and try to spark conversations around the problems we’re encountering [...]](http://d1ugx41kvdwavn.cloudfront.net/wp-content/uploads/2013/03/wpid22180-IMG_3779-150x150.jpg)
![SRSI, Official Day 1: Welcome Julie, Eric, Daragh, Andrea, Julie and Jefferson Official Day 1 of SRSI kicked off, lots of new folks starting their projects, vinyl is up, rooms are painted (and almost done), floors are clean, the storefronts are open!!! Come see us. The day started off with a bit more painting and cleaning up of 410 Pelissier. As no one was moving in this [...]](http://d1ugx41kvdwavn.cloudfront.net/wp-content/uploads/2010/06/IMG_9860-150x150.jpg)

![Text In-Transit Panels off to the Printers The panels for Text In-Transit have been sent off to the printers. We should be able to install these on Transit Windsor buses in the next couple of weeks!!! We settled on 90 unique panels + 10 title card panels. Again, we can’t thank everyone enough for the support and participation—I’m hugely excited to see [...]](http://d1ugx41kvdwavn.cloudfront.net/wp-content/uploads/2009/05/textintransit-folder-150x150.jpg)
![Reasons Why We Love Detroit In preparation for our upcoming contribution to the We Like Music Festival happening at The Magic Stick in Detroit, we are brainstorming a running list of reasons why we like Detroit. This blog post will be the spot where we can bounce ideas back and fourth through comments to use in our projection of text [...]](http://d1ugx41kvdwavn.cloudfront.net/wp-content/uploads/2010/09/MajesticTheaterDetroit-150x150.jpg)
![The Creation of Place in Abandoned Railway Cuts in Windsor: 1/4 Intro Lee Rodney teaches one of the best courses at the University of Windsor, Border Culture. I took the course in the fall of 2010 and wrote a book: The Creation of Place in Abandoned Railway Cuts in Windsor. The book serves as documentation and comparative analysis of three specific forgotten spaces in downtown Windsor, Ontario, [...]](http://d1ugx41kvdwavn.cloudfront.net/wp-content/uploads/2011/05/cuts-150x150.jpg)
Comments
One Response to “More Arduino + LCD + PHP fun”Trackbacks
Check out what others are saying...[...] » See All of Our Research [...]