<?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>swan tron dot com &#187; Arduino</title>
	<atom:link href="http://swantron.com/tag/arduino/feed/" rel="self" type="application/rss+xml" />
	<link>http://swantron.com</link>
	<description>Gadgetery, Consumer Electronics, &#38; Robots FTW</description>
	<lastBuildDate>Thu, 17 May 2012 21:38:45 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>Arduino 120V AC Relay Example</title>
		<link>http://swantron.com/arduino-120v-ac-relay-example/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=arduino-120v-ac-relay-example</link>
		<comments>http://swantron.com/arduino-120v-ac-relay-example/#comments</comments>
		<pubDate>Wed, 13 Jul 2011 04:13:18 +0000</pubDate>
		<dc:creator>Joseph Swanson</dc:creator>
				<category><![CDATA[Arduino]]></category>
		<category><![CDATA[how2]]></category>
		<category><![CDATA[120V]]></category>
		<category><![CDATA[Awesome]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[PowerSwitch]]></category>
		<category><![CDATA[Project]]></category>
		<category><![CDATA[Relay]]></category>
		<category><![CDATA[Snippet]]></category>
		<category><![CDATA[Takeaway]]></category>
		<category><![CDATA[Teardown]]></category>

		<guid isPermaLink="false">http://swantron.com/?p=3666</guid>
		<description><![CDATA[I got tired of poking around with LCD drivers with my Arduino. Time for a quick project to mix it up&#8230;staring at a surge protector always puts 120V on my mind. As it turns out, I tore apart an old &#8230; <a href="http://swantron.com/arduino-120v-ac-relay-example/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I got tired of poking around with LCD drivers with my Arduino.  Time for a quick project to mix it up&#8230;staring at a surge protector always puts 120V on my mind.  As it turns out, I tore apart an old humidifier a while ago on my &#8216;workbench.&#8217; Monday night is Katie&#8217;s reality TV night&#8230;time for something sweet.  </p>
<p>Investigating duty cycles on this plastic fan:</p>
<div id="attachment_3669" class="wp-caption aligncenter" style="width: 580px"><a href="http://swantron.com/wp-content/uploads/2011/07/fan-hack.jpg"><img src="http://swantron.com/wp-content/uploads/2011/07/fan-hack.jpg" alt="fan hack" title="fan-hack" width="570" height="233" class="size-full wp-image-3669" /></a><p class="wp-caption-text">fan hack</p></div>
<p>I figured that I could horse around with my PowerSwitch Tail, and make it somewhat mimic a PWM 5V setup.  I was curious how long I would have to &#8216;pulse&#8217; the switch with juice to keep the fan constantly rolling.  I started with it fully on, and kicked my &#8216;active&#8217; duty cycles lower until I reached a nearly-continual state of motion.  Pause for Arduino code snippet:</p>
<blockquote><p>
/*<br />
PowerSwitch Tail Template<br />
-<br />
120V AC Driver w/ LED indicator<br />
-<br />
Joseph Swanson<br />
2011 | http://swantron.com<br />
*/</p>
<p>void setup()  {<br />
  // declare pins (13, 7) for writing<br />
  pinMode(13, OUTPUT);<br />
  pinMode(7, OUTPUT);<br />
} </p>
<p>void loop()  {<br />
  // Fire relay / LED<br />
  digitalWrite(13, HIGH);<br />
  digitalWrite(7, HIGH);</p>
<p>  // Configure for &#8220;on&#8221; time<br />
  delay (50);</p>
<p>  // Kill relay / LED<br />
  digitalWrite(13, LOW);<br />
  digitalWrite(7, LOW);</p>
<p>  // Configure for &#8220;off&#8221; time<br />
  delay (950);<br />
}
</p></blockquote>
<p>Pause for a small small-video break:  </p>
<p><iframe width="569" height="427" src="http://www.youtube.com/embed/aXMxPQckQ9Q" frameborder="0" allowfullscreen></iframe></p>
<p>As that code and vid indicate, 1/20th of a second is all it took to keep the fan rolling, with 19/20th of a second idle.  Not bad.  Not sure what the takeaway is, but that is something to mention.  </p>
<p>Put that knowledge somewhere safe, provided the question of humidifier fan duty cycles should spring up.  </p>
]]></content:encoded>
			<wfw:commentRss>http://swantron.com/arduino-120v-ac-relay-example/feed/</wfw:commentRss>
		<slash:comments>14</slash:comments>
		</item>
		<item>
		<title>Evolution of a Project</title>
		<link>http://swantron.com/evolution-of-a-project/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=evolution-of-a-project</link>
		<comments>http://swantron.com/evolution-of-a-project/#comments</comments>
		<pubDate>Thu, 30 Jun 2011 03:48:02 +0000</pubDate>
		<dc:creator>Joseph Swanson</dc:creator>
				<category><![CDATA[Arduino]]></category>
		<category><![CDATA[Awesome]]></category>
		<category><![CDATA[Blue]]></category>
		<category><![CDATA[Duemilanove]]></category>
		<category><![CDATA[LCD]]></category>
		<category><![CDATA[Project]]></category>
		<category><![CDATA[Python]]></category>

		<guid isPermaLink="false">http://swantron.com/?p=3613</guid>
		<description><![CDATA[I have two speeds when it comes to projects: percolate and bazooka. Whereas my swantron comment / to / LCD project was bazooka, this Twitter deal has been percolate. Haven&#8217;t been able to jump in completely, rather, I have been &#8230; <a href="http://swantron.com/evolution-of-a-project/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I have two speeds when it comes to projects:  percolate and bazooka.  Whereas my swantron comment / to / LCD project was bazooka, this Twitter deal has been percolate.  Haven&#8217;t been able to jump in completely, rather, I have been poking this one with a stick.  </p>
<p>Still poking&#8230;</p>
<div id="attachment_3614" class="wp-caption aligncenter" style="width: 580px"><a href="http://swantron.com/wp-content/uploads/2011/06/lcd-arduino.jpg"><img src="http://swantron.com/wp-content/uploads/2011/06/lcd-arduino.jpg" alt="arduino controlling blue lcd" title="lcd-arduino" width="570" height="320" class="size-full wp-image-3614" /></a><p class="wp-caption-text">dual terminals and a terminal</p></div>
<p>Making progress&#8230;snagging my Twitter page via Python, and dumping it to LCD:</p>
<div id="attachment_3615" class="wp-caption aligncenter" style="width: 580px"><a href="http://swantron.com/wp-content/uploads/2011/06/blue-lcd-screen.jpg"><img src="http://swantron.com/wp-content/uploads/2011/06/blue-lcd-screen.jpg" alt="body and html closing tags on my lcd" title="blue-lcd-screen" width="570" height="320" class="size-full wp-image-3615" /></a><p class="wp-caption-text">+1 closing tags</p></div>
<p>I just need to hammer out some parsing, and I will be good to go.  I really need to figure out some sweet regex and drop this whole &#8216;import (some junk)&#8217; stuff.  Who knows&#8230;at this rate, I just may.  </p>
]]></content:encoded>
			<wfw:commentRss>http://swantron.com/evolution-of-a-project/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>HTML to Python to Arduino to LCD</title>
		<link>http://swantron.com/html-to-python-to-arduino-to-lcd/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=html-to-python-to-arduino-to-lcd</link>
		<comments>http://swantron.com/html-to-python-to-arduino-to-lcd/#comments</comments>
		<pubDate>Thu, 02 Jun 2011 04:42:07 +0000</pubDate>
		<dc:creator>Joseph Swanson</dc:creator>
				<category><![CDATA[Arduino]]></category>
		<category><![CDATA[HoF]]></category>
		<category><![CDATA[how2]]></category>
		<category><![CDATA[Awesome]]></category>
		<category><![CDATA[CLI]]></category>
		<category><![CDATA[DIY]]></category>
		<category><![CDATA[LCD]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[pix]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[Scripting]]></category>
		<category><![CDATA[This is Unix I Know This]]></category>
		<category><![CDATA[Video]]></category>
		<category><![CDATA[Vids]]></category>

		<guid isPermaLink="false">http://swantron.com/?p=3536</guid>
		<description><![CDATA[Last week found me standing tall upon my shell script soapbox, shouting command line praises to all who would listen. Thou ought direct thine output aftways, to-wards thine USB port of thee. And that is well and righteous. Well, that &#8230; <a href="http://swantron.com/html-to-python-to-arduino-to-lcd/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Last week found me standing tall upon my shell script soapbox, shouting command line praises to all who would listen. </p>
<p><em>Thou ought direct thine output aftways, to-wards thine USB port of thee.  And that is well and righteous.  </em></p>
<p>Well, that still is the case.  My latest project has made it glaringly obvious that sometimes a little Python script will render a whole bunch of shell scripting moot.  Namely, parsing HTML.  Let&#8217;s see a picture&#8230;</p>
<div id="attachment_3537" class="wp-caption aligncenter" style="width: 580px"><a href="http://swantron.com/wp-content/uploads/2011/06/outdoor-computer.jpg"><img src="http://swantron.com/wp-content/uploads/2011/06/outdoor-computer.jpg" alt="outdoor hacking" title="outdoor-computer" width="570" height="320" class="size-full wp-image-3537" /></a><p class="wp-caption-text">bad lab mobile</p></div>
<p>Lunch hour project:  <strong>parse the comments from swantron.com; feed said comments to an LCD screen.</strong>  </p>
<p>I was horsing around with wget from a CLI a few days ago.  I found myself trying to smash through the resultant file via pure regular expressions&#8230;which is incredibly clumsy.  Well, as luck would have it, my go-to after my main go-to is Python, and this type of thing has been issue enough to warrant a library.  BeautifulSoup.  It acts to parse the HTML info into items, that can be smashed around as I see(med) fit.  </p>
<p>My setup was simple: py script to snag my comments and write serial, Arduino sketch to drive a LCD and read/write serial.  And a source of shade.  And a WiFi signal to snag.  </p>
<div id="attachment_3538" class="wp-caption aligncenter" style="width: 580px"><a href="http://swantron.com/wp-content/uploads/2011/06/outdoor-hacking.jpg"><img src="http://swantron.com/wp-content/uploads/2011/06/outdoor-hacking.jpg" alt="mobile mobile" title="outdoor-hacking" width="570" height="320" class="size-full wp-image-3538" /></a><p class="wp-caption-text">bad lab mobile-mobile</p></div>
<p>Check, check, check, etc.  Video time:</p>
<p><iframe width="569" height="427" src="http://www.youtube.com/embed/4nyInt_5HHU" frameborder="0" allowfullscreen></iframe></p>
<p>Pretty slick&#8230;hit the fold for the code, as promised, and a summary.<br />
<span id="more-3536"></span><br />
Python parser / serial writer </p>
<blockquote><p>#!/usr/bin/python<br />
# http://swantron.com<br />
# htlm grab / parse&#8230;<br />
# &#8230;write to serial out<br />
# 2011</p>
<p>admin = [ 'Joseph Swanson' ]<br />
total = True</p>
<p>import urllib2, time, serial, sys<br />
from BeautifulSoup import BeautifulSoup</p>
<p># disregard spammers | disregard identical posts | create spam zone</p>
<p>spam = []</p>
<p># initialize serial write to Arduino</p>
<p>ser = serial.Serial(&#8216;/dev/ttyUSB0&#8242;, 9600)</p>
<p>time.sleep(5)</p>
<p># work section </p>
<p>while True:</p>
<p>  # snag html</p>
<p>  html = urllib2.urlopen(&#8220;http://swantron.com/comments/feed&#8221;).read()</p>
<p>  # parse</p>
<p>  soup = BeautifulSoup(html)</p>
<p>  # inspect parsed results</p>
<p>  for item in soup(&#8216;item&#8217;):<br />
      badGuy = item(&#8216;guid&#8217;)[0].string.split(&#8216;comment-&#8217;)[1]</p>
<p>      if badGuy not in spam:</p>
<p>              # spammer jail</p>
<p>              spam.append(badGuy)</p>
<p>              # time modification</p>
<p>              postTime = item(&#8216;pubdate&#8217;)[0].string<br />
              parsedTime = time.strptime(postTime, &#8220;%a, %d %b %Y %H:%M:%S +0000&#8243;)<br />
              offsetTime = time.mktime(parsedTime) &#8211; time.timezone<br />
              localPostTime = time.strftime(&#8220;%m/%d/%y %H:%M&#8221;, time.localtime(offsetTime))</p>
<p>              # identify me</p>
<p>              author = item(&#8216;dc:creator&#8217;)[0].string<br />
              if author in admin:<br />
                  print &#8220;(&#8221; + localPostTime + &#8220;) I, &#8221; + author + &#8220;, just posted a comment&#8221;<br />
                  print &#8221;    &#8221; + item(&#8216;guid&#8217;)[0].string<br />
                  print &#8221;    &#8221; + item(&#8216;description&#8217;)[0].string<br />
                  ser.write(item(&#8216;description&#8217;)[0].string)<br />
		  time.sleep(1)<br />
              elif total:<br />
                  print &#8220;(&#8221; + localPostTime + &#8220;) background noise ~~ &#8221; + author<br />
                  print &#8221;    &#8221; + item(&#8216;guid&#8217;)[0].string<br />
                  print &#8221;    &#8221; + item(&#8216;description&#8217;)[0].string<br />
                  ser.write(item(&#8216;description&#8217;)[0].string)</p>
<p>  time.sleep(10)</p></blockquote>
<p>Arduino LCD driver</p>
<blockquote><p>
// LCD Driver<br />
// http://swantron.com<br />
// basic serial in > LCD display<br />
// 2011</p>
<p>#include <LiquidCrystal.h></p>
<p>// **Define pins**<br />
// LCD RS &#8211; pin 12<br />
// LCD R/W &#8211; pin 11<br />
// LCD ENABLE &#8211; pin 10<br />
// LCD BACK+ &#8211; pin 13<br />
// LCD DATA4 &#8211; pin 5<br />
// LCD DATA5 &#8211; pin 4<br />
// LCD DATA6 &#8211; pin 3<br />
// LCD DATA7 &#8211; pin 2<br />
// LCD VSS, CONTRAST,  BACK- &#8211; ground</p>
<p>LiquidCrystal lcd(12, 11, 10, 5, 4, 3, 2);</p>
<p>int backLight = 13;    // Define pin for backlight</p>
<p>void setup()<br />
{<br />
  pinMode(backLight, OUTPUT);<br />
  digitalWrite(backLight, HIGH); // Backlight level (LOW / HIGH)<br />
  lcd.begin(20,4);               // (Columns, Rows)<br />
  Serial.begin(9600);<br />
}</p>
<p>void loop()<br />
{<br />
  // when characters arrive over the serial port&#8230;<br />
  if (Serial.available()) {<br />
    // wait a bit for the entire message to arrive<br />
    delay(100);<br />
    // clear the screen<br />
    lcd.clear();<br />
    // read all the available characters<br />
    while (Serial.available() > 0) {<br />
      // display each character to the LCD<br />
      lcd.write(Serial.read());<br />
    }<br />
  }<br />
}</p></blockquote>
<p>I&#8217;m excited about this project.  Even though this deal is in gen 3, I still have some crazy take-off ideas.  Create a secure page on swantron to hold a few values&#8230;hook up my old notebook as a base station&#8230;home automation on the cheap.  Replace that LCD with a sketch to search for a particular string, i.e. &#8220;open garage door&#8221; and boom, there you go.  This could be very cool.  Introduce twitter to remove my server from the equation&#8230;awesome.  </p>
<p>Hit the comments with any improvements or project ideas you can conjure.  This one has me excited&#8230;feel free to challenge me with something cool.  As always, thanks for reading, yadda yadda, stay tuned, etc.  </p>
]]></content:encoded>
			<wfw:commentRss>http://swantron.com/html-to-python-to-arduino-to-lcd/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>Python Teaser</title>
		<link>http://swantron.com/python-teaser/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=python-teaser</link>
		<comments>http://swantron.com/python-teaser/#comments</comments>
		<pubDate>Tue, 31 May 2011 02:41:08 +0000</pubDate>
		<dc:creator>Joseph Swanson</dc:creator>
				<category><![CDATA[Arduino]]></category>
		<category><![CDATA[Awesome]]></category>
		<category><![CDATA[Beautiful Soup]]></category>
		<category><![CDATA[LCD]]></category>
		<category><![CDATA[Prototype]]></category>
		<category><![CDATA[Python]]></category>

		<guid isPermaLink="false">http://swantron.com/?p=3527</guid>
		<description><![CDATA[After a deal of success with the command line interface-to-Arduino project, I am in the middle of stepping it up a notch. I ended up on a few blogs due to that last effort, which indicates that I am doing &#8230; <a href="http://swantron.com/python-teaser/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>After a deal of success with the command line interface-to-Arduino project, I am in the middle of stepping it up a notch.  I ended up on a few blogs due to that last effort, which indicates that I am doing something worthy of note.  Hats off to me, perhaps.  Well, my tool belt is what it is&#8230;if I can&#8217;t do it via shell scripting, I reach next for Python.  In an attempt to parse stuff that I have been &#8216;getting&#8217; via wget, I found myself trying to do some clunky regex from the command line.  Guess what&#8230;I can do that without as much heartache via Python via BeautifulSoup&#8230;<br />
<div id="attachment_3528" class="wp-caption aligncenter" style="width: 580px"><a href="http://swantron.com/wp-content/uploads/2011/05/beautysoup.jpg"><img src="http://swantron.com/wp-content/uploads/2011/05/beautysoup.jpg" alt="beautiful soup" title="beautysoup" width="570" height="320" class="size-full wp-image-3528" /></a><p class="wp-caption-text">so...beautiful</p></div><br />
Thus far, I have python doing the website getting and Beautiful Soup doing the parsing of my site&#8230;basically just grabbing some info at this point that I can modify.  I have my LCD driven via my trusty Arduino, and that is that.  Instead of redirecting standard out to serial, I am writing to serial via python.  Easy breezy. </p>
<p>I have some sloppy sloppy code at this point, and need to add some hardware and stuffs to my prototype.  Stay tuned&#8230;this could be a good one.  </p>
]]></content:encoded>
			<wfw:commentRss>http://swantron.com/python-teaser/feed/</wfw:commentRss>
		<slash:comments>24</slash:comments>
		</item>
		<item>
		<title>Command Line LCD Arduino Interface</title>
		<link>http://swantron.com/command-line-lcd-arduino-interface/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=command-line-lcd-arduino-interface</link>
		<comments>http://swantron.com/command-line-lcd-arduino-interface/#comments</comments>
		<pubDate>Fri, 20 May 2011 19:44:20 +0000</pubDate>
		<dc:creator>Joseph Swanson</dc:creator>
				<category><![CDATA[Arduino]]></category>
		<category><![CDATA[how2]]></category>
		<category><![CDATA[100% Awesome]]></category>
		<category><![CDATA[Awesome]]></category>
		<category><![CDATA[CLI]]></category>
		<category><![CDATA[Command Line]]></category>
		<category><![CDATA[Duemilanove]]></category>
		<category><![CDATA[Interface]]></category>
		<category><![CDATA[LCD]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[This is Unix I Know This]]></category>
		<category><![CDATA[Ubuntu]]></category>

		<guid isPermaLink="false">http://swantron.com/?p=3502</guid>
		<description><![CDATA[Liquid crystal displays are pretty awesome. Command line interfaces are very awesome. Hmm&#8230; I started daydreaming at work about how to go about making hardware interface with an RSS feed. I have seen some projects that use Arduinos with ethernet &#8230; <a href="http://swantron.com/command-line-lcd-arduino-interface/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Liquid crystal displays are pretty awesome.  Command line interfaces are very awesome.  Hmm&#8230;</p>
<p>I started daydreaming at work about how to go about making hardware interface with an RSS feed.  I have seen some projects that use Arduinos with ethernet shields to check Twitter, for example, but they seem unnecessarily bulky.  Or clumsy.  I spend a lot of time working on the command line, and love to put together dirty little scripts to solve problems.  It sort of goes along the lines of &#8216;when you have a hammer, everything looks like a nail&#8217;&#8230;I figured that the same thing could be implemented with a little shell scripting and my trusty Arduino, sans anything complicated.  </p>
<p>So far, so good.  </p>
<div id="attachment_3503" class="wp-caption aligncenter" style="width: 580px"><a href="http://swantron.com/wp-content/uploads/2011/05/LCD-setup.jpg"><img src="http://swantron.com/wp-content/uploads/2011/05/LCD-setup.jpg" alt="bad lab mobile" title="LCD-setup" width="570" height="320" class="size-full wp-image-3503" /></a><p class="wp-caption-text">bad lab mobile</p></div>
<p>I put together a sketch (after the bump) to drive my LCD, writing serial output to the screen.  After verifying that the sketch worked via the Arduino IDE&#8217;s serial monitor, I popped open a CLI and got to work.  FWIW, I am using Ubuntu 11.04 still&#8230;ctrl-alt-t pops open a terminal window&#8230;unity has me all over shortcuts these days.  Anyhow, I was able to verify that I could echo text and direct it to the USB port that the Arduino was mounted to.  No sweat.  </p>
<p>As a proof of concept, I decided to display the number of times that I had the word &#8220;awesome&#8221; on swantron.com.  Once the LCD was shown to work, the sky is the limit&#8230;see some regex, pipes, wget, and so forth in action:</p>
<div id="attachment_3505" class="wp-caption aligncenter" style="width: 580px"><a href="http://swantron.com/wp-content/uploads/2011/05/LCD.jpg"><img src="http://swantron.com/wp-content/uploads/2011/05/LCD.jpg" alt="CLI" title="LCD" width="570" height="550" class="size-full wp-image-3505" /></a><p class="wp-caption-text">CLI FTW</p></div>
<p>Survey says:</p>
<div id="attachment_3504" class="wp-caption aligncenter" style="width: 580px"><a href="http://swantron.com/wp-content/uploads/2011/05/awesome-count.jpg"><img src="http://swantron.com/wp-content/uploads/2011/05/awesome-count.jpg" alt="+1 awesome" title="awesome-count" width="570" height="320" class="size-full wp-image-3504" /></a><p class="wp-caption-text">+11 awesome</p></div>
<p>Eleven &#8220;awesome&#8221;s.  Awesome.<br />
(Hit the bump for some code, an oddity, and more fun&#8230;)<br />
<span id="more-3502"></span></p>
<p>So that is that.  You could link two of these together for 160 characters&#8230;toss together a shell (or Python, etc.) and have a Twitter display, for example.  Whatever you want to&#8230;gosh.  </p>
<p>I did notice an odd &#8220;feature&#8221; of the Liquid Crystal library I used.  For some reason, it wraps lines in an interesting fashion&#8230;</p>
<p>command line usage: <strong><br />
> echo &#8220;why does this library I am using wrap text wonky as hell?&#8221; > /dev/ttyUSB0</strong><br />
<div id="attachment_3506" class="wp-caption aligncenter" style="width: 580px"><a href="http://swantron.com/wp-content/uploads/2011/05/LCD-wrapping.jpg"><img src="http://swantron.com/wp-content/uploads/2011/05/LCD-wrapping.jpg" alt="why wrap like this" title="LCD-wrapping" width="570" height="320" class="size-full wp-image-3506" /></a><p class="wp-caption-text">1 &gt; 3 &gt; 2 &gt; 4</p></div></p>
<p>No idea why this is.  Sort of confusing.  Anyhow, the entire sketch is pretty straight forward.  Did somebody say snippet?</p>
<blockquote><p>// LCD sandbox<br />
// http://swantron.com<br />
// driving LCD from command line<br />
// 2011</p>
<p>#include <LiquidCrystal.h></p>
<p>// **Define pins**<br />
// LCD RS &#8211; pin 12<br />
// LCD R/W &#8211; pin 11<br />
// LCD ENABLE &#8211; pin 10<br />
// LCD BACK+ &#8211; pin 13<br />
// LCD DATA4 &#8211; pin 5<br />
// LCD DATA5 &#8211; pin 4<br />
// LCD DATA6 &#8211; pin 3<br />
// LCD DATA7 &#8211; pin 2<br />
// LCD VSS, CONTRAST,  BACK- &#8211; ground</p>
<p>LiquidCrystal lcd(12, 11, 10, 5, 4, 3, 2);</p>
<p>int backLight = 13;    // Define pin for backlight</p>
<p>void setup()<br />
{<br />
  pinMode(backLight, OUTPUT);<br />
  digitalWrite(backLight, HIGH); // Backlight level (LOW / HIGH)<br />
  lcd.begin(20,4);               // (Columbs, Rows)<br />
  Serial.begin(9600);<br />
}</p>
<p>void loop()<br />
{<br />
  // when characters arrive over the serial port&#8230;<br />
  if (Serial.available()) {<br />
    // wait a bit for the entire message to arrive<br />
    delay(100);<br />
    // clear the screen<br />
    lcd.clear();<br />
    // read all the available characters<br />
    while (Serial.available() > 0) {<br />
      // display each character to the LCD<br />
      lcd.write(Serial.read());<br />
    }<br />
  }<br />
}</p></blockquote>
<p>We&#8217;ll see where this one ends up.  This one might be a launching pad for a bigger and better thing.  Stay tuned.   </p>
]]></content:encoded>
			<wfw:commentRss>http://swantron.com/command-line-lcd-arduino-interface/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
		<item>
		<title>Easy LCD Arduino Display</title>
		<link>http://swantron.com/easy-lcd-arduino-display/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=easy-lcd-arduino-display</link>
		<comments>http://swantron.com/easy-lcd-arduino-display/#comments</comments>
		<pubDate>Sun, 15 May 2011 02:29:32 +0000</pubDate>
		<dc:creator>Joseph Swanson</dc:creator>
				<category><![CDATA[Arduino]]></category>
		<category><![CDATA[Awesome]]></category>
		<category><![CDATA[Blue]]></category>
		<category><![CDATA[Duemilanove]]></category>
		<category><![CDATA[LCD]]></category>
		<category><![CDATA[Prototyping]]></category>

		<guid isPermaLink="false">http://swantron.com/?p=3489</guid>
		<description><![CDATA[I am tired of looking at wobbly windows full of Eclipse. The best and worst part of the IOIO board is the fact that the libraries are Java-centric&#8230;unfortunately, I am in the middle of a &#8216;worst&#8217; phase. I am sort &#8230; <a href="http://swantron.com/easy-lcd-arduino-display/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I am tired of looking at wobbly windows full of Eclipse.  The best and worst part of the IOIO board is the fact that the libraries are Java-centric&#8230;unfortunately, I am in the middle of a &#8216;worst&#8217; phase.  I am sort of stalemated.  Unfortunately, my issue lies in something that should be trivial, namely naming.  Once I can figure out how to orient the crap out of these object-ass pins, I will be good to go.  Until then&#8230;I am going back to the basics.  Processing looks so safe and warm.  Coziness, for the win.  </p>
<p>How about a 20 by 4 LCD project?  Okay.  </p>
<div id="attachment_3490" class="wp-caption aligncenter" style="width: 580px"><a href="http://swantron.com/wp-content/uploads/2011/05/Blue-LCD.jpg"><img src="http://swantron.com/wp-content/uploads/2011/05/Blue-LCD.jpg" alt="easy blue LCD arduino +1 easy" title="Blue-LCD" width="570" height="320" class="size-full wp-image-3490" /></a><p class="wp-caption-text">+1 blue</p></div>
<p>I have had this sitting on the workbench of bad lab for a while.  Time to get after it.  </p>
<p>The unit came assembled, minus the jumpers I needed to plug this into my breadboard for prototyping.  Coincidentally, my soldering station needed to come out of retirement.  Sixteen pins&#8230;sounds about perfect.</p>
<p>(hit the bump for several more pics, a snippet, and some other awesome stuff)<span id="more-3489"></span></p>
<div id="attachment_3491" class="wp-caption aligncenter" style="width: 580px"><a href="http://swantron.com/wp-content/uploads/2011/05/soldering-wire.jpg"><img src="http://swantron.com/wp-content/uploads/2011/05/soldering-wire.jpg" alt="soldering wire spool" title="soldering-wire" width="570" height="643" class="size-full wp-image-3491" /></a><p class="wp-caption-text">those.</p></div>
<p>I snagged the unit from hacktronics.com.  Their <a href="http://www.hacktronics.com/">website</a> has details on the pin-level for the LCD unit.  Pretty straight forward&#8230;slam it together and feed it a string or four.  Wiring as follows: </p>
<div id="attachment_3492" class="wp-caption aligncenter" style="width: 580px"><a href="http://swantron.com/wp-content/uploads/2011/05/Arduino-LCD.jpg"><img src="http://swantron.com/wp-content/uploads/2011/05/Arduino-LCD.jpg" alt="arduino lcd action" title="Arduino-LCD" width="570" height="320" class="size-full wp-image-3492" /></a><p class="wp-caption-text">+ several wires</p></div>
<p>It has been a while since we have had a snippet.  Fair enough; queue the snippet:</p>
<blockquote><p>// LCD sandbox<br />
// http://swantron.com<br />
// 2011</p>
<p>#include <LiquidCrystal.h></p>
<p>// **Define pins**<br />
// LCD RS &#8211; pin 12<br />
// LCD R/W &#8211; pin 11<br />
// LCD ENABLE &#8211; pin 10<br />
// LCD BACK+ &#8211; pin 13<br />
// LCD DATA4 &#8211; pin 5<br />
// LCD DATA5 &#8211; pin 4<br />
// LCD DATA6 &#8211; pin 3<br />
// LCD DATA7 &#8211; pin 2<br />
// LCD VSS, CONTRAST,  BACK- &#8211; ground</p>
<p>LiquidCrystal lcd(12, 11, 10, 5, 4, 3, 2);</p>
<p>int backLight = 13;    // Define pin for backlight</p>
<p>void setup()<br />
{<br />
  pinMode(backLight, OUTPUT);<br />
  digitalWrite(backLight, HIGH); // Backlight level (LOW / HIGH)<br />
  lcd.begin(20,4);               // (Columbs, Rows)<br />
  lcd.clear();                   // Clear screen<br />
  lcd.setCursor(0,0);            // Move cursor, print<br />
  lcd.print(&#8220;liquid      |   swan&#8221;);<br />
  lcd.setCursor(0,1);            // Move cursor, print<br />
  lcd.print(&#8220;crystal     |   tron&#8221;);<br />
  lcd.setCursor(0,2);            // Move cursor, print<br />
  lcd.print(&#8220;display     |    dot&#8221;);<br />
  lcd.setCursor(0,3);            // Move cursor, print<br />
  lcd.print(&#8220;(FTW)       |    com&#8221;);<br />
}</p>
<p>void loop()<br />
{<br />
}</p></blockquote>
<p>That is that.  Again, the potentials for this sucker are vast.  I would like to to let this rip with my PING sensor, but need to throw some more effort towards the IOIO.  Java schmava.  Stay tuned for a bad assed project of some nature&#8230;even plan B is pretty awesome these days.  </p>
]]></content:encoded>
			<wfw:commentRss>http://swantron.com/easy-lcd-arduino-display/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>LED&#8230;Matrix or Cube?</title>
		<link>http://swantron.com/led-matrix-or-cube/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=led-matrix-or-cube</link>
		<comments>http://swantron.com/led-matrix-or-cube/#comments</comments>
		<pubDate>Fri, 06 May 2011 18:32:42 +0000</pubDate>
		<dc:creator>Joseph Swanson</dc:creator>
				<category><![CDATA[imgz]]></category>
		<category><![CDATA[Arduino]]></category>
		<category><![CDATA[Cube]]></category>
		<category><![CDATA[LED]]></category>
		<category><![CDATA[LEDs]]></category>
		<category><![CDATA[Matrix]]></category>
		<category><![CDATA[Projects]]></category>

		<guid isPermaLink="false">http://swantron.com/?p=3468</guid>
		<description><![CDATA[They&#8217;ve arrived&#8230; 125 white LEDs. My first thought is 5*5*5 LED cube, powered by the Arduino. I am also thinking that a 6*20 LED matrix would be pretty slick. Either way, my soldering skillz will be put to the test, &#8230; <a href="http://swantron.com/led-matrix-or-cube/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>They&#8217;ve arrived&#8230;</p>
<div id="attachment_3469" class="wp-caption aligncenter" style="width: 580px"><a href="http://swantron.com/wp-content/uploads/2011/05/white-led.jpg"><img src="http://swantron.com/wp-content/uploads/2011/05/white-led.jpg" alt="white leds" title="white-led" width="570" height="263" class="size-full wp-image-3469" /></a><p class="wp-caption-text">nearly a gross</p></div>
<p>125 white LEDs.  My first thought is 5*5*5 LED cube, powered by the Arduino.  I am also thinking that a 6*20 LED matrix would be pretty slick.  Either way, my soldering skillz will be put to the test, and awesomeness will surely ensue.  </p>
]]></content:encoded>
			<wfw:commentRss>http://swantron.com/led-matrix-or-cube/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>DIY Minority Report</title>
		<link>http://swantron.com/diy-minority-report/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=diy-minority-report</link>
		<comments>http://swantron.com/diy-minority-report/#comments</comments>
		<pubDate>Tue, 19 Apr 2011 18:34:48 +0000</pubDate>
		<dc:creator>Joseph Swanson</dc:creator>
				<category><![CDATA[Arduino]]></category>
		<category><![CDATA[HoF]]></category>
		<category><![CDATA[how2]]></category>
		<category><![CDATA[Awesome]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[Duemilanove]]></category>
		<category><![CDATA[Home Automation]]></category>
		<category><![CDATA[How-To]]></category>
		<category><![CDATA[Minority Report]]></category>
		<category><![CDATA[Ping)))]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Project]]></category>
		<category><![CDATA[Snippet]]></category>
		<category><![CDATA[Ultrasonic]]></category>
		<category><![CDATA[Video]]></category>
		<category><![CDATA[Vids]]></category>

		<guid isPermaLink="false">http://swantron.com/?p=3405</guid>
		<description><![CDATA[Spoiler1: This is awesome. Spoiler2: I&#8217;ve never seen Minority Report. I do know that there is some sort of hands free interface, and that is what I have put together. Long story short, I have extended upon my PING))) project &#8230; <a href="http://swantron.com/diy-minority-report/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Spoiler1:  This is awesome.<br />
Spoiler2:  I&#8217;ve never seen Minority Report.  </p>
<p>I do know that there is some sort of hands free interface, and that is what I have put together. </p>
<div id="attachment_3406" class="wp-caption aligncenter" style="width: 580px"><a href="http://swantron.com/wp-content/uploads/2011/04/minority-report.jpg"><img src="http://swantron.com/wp-content/uploads/2011/04/minority-report.jpg" alt="minority report" title="minority-report" width="570" height="320" class="size-full wp-image-3406" /></a><p class="wp-caption-text">+1 dizzy</p></div>
<p>Long story short, I have extended upon my PING))) project to include some sweet touchless home automation.  I have the ultrasonic sensor interfacing with my garage door and a lamp, utilizing a servo and a PowerSwitch Tail, respectively.</p>
<p>Hit the bump for an awesome video of this thing in action, and for my spippet.</p>
<p><span id="more-3405"></span> </p>
<p>*Video contains a rare thumbs up from the author*</p>
<p><iframe title="YouTube video player" width="570" height="458" src="http://www.youtube.com/embed/sdRrRXs33wo" frameborder="0" allowfullscreen></iframe></p>
<p>Snippet?  Oh, INDEED&#8230;</p>
<blockquote><p>//DIY Minority Report</p>
<p>// Joseph Swanson | 2011<br />
// http://swantron.com</p>
<p>// Setup<br />
// LEDs connected to pins 11, 2-5<br />
// Ping))) sensor signal to pin 7<br />
// Servo signal to pin 10<br />
// PowerSwitch Tail to pin 13<br />
// Ping))) +, servo + to 5V<br />
// Ground the shit out of everything</p>
<p>#include <Servo.h></p>
<p>Servo myservo; </p>
<p>int pos = 0;</p>
<p>// Pin assignment<br />
const int ledPin1 =  11;<br />
const int ledPin2 =  2;<br />
const int ledPin3 =  3;<br />
const int ledPin4 =  4;<br />
const int ledPin5 =  5;<br />
const int pingPin =  7;<br />
const int lampPin = 13;</p>
<p>// Create variables to store LED states / lamp state<br />
int ledState1 = LOW;<br />
int ledState2 = LOW;<br />
int ledState3 = LOW;<br />
int ledState4 = LOW;<br />
int ledState5 = LOW;<br />
int lampState = LOW;<br />
void setup() {</p>
<p>// Servo pin definition<br />
myservo.attach(10);</p>
<p>//Define pins 1-5, lamp pin as output<br />
pinMode(ledPin1, OUTPUT);<br />
pinMode(ledPin2, OUTPUT);<br />
pinMode(ledPin3, OUTPUT);<br />
pinMode(ledPin4, OUTPUT);<br />
pinMode(ledPin5, OUTPUT);<br />
pinMode(lampPin, OUTPUT);<br />
}<br />
void loop()<br />
{<br />
// Reset LEDs levels to low to begin loop<br />
  ledState1 = LOW;<br />
  ledState2 = LOW;<br />
  ledState3 = LOW;<br />
  ledState4 = LOW;<br />
  ledState5 = LOW;<br />
// Reset Servo position to initial location<br />
  pos = 0;</p>
<p>// Set duration variable<br />
  long duration, cm;</p>
<p>// Loop section for ping signal pin&#8230;start as output<br />
  pinMode(pingPin, OUTPUT);<br />
  digitalWrite(pingPin, LOW);<br />
  delayMicroseconds(2);<br />
  digitalWrite(pingPin, HIGH);<br />
  delayMicroseconds(5);<br />
  digitalWrite(pingPin, LOW);</p>
<p>// Listen with same pin<br />
  pinMode(pingPin, INPUT);<br />
  duration = pulseIn(pingPin, HIGH);</p>
<p>// Convert time to a distance<br />
  cm = microsecondsToCentimeters(duration);</p>
<p>// Configure this for LED sensitivity<br />
  delay(100); </p>
<p>// March through cm values&#8230;set levels where appropriate<br />
  if (cm < 95) {<br />
    ledState1 = HIGH;}</p>
<p>  if (cm < 60) {<br />
    ledState2 = HIGH;}  </p>
<p>  if (cm < 40) {<br />
    ledState3 = HIGH;}</p>
<p>  if (cm < 25) {<br />
    ledState4 = HIGH;}   </p>
<p>  if (cm < 10) {<br />
    ledState5 = HIGH;}</p>
<p>  if (cm < 40 &#038;&#038; cm >= 30 ) {<br />
    lampState = HIGH;}</p>
<p>  if (cm < 25 &#038;&#038; cm >= 15 ) {<br />
    lampState = LOW; }</p>
<p>  if (cm < 10) {<br />
    pos =( pos + 14 ); }</p>
<p>// fire all LED values...fire servo...fire lamp<br />
    digitalWrite(ledPin1, ledState1);<br />
    digitalWrite(ledPin2, ledState2);<br />
    digitalWrite(ledPin3, ledState3);<br />
    digitalWrite(ledPin4, ledState4);<br />
    digitalWrite(ledPin5, ledState5);<br />
    digitalWrite(lampPin, lampState);<br />
    myservo.write(pos);</p>
<p>  delay(100);    </p>
<p>}<br />
long microsecondsToCentimeters(long microseconds)<br />
{<br />
  // 340 meters per second...do some math<br />
  return microseconds / 29 / 2;<br />
}
</p></blockquote>
<p>As the code implies, I have set this thing up to look for pings in particular regions.  The LEDs indicate where I am at, and the rest sort of plays out from there.  The lamp is set up as a switch, with ON and OFF having separate regions.  The servo/g-door opener is a simple ON when the region is occupied&#8230;similar to my previous setup.  </p>
<p>Pretty flipping sweet.  As usual, send any feedback my way.  This is still in the proof-of-concept mode, and will likely get scrapped for parts soon.  Not to mention, Katie will probably want to be able to use the garage door opener, which I disconnected to string that wire that I have running manually to the servo.  Be prompt.  </p>
]]></content:encoded>
			<wfw:commentRss>http://swantron.com/diy-minority-report/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Garage Door Hack</title>
		<link>http://swantron.com/garage-door-hack/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=garage-door-hack</link>
		<comments>http://swantron.com/garage-door-hack/#comments</comments>
		<pubDate>Thu, 14 Apr 2011 04:19:53 +0000</pubDate>
		<dc:creator>Joseph Swanson</dc:creator>
				<category><![CDATA[Arduino]]></category>
		<category><![CDATA[HoF]]></category>
		<category><![CDATA[100% Awesome]]></category>
		<category><![CDATA[Awesome]]></category>
		<category><![CDATA[Duemilanove]]></category>
		<category><![CDATA[LED]]></category>
		<category><![CDATA[LEDs]]></category>
		<category><![CDATA[Ping)))]]></category>
		<category><![CDATA[Project]]></category>
		<category><![CDATA[Sensor]]></category>
		<category><![CDATA[Servo]]></category>
		<category><![CDATA[Ultrasonic]]></category>

		<guid isPermaLink="false">http://swantron.com/?p=3401</guid>
		<description><![CDATA[Introducing Open-er-o-matic 3000. OOM3K. My finest project to date. I have my Arduino poking around with a PING))) sensor, a servo, some LEDs, and best of all&#8230;my garage door opener. End result: some Star Trek-ass shit. Check this footage of &#8230; <a href="http://swantron.com/garage-door-hack/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Introducing Open-er-o-matic 3000.  OOM3K.  My finest project to date.  I have my Arduino poking around with a PING))) sensor, a servo, some LEDs, and best of all&#8230;my garage door opener.  End result:  some Star Trek-ass shit.  </p>
<div id="attachment_3402" class="wp-caption aligncenter" style="width: 580px"><a href="http://swantron.com/wp-content/uploads/2011/04/ghetto-fabulus.jpg"><img src="http://swantron.com/wp-content/uploads/2011/04/ghetto-fabulus.jpg" alt="hit the vid" title="ghetto-fabulus" width="570" height="333" class="size-full wp-image-3402" /></a><p class="wp-caption-text">Ronco alert</p></div>
<p>Check this footage of the OOM3K in action.  Here, I had it configured to open the door when the ultrasonic sensor echoes off of something within 8 cm&#8230;</p>
<p>After the bump, of course</p>
<p><span id="more-3401"></span><br />
<iframe title="YouTube video player" width="570" height="458" src="http://www.youtube.com/embed/vNHdoPARyLs" frameborder="0" allowfullscreen></iframe></p>
<p>Not only is this thing awesome, but you can get all sorts of clear looks at my trusty Ronco Showtime rotisserie oven.  Yard bird is a big hit at the old Swanson place.  </p>
<p>There is not much to this code&#8230;I built it on top of the LED binary project code.  Prepare for a bitchin&#8217; snippet.  </p>
<blockquote><p>//Open-er-o-matic 3000</p>
<p>// Joseph Swanson | 2011<br />
// http://swantron.com</p>
<p>// Setup<br />
// LEDs connected to pins 11, 2-5<br />
// Ping))) sensor signal to pin 7<br />
// Servo signal to pin 10<br />
// Ping))) +, servo + to 5V<br />
// Ground the shit out of everything</p>
<p>#include <Servo.h></p>
<p>Servo myservo; </p>
<p>int pos = 0;</p>
<p>// Pin assignment<br />
const int ledPin1 =  11;<br />
const int ledPin2 =  2;<br />
const int ledPin3 =  3;<br />
const int ledPin4 =  4;<br />
const int ledPin5 =  5;<br />
const int pingPin = 7;</p>
<p>// Create variables to store LED states<br />
int ledState1 = LOW;<br />
int ledState2 = LOW;<br />
int ledState3 = LOW;<br />
int ledState4 = LOW;<br />
int ledState5 = LOW;</p>
<p>void setup() {</p>
<p>myservo.attach(10);</p>
<p>//Define pins 1-5 as output<br />
pinMode(ledPin1, OUTPUT);<br />
pinMode(ledPin2, OUTPUT);<br />
pinMode(ledPin3, OUTPUT);<br />
pinMode(ledPin4, OUTPUT);<br />
pinMode(ledPin5, OUTPUT);<br />
}<br />
void loop()<br />
{<br />
 // Reset LEDs levels to low to begin loop<br />
  ledState1 = LOW;<br />
  ledState2 = LOW;<br />
  ledState3 = LOW;<br />
  ledState4 = LOW;<br />
  ledState5 = LOW;<br />
  pos = 0;</p>
<p>// Set duration variable<br />
  long duration, inches, cm;</p>
<p>// Loop section for ping signal pin&#8230;start as output<br />
  pinMode(pingPin, OUTPUT);<br />
  digitalWrite(pingPin, LOW);<br />
  delayMicroseconds(2);<br />
  digitalWrite(pingPin, HIGH);<br />
  delayMicroseconds(5);<br />
  digitalWrite(pingPin, LOW);</p>
<p>// Listen with same pin<br />
  pinMode(pingPin, INPUT);<br />
  duration = pulseIn(pingPin, HIGH);</p>
<p>// Convert time to a distance<br />
  inches = microsecondsToInches(duration);<br />
  cm = microsecondsToCentimeters(duration);</p>
<p>// Configure this for LED sensitivity<br />
  delay(500); </p>
<p>// March through cm values&#8230;output LEDs an servo<br />
  if (cm < 80) {<br />
    ledState1 = HIGH;}</p>
<p>  if (cm < 64) {<br />
    ledState2 = HIGH;}   </p>
<p>  if (cm < 48) {<br />
    ledState3 = HIGH;}</p>
<p>  if (cm < 32) {<br />
    ledState4 = HIGH;}</p>
<p>  if (cm < 16) {<br />
    ledState5 = HIGH; }</p>
<p>  if (cm < 16) {<br />
    pos =( pos + 14 ); }</p>
<p>// fire all LED values...fire servo<br />
    digitalWrite(ledPin1, ledState1);<br />
    digitalWrite(ledPin2, ledState2);<br />
    digitalWrite(ledPin3, ledState3);<br />
    digitalWrite(ledPin4, ledState4);<br />
    digitalWrite(ledPin5, ledState5);<br />
    myservo.write(pos);</p>
<p>  delay(100);    </p>
<p>}<br />
long microsecondsToInches(long microseconds)<br />
{<br />
  // 1130 feet per second...transofrm inches<br />
  return microseconds / 74 / 2;<br />
}<br />
long microsecondsToCentimeters(long microseconds)<br />
{<br />
  // 340 meters per second...transform cm<br />
  return microseconds / 29 / 2;<br />
}
</p></blockquote>
<p>I hope you enjoyed this one.  I had a fun time with this piece of crap.  Plus, it has given me some ideas of how to extend this setup into something more refined.  Spoiler:  more awesome.  </p>
]]></content:encoded>
			<wfw:commentRss>http://swantron.com/garage-door-hack/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
		<item>
		<title>Ultrasonic Distance Sensing</title>
		<link>http://swantron.com/ultrasonic-distance-sensing/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=ultrasonic-distance-sensing</link>
		<comments>http://swantron.com/ultrasonic-distance-sensing/#comments</comments>
		<pubDate>Wed, 13 Apr 2011 01:09:29 +0000</pubDate>
		<dc:creator>Joseph Swanson</dc:creator>
				<category><![CDATA[Arduino]]></category>
		<category><![CDATA[Awesome]]></category>
		<category><![CDATA[Duemilanove]]></category>
		<category><![CDATA[FTW]]></category>
		<category><![CDATA[LED]]></category>
		<category><![CDATA[LEDs]]></category>
		<category><![CDATA[Ping Pong]]></category>
		<category><![CDATA[Ping)))]]></category>
		<category><![CDATA[Project]]></category>
		<category><![CDATA[Snippet]]></category>
		<category><![CDATA[Ultrasonic]]></category>
		<category><![CDATA[Video]]></category>

		<guid isPermaLink="false">http://swantron.com/?p=3396</guid>
		<description><![CDATA[I really should have a running list of these mini-projects I have been cranking out. This one: using a PING))) sensor from Parallax Inc to drive LEDs for a set of values. Sounds boring, but it is sort of cool. &#8230; <a href="http://swantron.com/ultrasonic-distance-sensing/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I really should have a running list of these mini-projects I have been cranking out.  This one:  using a PING))) sensor from Parallax Inc to drive LEDs for a set of values.  Sounds boring, but it is sort of cool.   Oh cool.  </p>
