<?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>eclecticc &#187; relay</title>
	<atom:link href="http://eclecti.cc/tag/relay/feed" rel="self" type="application/rss+xml" />
	<link>http://eclecti.cc</link>
	<description></description>
	<lastBuildDate>Sun, 20 May 2012 14:28:21 +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>Walk This Way: Pedestrian Traffic Light Status Indicator</title>
		<link>http://eclecti.cc/hardware/walk-this-way-pedestrian-traffic-light-status-indicator</link>
		<comments>http://eclecti.cc/hardware/walk-this-way-pedestrian-traffic-light-status-indicator#comments</comments>
		<pubDate>Mon, 15 Feb 2010 01:20:24 +0000</pubDate>
		<dc:creator>nrp</dc:creator>
				<category><![CDATA[Hardware]]></category>
		<category><![CDATA[arduino]]></category>
		<category><![CDATA[overkill]]></category>
		<category><![CDATA[relay]]></category>

		<guid isPermaLink="false">http://eclecti.cc/?p=475</guid>
		<description><![CDATA[A recent Slashdot post about Weird Stuff Warehouse reminded me that they carry cheap pedestrian traffic lights. I&#8217;d been meaning to pick one up to use as a completely overkill status indicator at work.  I managed to get this one for $10. It is a GE PS7-CFC1-01A that uses LEDs and looks new, but was [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://eclecti.cc/files/2010/02/dontwalk.jpg"><img class="alignnone size-large wp-image-473" title="That's a disassembled Boogie Board in the background.  More on that later." src="http://eclecti.cc/files/2010/02/dontwalk-700x525.jpg" alt="Traffic Sign Status Indicator" width="700" height="525" /></a></p>
<p>A recent Slashdot post about <a href="http://www.weirdstuff.com/">Weird Stuff Warehouse</a> reminded me that they carry cheap pedestrian traffic lights.  I&#8217;d been meaning to pick one up to use as a completely overkill status indicator at work.  I managed to get this one for $10.  It is a <a href="http://www.econolite.com/docs/accessories/ge_16x18_ped_module.pdf">GE PS7-CFC1-01A</a> that uses LEDs and looks new, but was presumably dumped by the original owner because it is a basic stop/go light without a countdown timer or accessibility features.</p>
<p><a href="http://eclecti.cc/files/2010/02/powersupplies.jpg"><img class="alignnone size-large wp-image-474" title="It's just asking to be replaced by a Mooninite." src="http://eclecti.cc/files/2010/02/powersupplies-700x525.jpg" alt="Dual Power Supplies" width="700" height="525" /></a></p>
<p>There were three mystery wires coming out of the back to interface it, so I cracked it open to see what was inside.  The stop hand and walk person have independent AC-DC power supplies.  Both halves share the white neutral wire, while each has a live wire of its own.  The idea is to have the common line always connected to neutral while switching the hot line to whichever half you want lit up.  Note that there is some additional circuitry on the right and an optoisolator connecting the halves.  I believe this sign was designed such that if you attempt to power on both halves simultaneously, it will fail safe and light only the stop half.</p>
<p><a href="http://eclecti.cc/files/2010/02/relay.jpg"><img class="alignnone size-large wp-image-476" title="Try this at home, but follow the one hand rule when playing with household AC." src="http://eclecti.cc/files/2010/02/relay-700x525.jpg" alt="Traffic Sign Relay" width="700" height="525" /></a></p>
<p>People often get their hearts broken on Valentine&#8217;s Day.  Frying mine by playing with 120v AC is one way to do that.  Kidding. Household AC is fine to tinker with as long as you&#8217;re careful.  I built the circuit from the <a href="http://www.arduino.cc/playground/uploads/Main/relays.pdf">Arduino Relay</a> guide to do the switching.  I picked up a SPDT 5v power relay to make it easy to run off of the Arduino.  The transistor is still necessary because the AVR can&#8217;t drive the 100+mA the relay needs to switch itself.  I used an ATX power supply socket for convenience, rather than cutting a cable and using that.  The neutral line from the socket is soldered to the neutral line on the sign.  Each of the hot lines from the sign is connected to one of the relay throw positions, while the hot line from the socket is connected to the relay pole.  Thus, toggling a pin high or low on the Arduino will flip the hot line from one half to the other, powering either the stop or go sign on.  The project in total cost less than $20.  It probably would have been under $15, but Radioshack is the only electronics store open on Sundays.</p>
<p>The code on the Arduino end is pretty simple.  It just reads a character off the serial port and flips the relay one way or the other.</p>

<div class="wp_syntax"><div class="code"><pre class="c" style="font-family:monospace;"><span style="color: #339933;">#define RELAY_PIN 13</span>
bool state<span style="color: #339933;">;</span>
&nbsp;
<span style="color: #993333;">void</span> setup<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
  Serial.<span style="color: #202020;">begin</span><span style="color: #009900;">&#40;</span><span style="color: #0000dd;">9600</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  state <span style="color: #339933;">=</span> LOW<span style="color: #339933;">;</span>
  pinMode<span style="color: #009900;">&#40;</span>RELAY_PIN<span style="color: #339933;">,</span> OUTPUT<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  digitalWrite<span style="color: #009900;">&#40;</span>RELAY_PIN<span style="color: #339933;">,</span> state<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #993333;">void</span> loop<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
  <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>Serial.<span style="color: #202020;">available</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    byte in <span style="color: #339933;">=</span> Serial.<span style="color: #202020;">read</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>in <span style="color: #339933;">==</span> <span style="color: #ff0000;">'0'</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      state <span style="color: #339933;">=</span> LOW<span style="color: #339933;">;</span>
      Serial.<span style="color: #202020;">println</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;Switching relay to Stop.&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>in <span style="color: #339933;">==</span> <span style="color: #ff0000;">'1'</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      state <span style="color: #339933;">=</span> HIGH<span style="color: #339933;">;</span>
      Serial.<span style="color: #202020;">println</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;Switching relay to Go.&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
    digitalWrite<span style="color: #009900;">&#40;</span>RELAY_PIN<span style="color: #339933;">,</span> state<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>The computer end can be whatever you want it to be.  For example, in Python, you can use <a href="http://pyserial.sourceforge.net">pySerial</a> as follows.</p>

<div class="wp_syntax"><div class="code"><pre class="python" style="font-family:monospace;"><span style="color: #66cc66;">&gt;&gt;&gt;</span> <span style="color: #ff7700;font-weight:bold;">import</span> serial
<span style="color: #66cc66;">&gt;&gt;&gt;</span> sign = serial.<span style="color: black;">Serial</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'/dev/ttyUSB0'</span>,<span style="color: #ff4500;">9600</span><span style="color: black;">&#41;</span>
<span style="color: #66cc66;">&gt;&gt;&gt;</span> sign.<span style="color: black;">write</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'0'</span><span style="color: black;">&#41;</span>
<span style="color: #66cc66;">&gt;&gt;&gt;</span> sign.<span style="color: black;">write</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'1'</span><span style="color: black;">&#41;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://eclecti.cc/hardware/walk-this-way-pedestrian-traffic-light-status-indicator/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

<!-- Dynamic Page Served (once) in 0.270 seconds -->

