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.
Related posts:
Michelle and I finished so...
I went out to the site for...
We had a lot of changes ha...
Yet another extremely prod...
























![Later Nights, since it’s summer now Michelle and I spent hours and hours together yesterday. With everyone’s schedules fairly ridiculous at the moment, we’re trying to steal what little time we can to keep working. Lately, the time that we’ve all spent together has been framed exclusively almost exclusively by planning for Save the City or organizing the Storefront Residencies for [...]](http://d1ugx41kvdwavn.cloudfront.net/wp-content/uploads/2010/05/IMG_9749-sm-150x150.jpg)
![Defiance: Disobedient Design Panel Discussion Next week, I’ll be heading over to Detroit to join a panel discussion hosted by rogueHAA entitled, Defiance: Obedient Design. They’ve been doing a lot of great programming over the last year or so, and here’s some more information: As part of the Detroit Design Festival presented by the Detroit Creative Corridor Center, rogueHAA is pleased to announce the third [...]](http://d1ugx41kvdwavn.cloudfront.net/wp-content/uploads/2011/09/disobedient-design_A-150x150.jpg)
![LEDs in Action The 10mm LEDs I ordered from Evil Mad Science came in and I went out today to get a CR2032 3V battery to start testing. I got 100 super white and 100 blue LEDs. This is the CR2032 battery, I got 6 of them for $2 from the Dollar Store. It would be interesting to [...]](http://d1ugx41kvdwavn.cloudfront.net/wp-content/uploads/2008/12/img_0997-150x150.jpg)
![How We Spent Labour Day Afternoon It was a beautiful day in Windsor yesterday. Something like 30 degrees fahrenheit cooler than it was just a couple days ago when we were installing at Forest City Gallery. We started and finished our project for this year’s Windsor Biennial. We’ll have a lot more photos soon. The show opens on September 21, 2011, [...]](http://d1ugx41kvdwavn.cloudfront.net/wp-content/uploads/2011/09/IMG_0784-150x150.jpg)
![SRSI, Day 3: Quiet Sunday, but things were still happening It was a bit of a quiet Sunday, but things were still happening down at SRSI. In particular, Julie and Jefferson were hard at work all day, preparing their project, “The Peoples Museum & Fabulations de Windsor.” Above, and in between visits from some neighbours and friends, Julie preps a large piece of paper for [...]](http://d1ugx41kvdwavn.cloudfront.net/wp-content/uploads/2010/06/IMG_9890-150x150.jpg)
![Detroit bus services… A note from Stephen Hargreaves after our conversation last night about the bus system in Detroit and possibilities for cross-border transportation… the image above is of a different Detroit map just to give some reference. On the map Stephen mentions, the routes go far beyond Detroit’s city limits. Check out the “System Map”, where the [...]](http://d1ugx41kvdwavn.cloudfront.net/wp-content/uploads/2011/01/Screen-shot-2011-01-03-at-1.35.48-PM-150x150.png)
![This Probably Isn’t Helping: When Gateways Fail Physical civic improvements are an important step for Windsor. Our gateways, if you’re unfamiliar with the city, are a bit lack-luster at present. Where gateways do exist, the markers are underdeveloped, poorly executed, and are the kind of “this could literally be anywhere” design strategy. Why do gateways matter? Physically and visually defining space is [...]](http://d1ugx41kvdwavn.cloudfront.net/wp-content/uploads/2011/01/gatewayDay-150x150.jpg)
![Guess what showed up today? So … the book we created from our research project, How to Forget the Border Completely, finally showed up!!! I’m really happy with how it looks and I can’t wait to have some time to read through it all. After this week’s activities, we should plan some kind of launch for the book. Tom’s renderings [...]](http://d1ugx41kvdwavn.cloudfront.net/wp-content/uploads/2011/10/IMG_5370-150x150.jpg)
![Save A City At Windsor’s riverfront, SAVE A CITY, installed this afternoon. We opted out of using monofilament to hang the blocks of ice because there was a nice snowbank already there, and probably the last thing the Detroit River needs is more garbage in it. I’ll post some photos of the process of making these soon (definitely [...]](http://d1ugx41kvdwavn.cloudfront.net/wp-content/uploads/2009/02/img_2536-2-150x150.jpg)
![“Alive & Well” viewable on Google Maps Our project for the 2011 Windsor Biennial, Alive & Well, was created with the hope that it would be captured on Google Maps to make a monument or announcement of sorts to the rest of the world about Windsor as we near the end of the year and ahead of being torn up for the new Aquatic [...]](http://d1ugx41kvdwavn.cloudfront.net/wp-content/uploads/2011/12/aliveandWellscreenshot-2-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)
![EC Row Walkway Measurement We spent part of Monday afternoon doing a site visit for an upcoming project we’ve been planning for a while. The EC Row Walkway crosses over the 6 lanes of EC Row and is a pretty incredible view. We took some measurements and did a quick visibility test. We were only up there for about [...]](http://d1ugx41kvdwavn.cloudfront.net/wp-content/uploads/2009/01/img_2037-150x150.jpg)
![Public Realm at Propeller Centre for the Visual Arts On Thursday, January 21st at the Propeller Centre for the Visual Arts in Toronto, we’ll be doing a projection performance that examines the language and ideas surrounding public space, intervention, urban surfaces, and city infrastructures. As part of Propeller’s Public Realm exhibition, we will curate a text-based list of ideas, statements, and questions, that address the [...]](http://d1ugx41kvdwavn.cloudfront.net/wp-content/uploads/2010/01/propellerinvite-150x150.jpg)
![Welcome to the Neighbourhood Recap of Awesome Psychogeographic Exploration!!! Welcome to the Neighbourhood took five groups of brave explorers on an adventure around West Windsor on Monday in order to highlight the potential to pay particular attention to the many things that usually go unnoticed in such a transient area. Given that the neighbourhood surrounding the University of Windsor is made up mostly of [...]](http://d1ugx41kvdwavn.cloudfront.net/wp-content/uploads/2009/09/DSCF1055-150x150.jpg)
![Editing Over Distances From way away in Toronto, Cristina sends edits through the magic of Tracking Changes after some good old fashioned hand-written editing. I did the same while waiting for the flight back to Detroit. We’re getting so excited about this project, we’ll have to figure out a way to pull it off … funding or no [...]](http://d1ugx41kvdwavn.cloudfront.net/wp-content/uploads/2010/10/IMG_0203-sm-150x150.jpg)
![BCL Report: April 21, 2011 (making decisions) Thursday night was a night of decisions and tests. We’ve spent the last couple of weeks just trying to get caught up generally with projects and Thursday marked the beginning of the deciding how to start wrapping up How to Forget the Border Completely and what direction to move in to make some more progress on [...]](http://d1ugx41kvdwavn.cloudfront.net/wp-content/uploads/2011/04/IMG_9596-150x150.jpg)
![The LED Sign is Finished!!! It’s taken a number of weeks, but we finished wiring the LED sign at tonight’s Office Hours! It was a pretty incredible moment to plug in the sign, turn off the lights, and realize that we made this come together. I’m really, really, really happy with how it turned out!!! There are still a few [...]](http://d1ugx41kvdwavn.cloudfront.net/wp-content/uploads/2009/02/img_2667-150x150.jpg)
![SRSI, Day 21: Busting Open Payphones Laura Paolini of Bell Payphone Labs arrived yesterday with a mission to bust open her payphones. We found all the tools and help we needed out on the street. Otherwise, business as usual down on Pelissier, with one week left to go! The Department of Unusual Certainties have been re-arranging their workspace. These boys are [...]](http://d1ugx41kvdwavn.cloudfront.net/wp-content/uploads/2010/07/IMG_8367-150x150.jpg)
![Eric Boucher Micro-Residency Iteration 4/5 For part 4 of Eric Boucher’s Micro-Residency, we trekked all the way out to Harrow to interview my good friend, and local musician, Derek Harrison. I met Derek way back in my first week of University and became friends very quickly. Since that first semester in Windsor, Derek has been leaving Windsor left and right, [...]](http://d1ugx41kvdwavn.cloudfront.net/wp-content/uploads/2009/12/derek-150x150.jpg)
![Getting Things to Talk: Arduino + LCDs I spent the better part of the day on Saturday doing some more basic research into connecting an Arduino and LCD for this ongoing project. For the most part, it’s pretty basic and following the wiring diagrams and tutorials online is fine. I ran into a problem with getting text on two lines, which I’ll [...]](http://d1ugx41kvdwavn.cloudfront.net/wp-content/uploads/2010/01/IMG_6480-150x150.jpg)
Comments
One Response to “More Arduino + LCD + PHP fun”Trackbacks
Check out what others are saying...[...] » See All of Our Research [...]