<p>Picture time:</p>
<div id="attachment_3397" class="wp-caption aligncenter" style="width: 580px"><a href="http://swantron.com/wp-content/uploads/2011/04/ultrasonic.jpg"><img src="http://swantron.com/wp-content/uploads/2011/04/ultrasonic.jpg" alt="doing work at work, again" title="ultrasonic" width="570" height="320" class="size-full wp-image-3397" /></a><p class="wp-caption-text">doing work at work, again</p></div>
<p>Follow the bump for a vid / snippet<br />
<span id="more-3396"></span><br />
Video time:</p>
<p><iframe title="YouTube video player" width="570" height="458" src="http://www.youtube.com/embed/12JpMXZUJpM" frameborder="0" allowfullscreen></iframe></p>
<p>Snippet time:</p>
<blockquote><p>//Ping LED Levels</p>
<p>// Joseph Swanson | 2011<br />
// http://swantron.com</p>
<p>// Setup<br />
// LEDs connected to pins 11, 2-6<br />
// Ping))) sensor signal to pin 7<br />
// Ping))) + to 5V, &#8211; to ground</p>
<p>// Pin assignment<br />
const int ledPin1 =  11;<br />
const int ledPin2 =  2;<br />
const int ledPin3 =  3;<br />
const int ledPin4 =  4;<br />
const int ledPin5 =  5;<br />
const int ledPin6 =  6;     </p>
<p>const int pingPin = 7;</p>
<p>// Create variables to store LED states<br />
int ledState1 = LOW;<br />
int ledState2 = LOW;<br />
int ledState3 = LOW;<br />
int ledState4 = LOW;<br />
int ledState5 = LOW;<br />
int ledState6 = LOW;</p>
<p>void setup() {</p>
<p>// Start serial </p>
<p>  Serial.begin(9600);</p>
<p>//Define pins 1-6 as output<br />
  pinMode(ledPin1, OUTPUT);<br />
  pinMode(ledPin2, OUTPUT);<br />
  pinMode(ledPin3, OUTPUT);<br />
  pinMode(ledPin4, OUTPUT);<br />
  pinMode(ledPin5, OUTPUT);<br />
  pinMode(ledPin6, OUTPUT); </p>
<p>}<br />
void loop()<br />
{</p>
<p>// Reset LEDs levels to low to begin loop</p>
<p> ledState1 = LOW;<br />
 ledState2 = LOW;<br />
 ledState3 = LOW;<br />
 ledState4 = LOW;<br />
 ledState5 = LOW;<br />
 ledState6 = LOW; </p>
<p>// Set duration variable</p>
<p> long duration, inches, cm;</p>
<p>// Loop section for ping signal pin&#8230;start as output<br />
  pinMode(pingPin, OUTPUT);<br />
  digitalWrite(pingPin, LOW);<br />
  delayMicroseconds(2);<br />
  digitalWrite(pingPin, HIGH);<br />
  delayMicroseconds(5);<br />
  digitalWrite(pingPin, LOW);</p>
<p>// Listen with same pin<br />
   pinMode(pingPin, INPUT);<br />
   duration = pulseIn(pingPin, HIGH);</p>
<p>// Converttime to a distance</p>
<p>  inches = microsecondsToInches(duration);<br />
  cm = microsecondsToCentimeters(duration);</p>
<p>// Write to serial out<br />
  Serial.print(inches);<br />
  Serial.print(&#8220;in, &#8220;);<br />
  Serial.print(cm);<br />
  Serial.print(&#8220;cm&#8221;);<br />
  Serial.println();</p>
<p>// Configure this for fine tuning&#8230; 50 is noisy<br />
  delay(75); </p>
<p>// March through cm values&#8230;output<br />
  if (cm < 128) {</p>
<p>      ledState1 = HIGH;}</p>
<p>  if (cm < 64) {</p>
<p>      ledState2 = HIGH;}</p>
<p>  if (cm < 32) {</p>
<p>      ledState3 = HIGH;}</p>
<p>  if (cm < 16) {</p>
<p>      ledState4 = HIGH;}</p>
<p>  if (cm < <img src='http://swantron.com/wp-includes/images/smilies/icon_cool.gif' alt='8)' class='wp-smiley' /> {</p>
<p>      ledState5 = HIGH; }</p>
<p>  if (cm < 4) {</p>
<p>      ledState6 = HIGH;}</p>
<p>// fire all LED values<br />
    digitalWrite(ledPin1, ledState1);<br />
    digitalWrite(ledPin2, ledState2);<br />
    digitalWrite(ledPin3, ledState3);<br />
    digitalWrite(ledPin4, ledState4);<br />
    digitalWrite(ledPin5, ledState5);<br />
    digitalWrite(ledPin6, ledState6);</p>
<p>}<br />
long microsecondsToInches(long microseconds)<br />
{<br />
  // 1130 feet per second...transofrm inches</p>
<p>  return microseconds / 74 / 2;<br />
}</p>
<p>long microsecondsToCentimeters(long microseconds)<br />
{<br />
  // 340 meters per second...transform cm<br />
  return microseconds / 29 / 2;<br />
}</p></blockquote>
<p>Synopsis time:  </p>
<p>The code fires the ultrasonic sensor via a digital pin, listens via the same pin, does a little math to transform times to distances using the speed of sound, takes the distances and writes to various LEDs depending upon the value returned.  </p>
<p>Think of the backup collision sensors that ship with many new vehicles&#8230;same deal.  Instead of firing a speaker, I have fired 6 lights instead&#8230;more accurate, FTW!</p>
<p>I sort of want to mount this bad boy on my Trail-90.  Or my Yukon&#8230;that would be ghetto goddamn fabulous.  For real.  </p>
<p>Thanks for reading.  Happy Tuesday.  </p>
]]></content:encoded>
			<wfw:commentRss>http://swantron.com/ultrasonic-distance-sensing/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

