<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Broken City Lab &#187; numbers</title>
	<atom:link href="http://www.brokencitylab.org/tags/numbers/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.brokencitylab.org</link>
	<description>Broken City Lab is a creative research group based out of Windsor, Ontario.</description>
	<lastBuildDate>Fri, 10 Sep 2010 18:49:29 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>More Arduino + LCD + PHP fun</title>
		<link>http://www.brokencitylab.org/blog/more-arduino-lcd-php-fun/</link>
		<comments>http://www.brokencitylab.org/blog/more-arduino-lcd-php-fun/#comments</comments>
		<pubDate>Wed, 10 Feb 2010 14:39:27 +0000</pubDate>
		<dc:creator>Justin Langlois</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[arduino]]></category>
		<category><![CDATA[BCL]]></category>
		<category><![CDATA[diagrams]]></category>
		<category><![CDATA[electronics]]></category>
		<category><![CDATA[LCD]]></category>
		<category><![CDATA[numbers]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[research]]></category>

		<guid isPermaLink="false">http://www.brokencitylab.org/?p=7043</guid>
		<description><![CDATA[My work on this ongoing LCD Arduino project has been continuing over the last couple of weeks, I just haven&#8217;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&#8217;m already very well-acquainted with PHP, I&#8217;ve [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.brokencitylab.org/wp-content/uploads/2010/02/IMG_7140.jpg"><img class="alignnone size-full wp-image-7147" title="IMG_7140" src="http://www.brokencitylab.org/wp-content/uploads/2010/02/IMG_7140.jpg" alt="IMG 7140 More Arduino + LCD + PHP fun" width="520" height="347" /></a></p>
<p>My work on this <a href="http://www.brokencitylab.org/blog/new-lcds-and-serial-ports-and-some-maxmsp-for-good-measure/" target="_blank">ongoing LCD Arduino project</a> has been continuing over the last couple of weeks, I just haven&#8217;t had the time to update appropriately.</p>
<p>So, I switched over my plan of attack from Processing to PHP. I figured this made sense for a couple reasons: first, I&#8217;m already very well-acquainted with PHP, I&#8217;ve written and hacked together a good amount of code in this language before and so I feel like I&#8217;ll spend a lot less time just figuring this out and more time actually doing; second, I don&#8217;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.</p>
<p>I&#8217;ve made quite a lot of progress over the last week or so &#8212; 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&#8217;d hoped them to be at this point.</p>
<p><span id="more-7043"></span></p>
<p><a href="http://www.brokencitylab.org/wp-content/uploads/2010/02/Screen-shot-2010-02-04-at-2.47.25-PM.jpg"><img title="Screen-shot-2010-02-04-at-2.47.25-PM" src="http://www.brokencitylab.org/wp-content/uploads/2010/02/Screen-shot-2010-02-04-at-2.47.25-PM.jpg" alt="Screen shot 2010 02 04 at 2.47.25 PM More Arduino + LCD + PHP fun" width="520" height="289" /></a></p>
<p>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.</p>
<p><a href="http://www.brokencitylab.org/wp-content/uploads/2010/02/IMG_7140.jpg"></a><a href="http://www.brokencitylab.org/wp-content/uploads/2010/02/Screen-shot-2010-02-04-at-2.47.19-PM.jpg"><img title="Screen-shot-2010-02-04-at-2.47.19-PM" src="http://www.brokencitylab.org/wp-content/uploads/2010/02/Screen-shot-2010-02-04-at-2.47.19-PM.jpg" alt="Screen shot 2010 02 04 at 2.47.19 PM More Arduino + LCD + PHP fun" width="520" height="281" /></a></p>
<p>I also started working with the PHP Serial class, which is awesome, there are a few versions out there, but the one I&#8217;m using came from Rizwan Kassim who made changes to the oft-circulated Rémy Sanchez version.</p>
<p><a href="http://www.brokencitylab.org/wp-content/uploads/2010/02/Screen-shot-2010-02-04-at-2.47.19-PM.jpg"></a><a href="http://www.brokencitylab.org/wp-content/uploads/2010/02/IMG_7142.jpg"><img class="alignnone size-full wp-image-7146" title="IMG_7142" src="http://www.brokencitylab.org/wp-content/uploads/2010/02/IMG_7142.jpg" alt="IMG 7142 More Arduino + LCD + PHP fun" width="520" height="347" /></a></p>
<p>So, I tweaked the example script to spit out the text that would appear on my LCD screen in my browser window.</p>
<p><a href="http://www.brokencitylab.org/wp-content/uploads/2010/02/IMG_7144.jpg"><img class="alignnone size-full wp-image-7145" title="IMG_7144" src="http://www.brokencitylab.org/wp-content/uploads/2010/02/IMG_7144.jpg" alt="IMG 7144 More Arduino + LCD + PHP fun" width="520" height="347" /></a></p>
<p>Here&#8217;s the script.</p>
<p><a href="http://www.brokencitylab.org/wp-content/uploads/2010/02/IMG_7140.jpg"><img title="IMG_7140" src="http://www.brokencitylab.org/wp-content/uploads/2010/02/IMG_7140.jpg" alt="IMG 7140 More Arduino + LCD + PHP fun" width="520" height="347" /></a></p>
<p>And the result.</p>
<p><a href="http://www.brokencitylab.org/wp-content/uploads/2010/02/IMG_7145.jpg"><img class="alignnone size-full wp-image-7144" title="IMG_7145" src="http://www.brokencitylab.org/wp-content/uploads/2010/02/IMG_7145.jpg" alt="IMG 7145 More Arduino + LCD + PHP fun" width="520" height="347" /></a></p>
<p>Then I moved onto a looped script.</p>
<p><a href="http://www.brokencitylab.org/wp-content/uploads/2010/02/IMG_7147.jpg"><img class="alignnone size-full wp-image-7143" title="IMG_7147" src="http://www.brokencitylab.org/wp-content/uploads/2010/02/IMG_7147.jpg" alt="IMG 7147 More Arduino + LCD + PHP fun" width="520" height="347" /></a></p>
<p>This worked fairly well.</p>
<p><a href="http://www.brokencitylab.org/wp-content/uploads/2010/02/IMG_7148.jpg"><img class="alignnone size-full wp-image-7142" title="IMG_7148" src="http://www.brokencitylab.org/wp-content/uploads/2010/02/IMG_7148.jpg" alt="IMG 7148 More Arduino + LCD + PHP fun" width="520" height="347" /></a></p>
<p>The script &#8230; wrapping the $serial -&gt; sendMessage($i) in a while statement.</p>
<p><a href="http://www.brokencitylab.org/wp-content/uploads/2010/02/IMG_7149.jpg"><img class="alignnone size-full wp-image-7141" title="IMG_7149" src="http://www.brokencitylab.org/wp-content/uploads/2010/02/IMG_7149.jpg" alt="IMG 7149 More Arduino + LCD + PHP fun" width="520" height="347" /></a></p>
<p>My diagram for what exactly I want this to do&#8230;</p>
<p><a href="http://www.brokencitylab.org/wp-content/uploads/2010/02/IMG_7152.jpg"><img class="alignnone size-full wp-image-7140" title="IMG_7152" src="http://www.brokencitylab.org/wp-content/uploads/2010/02/IMG_7152.jpg" alt="IMG 7152 More Arduino + LCD + PHP fun" width="520" height="347" /></a></p>
<p>The counting numbers script was a bit wonky for reasons I&#8217;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&#8217;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.</p>
<p><a href="http://www.brokencitylab.org/wp-content/uploads/2010/02/IMG_7153.jpg"><img class="alignnone size-full wp-image-7139" title="IMG_7153" src="http://www.brokencitylab.org/wp-content/uploads/2010/02/IMG_7153.jpg" alt="IMG 7153 More Arduino + LCD + PHP fun" width="520" height="347" /></a></p>
<p>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&#8217;t know how to automatically display this as I might wish. There are some inherent difficulties in this &#8212; while PHP can find me letters or entire words and break them up accordingly, I&#8217;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.</p>
<p><a href="http://www.brokencitylab.org/wp-content/uploads/2010/02/IMG_7157.jpg"><img class="alignnone size-full wp-image-7137" title="IMG_7157" src="http://www.brokencitylab.org/wp-content/uploads/2010/02/IMG_7157.jpg" alt="IMG 7157 More Arduino + LCD + PHP fun" width="520" height="347" /></a></p>
<p>The other thing that you&#8217;ll notice is that the Arduino sketch as I had written it at the moment, wasn&#8217;t right in its placement of characters on the LCD.</p>
<p><a href="http://www.brokencitylab.org/wp-content/uploads/2010/02/IMG_7158.jpg"><img class="alignnone size-full wp-image-7136" title="IMG_7158" src="http://www.brokencitylab.org/wp-content/uploads/2010/02/IMG_7158.jpg" alt="IMG 7158 More Arduino + LCD + PHP fun" width="520" height="347" /></a></p>
<p>As I understand it, these LCDs are meant to write to the 1st line, then the 3rd, then the 2nd, then the 4th.</p>
<p><a href="http://www.brokencitylab.org/wp-content/uploads/2010/02/IMG_7159.jpg"><img class="alignnone size-full wp-image-7135" title="IMG_7159" src="http://www.brokencitylab.org/wp-content/uploads/2010/02/IMG_7159.jpg" alt="IMG 7159 More Arduino + LCD + PHP fun" width="520" height="347" /></a></p>
<p>In this case, I had the Arduino sketch printing out one letter at a time &#8212; 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.</p>
<p><a href="http://www.brokencitylab.org/wp-content/uploads/2010/02/Screen-shot-2010-02-04-at-8.16.59-PM.jpg"><img title="Screen-shot-2010-02-04-at-8.16.59-PM" src="http://www.brokencitylab.org/wp-content/uploads/2010/02/Screen-shot-2010-02-04-at-8.16.59-PM.jpg" alt="Screen shot 2010 02 04 at 8.16.59 PM More Arduino + LCD + PHP fun" width="520" height="424" /></a></p>
<p>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 &#8212; my LCD is parallel, so I have to imagine this is a big reason why it wasn&#8217;t working.</p>
<p><a href="http://www.brokencitylab.org/wp-content/uploads/2010/02/IMG_7163.jpg"><img class="alignnone size-full wp-image-7133" title="IMG_7163" src="http://www.brokencitylab.org/wp-content/uploads/2010/02/IMG_7163.jpg" alt="IMG 7163 More Arduino + LCD + PHP fun" width="520" height="347" /></a></p>
<p>So, back to the drawing board&#8230;</p>
<p><a href="http://www.brokencitylab.org/wp-content/uploads/2010/02/IMG_7164.jpg"><img class="alignnone size-full wp-image-7132" title="IMG_7164" src="http://www.brokencitylab.org/wp-content/uploads/2010/02/IMG_7164.jpg" alt="IMG 7164 More Arduino + LCD + PHP fun" width="520" height="347" /></a></p>
<p>This time, I got it to work&#8230;</p>
<p><a href="http://www.brokencitylab.org/wp-content/uploads/2010/02/IMG_7165.jpg"><img class="alignnone size-full wp-image-7131" title="IMG_7165" src="http://www.brokencitylab.org/wp-content/uploads/2010/02/IMG_7165.jpg" alt="IMG 7165 More Arduino + LCD + PHP fun" width="520" height="347" /></a></p>
<p>See the comma &#8212; it went to the 2nd line, like it was supposed to!</p>
<p><a href="http://www.brokencitylab.org/wp-content/uploads/2010/02/IMG_7166.jpg"><img class="alignnone size-full wp-image-7130" title="IMG_7166" src="http://www.brokencitylab.org/wp-content/uploads/2010/02/IMG_7166.jpg" alt="IMG 7166 More Arduino + LCD + PHP fun" width="520" height="347" /></a></p>
<p>The string carried on, though it&#8217;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.</p>
<p><a href="http://www.brokencitylab.org/wp-content/uploads/2010/02/Screen-shot-2010-02-04-at-10.13.41-PM.jpg"><img title="Screen-shot-2010-02-04-at-10.13.41-PM" src="http://www.brokencitylab.org/wp-content/uploads/2010/02/Screen-shot-2010-02-04-at-10.13.41-PM.jpg" alt="Screen shot 2010 02 04 at 10.13.41 PM More Arduino + LCD + PHP fun" width="520" height="699" /></a></p>
<p>Here&#8217;s a screenshot of the Arduino code I&#8217;d settled on. Those letter variables are a counter for each line, allowing me to have Arduino automatically wrap the entire string when it&#8217;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.</p>
<p><a href="http://www.brokencitylab.org/wp-content/uploads/2010/02/IMG_7167.jpg"><img class="alignnone size-full wp-image-7129" title="IMG_7167" src="http://www.brokencitylab.org/wp-content/uploads/2010/02/IMG_7167.jpg" alt="IMG 7167 More Arduino + LCD + PHP fun" width="520" height="347" /></a></p>
<p>So the string continues.</p>
<p><a href="http://www.brokencitylab.org/wp-content/uploads/2010/02/IMG_7172.jpg"><img class="alignnone size-full wp-image-7126" title="IMG_7172" src="http://www.brokencitylab.org/wp-content/uploads/2010/02/IMG_7172.jpg" alt="IMG 7172 More Arduino + LCD + PHP fun" width="520" height="347" /></a></p>
<p>And here&#8217;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.</p>
<p><a href="http://www.brokencitylab.org/wp-content/uploads/2010/02/IMG_7175.jpg"><img title="IMG_7175" src="http://www.brokencitylab.org/wp-content/uploads/2010/02/IMG_7175.jpg" alt="IMG 7175 More Arduino + LCD + PHP fun" width="520" height="347" /></a></p>
<p>And again, here&#8217;s the code that finally made this work, all those counters&#8230;</p>
<p>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</p>
<p><strong>Problems that remain at the moment:</strong></p>
<p>I&#8217;m still not sure why I need the Arduino Serial Monitor open for this to work. Unless it&#8217;s open, the PHP script won&#8217;t work and because it doesn&#8217;t work, it gets stuck with the Serial port open, it crashes the Arduino IDE and the LCD itself obviously has no output.</p>
<p>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&#8217;m not sure how to pass that along to Arduino. I&#8217;m guessing using something like a case break type of loop would do it. <a href="http://www.ipipi.com/help/ipipi_in_out.htm" target="_blank">iPiPi</a> 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&#8217;d want a dedicated number or long code, but would be worth it to see this project work as I imagined it &#8230; that part of the project is a little while off anyways. But, I&#8217;m just happy that I found what I was looking for.</p>
<p>&#8211;</p>
<p><strong>Annotated bibliography for the last couple of weeks:</strong></p>
<p><a href="http://dorkbotpdx.org/blog/kmat/serial_lcd" target="_blank">http://dorkbotpdx.org/blog/kmat/serial_lcd</a> (serial &#8211;&gt; LCD &#8230; this is making more sense now, using case breaks to look for specific characters to insert a function, such as starting a new line)</p>
<p><a href="http://blog.datasingularity.com/?p=50" target="_blank">http://blog.datasingularity.com/?p=50</a> (control arduino through html)</p>
<p><a href="http://stackoverflow.com/questions/899098/arduino-serial-reading" target="_blank">http://stackoverflow.com/questions/899098/arduino-serial-reading</a> (arduino serial reading)</p>
<p><a href="http://www.ipipi.com/ContactUs.do" target="_blank">http://www.ipipi.com/ContactUs.do</a> (potential sms forwarding to email option)</p>
<p><a href="http://www.ipipi.com/help/ipipi_in_out.htm" target="_blank">http://www.ipipi.com/help/ipipi_in_out.htm</a> (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)</p>
<p><a href="http://docs.upsidewireless.com/index.php?title=MO_HTTP" target="_blank">http://docs.upsidewireless.com/index.php?title=MO_HTTP</a> (notes on how to bring sms messages into an application using HTTP POST)</p>
<p><a href="http://www.upsidewireless.com/how_virtual_sms_works.htm" target="_blank">http://www.upsidewireless.com/how_virtual_sms_works.htm</a> (this is the kind of service I&#8217;ll need for this project &#8230; SMS messages forwarded to email or accessible through HTTP requests &#8230; with the possibility of getting a Windsor-based number AKA longcode)</p>
<p><a href="http://www.mydarkmaterials.co.uk/2008/11/interfacing-php-with-the-arduino/" target="_blank">http://www.mydarkmaterials.co.uk/2008/11/interfacing-php-with-the-arduino/</a> (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&#8217;t there any longer &#8230; maybe it&#8217;s been silly of me to ignore PHP &#8230; I actually have a decent idea of what I&#8217;m doing there)</p>
<p><a href="http://www.procata.com/blog/archives/2007/10/28/working-with-php-5-in-mac-os-x-105/" target="_blank">http://www.procata.com/blog/archives/2007/10/28/working-with-php-5-in-mac-os-x-105/</a> (helpful to get PHP running properly on 10.6)</p>
<p><a href="http://opensourceprojects-torchris.blogspot.com/2009/09/arduino-pop3-email-checker.html" target="_blank">http://opensourceprojects-torchris.blogspot.com/2009/09/arduino-pop3-email-checker.html</a> (maybe or maybe not useful in some capacity, using arduino to check email)</p>
<p><a href="http://www.arduino.cc/playground/Learning/SparkFunSerLCD" target="_blank">http://www.arduino.cc/playground/Learning/SparkFunSerLCD</a> (serial commands)</p>
<p><a href="http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?action=print;num=1192470251" target="_blank">http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?action=print;num=1192470251</a> (word wrapping in Arduino)</p>
<p><a href="http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1252901403/4">http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1252901403/4</a> (word wrapping more)</p>
<p><strong>I would like to thank the Canada Council for the Arts for their generous support.</strong></p>
<p><a href="http://canadacouncil.ca"><img title="CCFA-bar" src="http://www.brokencitylab.org/wp-content/uploads/2010/01/CCFA-bar.gif" alt="CCFA bar More Arduino + LCD + PHP fun" width="520" height="56" /></a></p>

<div class="sociable">

<ul>
	<li class="sociablefirst"><a rel="nofollow"  target="_blank" href="http://www.facebook.com/share.php?u=http%3A%2F%2Fwww.brokencitylab.org%2Fblog%2Fmore-arduino-lcd-php-fun%2F&amp;t=More%20Arduino%20%2B%20LCD%20%2B%20PHP%20fun" title="Facebook"><img src="http://www.brokencitylab.org/wp-content/plugins/sociable/images/facebook.png" title="Facebook" alt="Facebook" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://twitter.com/home?status=More%20Arduino%20%2B%20LCD%20%2B%20PHP%20fun%20-%20http%3A%2F%2Fwww.brokencitylab.org%2Fblog%2Fmore-arduino-lcd-php-fun%2F" title="Twitter"><img src="http://www.brokencitylab.org/wp-content/plugins/sociable/images/twitter.png" title="Twitter" alt="Twitter" class="sociable-hovers" /></a></li>
	<li class="sociablelast"><a rel="nofollow"  target="_blank" href="http://delicious.com/post?url=http%3A%2F%2Fwww.brokencitylab.org%2Fblog%2Fmore-arduino-lcd-php-fun%2F&amp;title=More%20Arduino%20%2B%20LCD%20%2B%20PHP%20fun&amp;notes=%0D%0A%0D%0AMy%20work%20on%20this%20ongoing%20LCD%20Arduino%20project%20has%20been%20continuing%20over%20the%20last%20couple%20of%20weeks%2C%20I%20just%20haven%27t%20had%20the%20time%20to%20update%20appropriately.%0D%0A%0D%0ASo%2C%20I%20switched%20over%20my%20plan%20of%20attack%20from%20Processing%20to%20PHP.%20I%20figured%20this%20made%20sense%20for%20a%20c" title="del.icio.us"><img src="http://www.brokencitylab.org/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" class="sociable-hovers" /></a></li>
</ul>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.brokencitylab.org/blog/more-arduino-lcd-php-fun/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
