<?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>Awooga!!! &#187; crafts</title>
	<atom:link href="http://awooga.nl/tag/crafts/feed" rel="self" type="application/rss+xml" />
	<link>http://awooga.nl</link>
	<description>how hard can it be?</description>
	<lastBuildDate>Tue, 05 Apr 2011 12:46:28 +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>Droidock</title>
		<link>http://awooga.nl/droidock</link>
		<comments>http://awooga.nl/droidock#comments</comments>
		<pubDate>Thu, 03 Feb 2011 22:28:52 +0000</pubDate>
		<dc:creator>Q</dc:creator>
				<category><![CDATA[blog]]></category>
		<category><![CDATA[android]]></category>
		<category><![CDATA[apple]]></category>
		<category><![CDATA[chargers]]></category>
		<category><![CDATA[crafts]]></category>
		<category><![CDATA[desktop]]></category>
		<category><![CDATA[dock]]></category>
		<category><![CDATA[gadgets]]></category>
		<category><![CDATA[hacking]]></category>
		<category><![CDATA[iphone]]></category>
		<category><![CDATA[modaco]]></category>
		<category><![CDATA[modding]]></category>
		<category><![CDATA[orange]]></category>
		<category><![CDATA[san francisco]]></category>
		<category><![CDATA[usb]]></category>
		<category><![CDATA[work]]></category>
		<category><![CDATA[zte blade]]></category>

		<guid isPermaLink="false">http://awooga.nl/?p=527</guid>
		<description><![CDATA[About two weeks ago, I finally bit the bullet and retired my trusty iPhone 3G, and went to the dark bright side, with an Orange San Francisco (also known as the ZTE Blade). At £99 (including a compulsory £10 Orange topup) it can be SIM unlocked for free and flashed to Froyo 2.2 with a [...]]]></description>
			<content:encoded><![CDATA[<p>About two weeks ago, I finally bit the bullet and retired my trusty <a href="/officially-sad-or-officially-geek" class="liinternal">iPhone 3G</a>, and went to the <del>dark</del> bright side, with an <a href="http://newsroom.orange.co.uk/2010/09/21/orange-brings-android-to-the-masses-with-the-launch-of-san-francisco/" target="_blank" class="liexternal">Orange San Francisco</a> (also known as the <a href="http://wwwen.zte.com.cn/en/press_center/news/201011/t20101108_194339.html" target="_blank" class="liexternal">ZTE Blade</a>).  At £99 (including a compulsory £10 Orange topup) it can be <a href="http://arrtoo.x10.mx/unlockBlade.php" target="_blank" class="liexternal">SIM unlocked for free</a> and flashed to <a href="http://en.wikipedia.org/wiki/Android_%28operating_system%29" target="_blank" class="liexternal">Froyo 2.2</a> with a variety of <a href="http://android.modaco.com/content/zte-blade-roms-rom-customisation/329856/02-feb-roms-current-known-available-roms-for-the-zte-blade/" target="_blank" class="liexternal">ROMs</a>.</p>
<p>But despite a incredible take up by punters everywhere, the lack of handset accessories is frustrating.  Until recently we couldn&#8217;t even get an OSF specific screen protector, let alone a <a href="http://android.modaco.com/content/zte-blade-blade-modaco-com/319419/suitable-silicone-case-screen-protector-for-san-francisco-by-orange/" target="_blank" class="liexternal">protective cover</a>.  And still we can not buy a desktop charger that fits!</p>
<p>And so, when a colleague was unpacking a toner cartridge and I spotted the polystyrene padding material, I thought, why not bodge one myself?</p>
<p><a href="/gallery/modding/droidock/Photo+Feb+03_+9+36+47+PM.jpg.html" class="liimagelink"><img src="/g/image/37850-4/Photo+Feb+03_+9+36+47+PM.jpg" alt="" class="aligncenter" /></a></p>
<p>15 minutes (and a sharp blade) later, and voila!</p>
<p><a href="/gallery/modding/droidock/Photo+Feb+03_+9+36+30+PM.jpg.html" class="liimagelink"><img src="/g/image/37844-3/Photo+Feb+03_+9+36+30+PM.jpg" alt="" /></a> <a href="/gallery/modding/droidock/Photo+Feb+03_+9+37+03+PM.jpg.html" class="liimagelink"><img src="/g/image/37853-3/Photo+Feb+03_+9+37+03+PM.jpg" alt="" /></a> <a href="/gallery/modding/droidock/Photo+Feb+03_+9+37+19+PM.jpg.html" class="liimagelink"><img src="/g/image/37857-3/Photo+Feb+03_+9+37+19+PM.jpg" alt="" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://awooga.nl/droidock/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Ooh Arr-duino</title>
		<link>http://awooga.nl/ooh-arr-duino</link>
		<comments>http://awooga.nl/ooh-arr-duino#comments</comments>
		<pubDate>Thu, 03 Feb 2011 14:45:38 +0000</pubDate>
		<dc:creator>Q</dc:creator>
				<category><![CDATA[blog]]></category>
		<category><![CDATA[arduino]]></category>
		<category><![CDATA[chargers]]></category>
		<category><![CDATA[ciseco]]></category>
		<category><![CDATA[crafts]]></category>
		<category><![CDATA[dfrobot]]></category>
		<category><![CDATA[ebay]]></category>
		<category><![CDATA[electricity]]></category>
		<category><![CDATA[gadgets]]></category>
		<category><![CDATA[hacking]]></category>
		<category><![CDATA[i2c]]></category>
		<category><![CDATA[lcd]]></category>
		<category><![CDATA[led]]></category>
		<category><![CDATA[makezine]]></category>
		<category><![CDATA[maplin]]></category>
		<category><![CDATA[modding]]></category>
		<category><![CDATA[relay]]></category>
		<category><![CDATA[shield]]></category>
		<category><![CDATA[socket]]></category>
		<category><![CDATA[timer]]></category>
		<category><![CDATA[usb]]></category>

		<guid isPermaLink="false">http://awooga.nl/?p=495</guid>
		<description><![CDATA[Santa this year was very generous to my son and gifted him with a Maverick Atom XT RTR 1/18 Electric 4WD Truggy but failed to mention that the batteries that came with it could only be left in the charger for 6 hours, no longer. With grave warnings about explosions and fire, I tried to [...]]]></description>
			<content:encoded><![CDATA[<p>Santa this year was very generous to my son and gifted him with a <a href="http://www.hpiracing.co.uk/piw.php?partNo=MV12102" target="_blank" class="liexternal">Maverick Atom XT RTR 1/18 Electric 4WD Truggy</a> but failed to mention that the batteries that came with it could only be left in the charger for 6 hours, no longer.  With grave warnings about explosions and fire, I tried to find an egg-timer on a socket kind of solution, but could not find anything that would go beyond 4 hours.</p>
<p>So what is a <a href="http://en.wikipedia.org/wiki/Tinkerer" target="_blank" class="liexternal">tinkerer</a> to do?  He makes one himself! ;)<br />
<br /><br /><center><script type="text/javascript"><!--
google_ad_client = "pub-3248212177098373";
google_ad_slot = "3039514391";
google_ad_width = 468;
google_ad_height = 60;
//--></script>
<script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
</center><br /><br />
A long time ago I bought an <a href="http://arduino.cc/en/Main/ArduinoBoardDuemilanove" target="_blank" class="liexternal">Arduino</a>, but never really got any further with it than a blinking RGB led.  Now I finally found a purpose for it :)  I was going to build an Arduino controlled timer socket!</p>
<p>All I needed now were some kind of relay, some sockets, a few buttons and a way of letting <del>the user</del> my son know what the time was set to and if it was on or not.  I ended up with a <a href="http://www.ciseco.co.uk/content/?p=1515" target="_blank" class="liexternal">Ciseco Arduino Relay Shield</a>, two <a href="http://www.maplin.co.uk/push-to-make-switch-34858" target="_blank" class="liexternal">Maplin push-to-make switches</a>, a <a href="http://www.dfrobot.com/index.php?route=product/product&#038;path=53&#038;product_id=135" target="_blank" class="liexternal">DFRobot I2C 16&#215;2 LCD</a> and a <a href="http://www.maplin.co.uk/mb-plastic-boxes-1676" target="_blank" class="liexternal">Maplin project box</a> big enough to fit it all in</p>
<blockquote><p><b>First a small word of warning.</b>  You are dealing with <b>MAINS voltage</b>, which can be lethal if you fool around.  <b>DO NOT EVER!</b> connect the bits to mains power when parts of it are exposed.  You&#8217;ve been warned</p></blockquote>
<p><a href="/gallery/modding/arduino/DSC04157.JPG.html" class="liimagelink"><img src="/g/image/37596-3/DSC04157.JPG" alt="" /></a> <a href="/gallery/modding/arduino/DSC04158.JPG.html" class="liimagelink"><img src="/g/image/37601-3/DSC04158.JPG" alt="" /></a> <a href="/gallery/modding/arduino/DSC04159.JPG.html" class="liimagelink"><img src="/g/image/37605-3/DSC04159.JPG" alt="" /></a></p>
<p>I started off with a small mockup of materials and then got my trusty Dremel clone out and started cutting away at the project case.</p>
<p><a href="/gallery/modding/arduino/DSC04160.JPG.html" class="liimagelink"><img src="/g/image/37609-3/DSC04160.JPG" alt="" /></a> <a href="/gallery/modding/arduino/DSC04161.JPG.html" class="liimagelink"><img src="/g/image/37613-3/DSC04161.JPG" alt="" /></a></p>
<p>First off is the socket in which the battery charger can be plugged.  A small template on paper is by far the easiest way to make sure you don&#8217;t cut out too much behind the socket</p>
<p><a href="/gallery/modding/arduino/DSC04162.JPG.html" class="liimagelink"><img src="/g/image/37617-3/DSC04162.JPG" alt="" /></a> <a href="/gallery/modding/arduino/DSC04164.JPG.html" class="liimagelink"><img src="/g/image/37625-3/DSC04164.JPG" alt="" /></a> <a href="/gallery/modding/arduino/DSC04165.JPG.html" class="liimagelink"><img src="/g/image/37629-3/DSC04165.JPG" alt="" /></a> <a href="/gallery/modding/arduino/DSC04166.JPG.html" class="liimagelink"><img src="/g/image/37633-3/DSC04166.JPG" alt="" /></a> <a href="/gallery/modding/arduino/DSC04167.JPG.html" class="liimagelink"><img src="/g/image/37637-3/DSC04167.JPG" alt="" /></a> <a href="/gallery/modding/arduino/DSC04168.JPG.html" class="liimagelink"><img src="/g/image/37641-3/DSC04168.JPG" alt="" /></a> <a href="/gallery/modding/arduino/DSC04169.JPG.html" class="liimagelink"><img src="/g/image/37645-3/DSC04169.JPG" alt="" /></a> <a href="/gallery/modding/arduino/DSC04170.JPG.html" class="liimagelink"><img src="/g/image/37649-3/DSC04170.JPG" alt="" /></a></p>
<p>With the socket in place, I created the template for the LCD.  I took my time with this, as I didn&#8217;t want to cut out too much.  A lot of careful sanding ensured that only the black part would be visible, and nothing else.  Then with the help of some small bolts and nuts, I created some spacers, enabling the LCD to sit nicely in the cutout.  Lots of hotglue completes the mounting</p>
<p><a href="/gallery/modding/arduino/DSC04171.JPG.html" class="liimagelink"><img src="/g/image/37653-3/DSC04171.JPG" alt="" /></a> <a href="/gallery/modding/arduino/DSC04172.JPG.html" class="liimagelink"><img src="/g/image/37657-3/DSC04172.JPG" alt="" /></a> <a href="/gallery/modding/arduino/DSC04173.JPG.html" class="liimagelink"><img src="/g/image/37661-3/DSC04173.JPG" alt="" /></a> <a href="/gallery/modding/arduino/DSC04174.JPG.html" class="liimagelink"><img src="/g/image/37665-3/DSC04174.JPG" alt="" /></a> <a href="/gallery/modding/arduino/DSC04175.JPG.html" class="liimagelink"><img src="/g/image/37669-3/DSC04175.JPG" alt="" /></a> <a href="/gallery/modding/arduino/DSC04176.JPG.html" class="liimagelink"><img src="/g/image/37673-3/DSC04176.JPG" alt="" /></a></p>
<p>The buttons only required some measuring to make sure they are neatly symetric and do not interfere with the LCD</p>
<p><a href="/gallery/modding/arduino/DSC04177.JPG.html" class="liimagelink"><img src="/g/image/37677-3/DSC04177.JPG" alt="" /></a> <a href="/gallery/modding/arduino/DSC04178.JPG.html" class="liimagelink"><img src="/g/image/37681-3/DSC04178.JPG" alt="" /></a> <a href="/gallery/modding/arduino/DSC04179.JPG.html" class="liimagelink"><img src="/g/image/37685-3/DSC04179.JPG" alt="" /></a> <a href="/gallery/modding/arduino/DSC04180.JPG.html" class="liimagelink"><img src="/g/image/37689-3/DSC04180.JPG" alt="" /></a> <a href="/gallery/modding/arduino/DSC04182.JPG.html" class="liimagelink"><img src="/g/image/37697-3/DSC04182.JPG" alt="" /></a></p>
<p>All that remains is the IEC socket where the power will go into the project box</p>
<p><a href="/gallery/modding/arduino/DSC04186.JPG.html" class="liimagelink"><img src="/g/image/37713-3/DSC04186.JPG" alt="" /></a> <a href="/gallery/modding/arduino/DSC04187.JPG.html" class="liimagelink"><img src="/g/image/37717-3/DSC04187.JPG" alt="" /></a> <a href="/gallery/modding/arduino/DSC04188.JPG.html" class="liimagelink"><img src="/g/image/37721-3/DSC04188.JPG" alt="" /></a> <a href="/gallery/modding/arduino/DSC04190.JPG.html" class="liimagelink"><img src="/g/image/37729-3/DSC04190.JPG" alt="" /></a></p>
<p>Now with everything in place, all we need to do is connect the components together with some wire using the below schematic</p>
<p><a href="/gallery/modding/arduino/socket-wiring.jpg.html" class="liimagelink"><img src="/g/image/37838-4/socket-wiring.jpg" alt="" class="aligncenter" /></a></p>
<p>Warm up the soldering iron and just follow the diagram.  As my soldering skills are not that great, I also used a bit of heatshrink here and there to make sure that wires could not short on each other :)</p>
<p><a href="/gallery/modding/arduino/DSC04191.JPG.html" class="liimagelink"><img src="/g/image/37733-3/DSC04191.JPG" alt="" /></a> <a href="/gallery/modding/arduino/DSC04192.JPG.html" class="liimagelink"><img src="/g/image/37737-5/DSC04192.JPG" alt="" /></a> <a href="/gallery/modding/arduino/DSC04193.JPG.html" class="liimagelink"><img src="/g/image/37741-3/DSC04193.JPG" alt="" /></a> <a href="/gallery/modding/arduino/DSC04194.JPG.html" class="liimagelink"><img src="/g/image/37745-3/DSC04194.JPG" alt="" /></a> <a href="/gallery/modding/arduino/DSC04195.JPG.html" class="liimagelink"><img src="/g/image/37749-3/DSC04195.JPG" alt="" /></a> <a href="/gallery/modding/arduino/DSC04200.JPG.html" class="liimagelink"><img src="/g/image/37769-5/DSC04200.JPG" alt="" /></a> <a href="/gallery/modding/arduino/DSC04198.JPG.html" class="liimagelink"><img src="/g/image/37761-5/DSC04198.JPG" alt="" /></a></p>
<p>I&#8217;m using an old iPhone charger to power the Arduino as it provides a neat 5V/1A, with a small retractable USB lead with a Type A to B converter.  A quick test of the wiring to make sure it all works as planned</p>
<p><a href="/gallery/modding/arduino/DSC04196.JPG.html" class="liimagelink"><img src="/g/image/37754-6/DSC04196.JPG" alt="" class="aligncenter" /></a></p>
<p>Now with construction over, it was time to do the Arduino coding.  The LCD uses the <a href="/stuff/LiquidCrystal_I2C.zip" class="lizip">LiquidCrystal I2C</a> library which takes care of all the hard work interfacing to it.  Likewise, the <a href="/stuff/Metro.zip" class="lizip">Metro</a> library takes care of the timer.  So, it is just a simple case of increasing the clock by an hour every time the red button is pressed, and starting the timer when the green button is pressed.  Once the timer is running, any button press will stop the timer and reset the state to the beginning.</p>

<div class="wp_syntax"><div class="code"><pre class="c" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">// Arduino controlled timer socket</span>
<span style="color: #666666; font-style: italic;">// (CC BY) 2011</span>
<span style="color: #666666; font-style: italic;">// http://awooga.nl</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// pull in libraries</span>
<span style="color: #339933;">#include &lt;Wire.h&gt;</span>
<span style="color: #339933;">#include &lt;LiquidCrystal_I2C.h&gt;</span>
<span style="color: #339933;">#include &lt;Metro.h&gt;</span>
&nbsp;
&nbsp;
<span style="color: #666666; font-style: italic;">// arduino pins constants</span>
<span style="color: #339933;">#define RELAY 2 // black wire connected to input on shield</span>
<span style="color: #339933;">#define RED   6 // green wire</span>
<span style="color: #339933;">#define GREEN 7 // white wire</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// i2c pin A5 = white wire</span>
<span style="color: #666666; font-style: italic;">// i2c pin A4 = green wire</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// allow between 1 and 6 hours</span>
<span style="color: #339933;">#define MINIMUM_TIME 1</span>
<span style="color: #339933;">#define DEFAULT_TIME 6</span>
<span style="color: #339933;">#define MAXIMUM_TIME 6</span>
&nbsp;
&nbsp;
<span style="color: #993333;">const</span> <span style="color: #993333;">unsigned</span> <span style="color: #993333;">long</span> MILLISECONDS<span style="color: #339933;">=</span><span style="color: #0000dd;">1</span><span style="color: #339933;">;</span>
<span style="color: #993333;">const</span> <span style="color: #993333;">unsigned</span> <span style="color: #993333;">long</span> SECONDS<span style="color: #339933;">=</span><span style="color: #009900;">&#40;</span><span style="color: #0000dd;">1000</span><span style="color: #339933;">*</span>MILLISECONDS<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #993333;">const</span> <span style="color: #993333;">unsigned</span> <span style="color: #993333;">long</span> MINUTES<span style="color: #339933;">=</span><span style="color: #009900;">&#40;</span><span style="color: #0000dd;">60</span><span style="color: #339933;">*</span>SECONDS<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #993333;">const</span> <span style="color: #993333;">unsigned</span> <span style="color: #993333;">long</span> HOURS<span style="color: #339933;">=</span><span style="color: #009900;">&#40;</span><span style="color: #0000dd;">60</span><span style="color: #339933;">*</span>MINUTES<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #993333;">const</span> <span style="color: #993333;">unsigned</span> <span style="color: #993333;">long</span> DAYS<span style="color: #339933;">=</span><span style="color: #009900;">&#40;</span><span style="color: #0000dd;">24</span><span style="color: #339933;">*</span>HOURS<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #993333;">const</span> <span style="color: #993333;">unsigned</span> <span style="color: #993333;">long</span> UNITS<span style="color: #339933;">=</span>HOURS<span style="color: #339933;">;</span>
&nbsp;
&nbsp;
<span style="color: #666666; font-style: italic;">// prgram states</span>
<span style="color: #339933;">#define IDLE         0</span>
<span style="color: #339933;">#define RED_BUTTON   1</span>
<span style="color: #339933;">#define GREEN_BUTTON 2</span>
<span style="color: #339933;">#define MENU         3</span>
<span style="color: #339933;">#define PAUSE        4</span>
<span style="color: #339933;">#define STOP_TIMER   5</span>
<span style="color: #339933;">#define CANCEL_TIMER 6</span>
&nbsp;
&nbsp;
<span style="color: #666666; font-style: italic;">// global variables</span>
byte events<span style="color: #339933;">;</span>
byte countdowntime<span style="color: #339933;">;</span>
boolean menu_running<span style="color: #339933;">;</span>
boolean timer_running<span style="color: #339933;">;</span>
&nbsp;
boolean debug <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">false</span><span style="color: #339933;">;</span>
&nbsp;
byte currentRed <span style="color: #339933;">=</span> LOW<span style="color: #339933;">;</span>
byte currentGreen <span style="color: #339933;">=</span> LOW<span style="color: #339933;">;</span>
byte previousRed <span style="color: #339933;">=</span> LOW<span style="color: #339933;">;</span>
byte previousGreen <span style="color: #339933;">=</span> LOW<span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// set the LCD address to 0x27 for the 16x2 display</span>
LiquidCrystal_I2C lcd<span style="color: #009900;">&#40;</span><span style="color: #208080;">0x27</span><span style="color: #339933;">,</span> <span style="color: #0000dd;">16</span><span style="color: #339933;">,</span> <span style="color: #0000dd;">2</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// initiate Metro object</span>
Metro relayMetro <span style="color: #339933;">=</span> Metro<span style="color: #009900;">&#40;</span><span style="color: #0000dd;">0</span><span style="color: #339933;">,</span> <span style="color: #000000; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
&nbsp;
<span style="color: #666666; font-style: italic;">// arduino setup routine</span>
<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>
&nbsp;
  <span style="color: #666666; font-style: italic;">// set the arduino pins</span>
  pinMode<span style="color: #009900;">&#40;</span>RELAY<span style="color: #339933;">,</span> OUTPUT<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  pinMode<span style="color: #009900;">&#40;</span>RED<span style="color: #339933;">,</span> INPUT<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  pinMode<span style="color: #009900;">&#40;</span>GREEN<span style="color: #339933;">,</span> INPUT<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>  
&nbsp;
  <span style="color: #666666; font-style: italic;">// initialise the lcd</span>
  lcd.<span style="color: #202020;">init</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  lcd.<span style="color: #202020;">backlight</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
  <span style="color: #666666; font-style: italic;">// activate debugging on the serial port</span>
  <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>debug<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>
    Serial.<span style="color: #202020;">println</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;Lets go!&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
&nbsp;
  <span style="color: #666666; font-style: italic;">// initialise variables</span>
  events <span style="color: #339933;">=</span> IDLE<span style="color: #339933;">;</span>
  countdowntime <span style="color: #339933;">=</span> DEFAULT_TIME<span style="color: #339933;">;</span>
  menu_running <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">false</span><span style="color: #339933;">;</span>
  timer_running <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">false</span><span style="color: #339933;">;</span>
  digitalWrite<span style="color: #009900;">&#40;</span>RELAY<span style="color: #339933;">,</span> LOW<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
&nbsp;
<span style="color: #666666; font-style: italic;">// arduino loop routine</span>
<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>
&nbsp;
  <span style="color: #b1b100;">switch</span> <span style="color: #009900;">&#40;</span>events<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
    <span style="color: #b1b100;">case</span> IDLE<span style="color: #339933;">:</span>
      events <span style="color: #339933;">=</span> Idling<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      <span style="color: #000000; font-weight: bold;">break</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #b1b100;">case</span> MENU<span style="color: #339933;">:</span>
      events <span style="color: #339933;">=</span> MainMenu<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      <span style="color: #000000; font-weight: bold;">break</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #b1b100;">case</span> RED_BUTTON<span style="color: #339933;">:</span>
      events <span style="color: #339933;">=</span> RedButton<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      <span style="color: #000000; font-weight: bold;">break</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #b1b100;">case</span> GREEN_BUTTON<span style="color: #339933;">:</span>
      events <span style="color: #339933;">=</span> GreenButton<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      <span style="color: #000000; font-weight: bold;">break</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #b1b100;">case</span> PAUSE<span style="color: #339933;">:</span>
      events <span style="color: #339933;">=</span> Pause<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      <span style="color: #000000; font-weight: bold;">break</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #b1b100;">case</span> STOP_TIMER<span style="color: #339933;">:</span>
      events <span style="color: #339933;">=</span> StopTimer<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      <span style="color: #000000; font-weight: bold;">break</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #b1b100;">case</span> CANCEL_TIMER<span style="color: #339933;">:</span>
      events <span style="color: #339933;">=</span> CancelTimer<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      <span style="color: #000000; font-weight: bold;">break</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #b1b100;">default</span><span style="color: #339933;">:</span>
      events <span style="color: #339933;">=</span> IDLE<span style="color: #339933;">;</span>
      <span style="color: #000000; font-weight: bold;">break</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
&nbsp;
<span style="color: #993333;">int</span> MainMenu<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
  <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>timer_running<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #b1b100;">return</span> IDLE<span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
&nbsp;
  <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>menu_running<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #b1b100;">return</span> IDLE<span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
&nbsp;
  <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>debug<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> Serial.<span style="color: #202020;">println</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;MainMenu()&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span>
&nbsp;
  lcd.<span style="color: #202020;">clear</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  lcd.<span style="color: #202020;">print</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;  Red: Set time&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  lcd.<span style="color: #202020;">setCursor</span><span style="color: #009900;">&#40;</span><span style="color: #0000dd;">0</span><span style="color: #339933;">,</span> <span style="color: #0000dd;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  lcd.<span style="color: #202020;">print</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;Green: Go (&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  lcd.<span style="color: #202020;">print</span><span style="color: #009900;">&#40;</span>countdowntime<span style="color: #339933;">,</span> DEC<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>countdowntime <span style="color: #339933;">==</span> <span style="color: #0000dd;">1</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    lcd.<span style="color: #202020;">print</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;hr)&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: #009900;">&#123;</span>
    lcd.<span style="color: #202020;">print</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;hrs)&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
&nbsp;
  menu_running <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">true</span><span style="color: #339933;">;</span>
&nbsp;
  <span style="color: #b1b100;">return</span> IDLE<span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
&nbsp;
<span style="color: #993333;">int</span> Idling<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
  boolean do_red <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">false</span><span style="color: #339933;">;</span>
  boolean do_green <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">false</span><span style="color: #339933;">;</span>
&nbsp;
  <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>timer_running<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>relayMetro.<span style="color: #202020;">check</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>
      <span style="color: #b1b100;">return</span> STOP_TIMER<span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
  <span style="color: #009900;">&#125;</span>
&nbsp;
  currentRed <span style="color: #339933;">=</span> digitalRead<span style="color: #009900;">&#40;</span>RED<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  currentGreen <span style="color: #339933;">=</span> digitalRead<span style="color: #009900;">&#40;</span>GREEN<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
  <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>currentRed <span style="color: #339933;">!=</span> previousRed<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    do_red <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>currentRed <span style="color: #339933;">==</span> HIGH<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
  previousRed <span style="color: #339933;">=</span> currentRed<span style="color: #339933;">;</span>
&nbsp;
  <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>currentGreen <span style="color: #339933;">!=</span> previousGreen<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    do_green <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>currentGreen <span style="color: #339933;">==</span> HIGH<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
  previousGreen <span style="color: #339933;">=</span> currentGreen<span style="color: #339933;">;</span>
&nbsp;
  <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span>do_red<span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span>do_green<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #b1b100;">return</span> RED_BUTTON<span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
&nbsp;
  <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span>do_red<span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #009900;">&#40;</span>do_green<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #b1b100;">return</span> GREEN_BUTTON<span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
&nbsp;
  <span style="color: #666666; font-style: italic;">// all other button combinations are ignored</span>
  <span style="color: #b1b100;">return</span> MENU<span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
&nbsp;
<span style="color: #993333;">int</span> RedButton<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>debug<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> Serial.<span style="color: #202020;">println</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;RedButton()&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span>
&nbsp;
  <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>timer_running<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #b1b100;">return</span> CANCEL_TIMER<span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
&nbsp;
  <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">++</span>countdowntime <span style="color: #339933;">&gt;</span> MAXIMUM_TIME<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> countdowntime <span style="color: #339933;">=</span> MINIMUM_TIME<span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span>
&nbsp;
  lcd.<span style="color: #202020;">clear</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  lcd.<span style="color: #202020;">print</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;Time set to&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  lcd.<span style="color: #202020;">setCursor</span><span style="color: #009900;">&#40;</span><span style="color: #0000dd;">0</span><span style="color: #339933;">,</span> <span style="color: #0000dd;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  lcd.<span style="color: #202020;">print</span><span style="color: #009900;">&#40;</span>countdowntime<span style="color: #339933;">,</span> DEC<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>countdowntime <span style="color: #339933;">==</span> <span style="color: #0000dd;">1</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    lcd.<span style="color: #202020;">print</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot; hour&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: #009900;">&#123;</span>
    lcd.<span style="color: #202020;">print</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot; hours&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
&nbsp;
  menu_running <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">false</span><span style="color: #339933;">;</span>
&nbsp;
  <span style="color: #b1b100;">return</span> PAUSE<span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
&nbsp;
<span style="color: #993333;">int</span> GreenButton<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>debug<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> Serial.<span style="color: #202020;">println</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;GreenButton()&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span>
&nbsp;
  <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>timer_running<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #b1b100;">return</span> CANCEL_TIMER<span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
&nbsp;
  lcd.<span style="color: #202020;">clear</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  lcd.<span style="color: #202020;">print</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;Running timer&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  lcd.<span style="color: #202020;">setCursor</span><span style="color: #009900;">&#40;</span><span style="color: #0000dd;">0</span><span style="color: #339933;">,</span> <span style="color: #0000dd;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  lcd.<span style="color: #202020;">print</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;for &quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  lcd.<span style="color: #202020;">print</span><span style="color: #009900;">&#40;</span>countdowntime<span style="color: #339933;">,</span> DEC<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>countdowntime <span style="color: #339933;">==</span> <span style="color: #0000dd;">1</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    lcd.<span style="color: #202020;">print</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot; hour&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: #009900;">&#123;</span>
    lcd.<span style="color: #202020;">print</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot; hours&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
&nbsp;
  <span style="color: #993333;">unsigned</span> <span style="color: #993333;">long</span> t <span style="color: #339933;">=</span> countdowntime <span style="color: #339933;">*</span> UNITS<span style="color: #339933;">;</span>
&nbsp;
  timer_running <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">true</span><span style="color: #339933;">;</span>
  <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>debug<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    Serial.<span style="color: #202020;">print</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;Setting metro for &quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    Serial.<span style="color: #202020;">print</span><span style="color: #009900;">&#40;</span>t<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    Serial.<span style="color: #202020;">println</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot; seconds&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
  relayMetro.<span style="color: #202020;">interval</span><span style="color: #009900;">&#40;</span>t<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
  digitalWrite<span style="color: #009900;">&#40;</span>RELAY<span style="color: #339933;">,</span> HIGH<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
  <span style="color: #b1b100;">return</span> IDLE<span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
&nbsp;
<span style="color: #993333;">int</span> StopTimer<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>debug<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> Serial.<span style="color: #202020;">println</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;StopTimer()&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span>
&nbsp;
  digitalWrite<span style="color: #009900;">&#40;</span>RELAY<span style="color: #339933;">,</span> LOW<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
  lcd.<span style="color: #202020;">clear</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  lcd.<span style="color: #202020;">print</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;Timer finished&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
  timer_running <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">false</span><span style="color: #339933;">;</span>
  menu_running <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">false</span><span style="color: #339933;">;</span>
  relayMetro.<span style="color: #202020;">reset</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
  <span style="color: #b1b100;">return</span> PAUSE<span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
&nbsp;
<span style="color: #993333;">int</span> CancelTimer<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>debug<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> Serial.<span style="color: #202020;">println</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;CancelTimer()&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span>
&nbsp;
  digitalWrite<span style="color: #009900;">&#40;</span>RELAY<span style="color: #339933;">,</span> LOW<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
  lcd.<span style="color: #202020;">clear</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  lcd.<span style="color: #202020;">print</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;Timer stopped&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
  timer_running <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">false</span><span style="color: #339933;">;</span>
  menu_running <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">false</span><span style="color: #339933;">;</span>
  relayMetro.<span style="color: #202020;">reset</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
  <span style="color: #b1b100;">return</span> PAUSE<span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
&nbsp;
<span style="color: #993333;">int</span> Pause<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  delay<span style="color: #009900;">&#40;</span><span style="color: #0000dd;">1000</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #b1b100;">return</span> IDLE<span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>Or just download the .pde file <a href="/stuff/SocketTimer.pde" class="liinternal">here</a></p>
<p>Obviously you can go all crazy with options and clocks, but I just wanted something quick and working.  Changing the code to do all that is just a matter of opening it up, and uploading the new software.</p>
<p><a href="/gallery/modding/arduino/DSC04201.JPG.html" class="liimagelink"><img src="/g/image/37773-5/DSC04201.JPG" alt="" /></a> <a href="/gallery/modding/arduino/DSC04202.JPG.html" class="liimagelink"><img src="/g/image/37777-3/DSC04202.JPG" alt="" /></a> <a href="/gallery/modding/arduino/DSC04204.JPG.html" class="liimagelink"><img src="/g/image/37785-3/DSC04204.JPG" alt="" /></a></p>
<p><br /><br /><center><script type="text/javascript"><!--
google_ad_client = "pub-3248212177098373";
google_ad_slot = "3039514391";
google_ad_width = 468;
google_ad_height = 60;
//--></script>
<script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
</center><br /></p>
<p>And just to prove it is all working, here&#8217;s a small video demonstration.  It doesn&#8217;t show the timer ending, you just have to take my word on that :D</p>
<p><object width="425" height="355"><param name="movie" value="http://www.youtube.com/v/STLeDXH6rNU?rel=0" /><param name="allowFullScreen" value="true" /><param name="allowscriptaccess" value="always" /><embed wmode="opaque" src="http://www.youtube.com/v/STLeDXH6rNU?rel=0" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="425" height="355"></embed></object></p>
]]></content:encoded>
			<wfw:commentRss>http://awooga.nl/ooh-arr-duino/feed</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>The Mul-tea Charger</title>
		<link>http://awooga.nl/the-mul-tea-charger</link>
		<comments>http://awooga.nl/the-mul-tea-charger#comments</comments>
		<pubDate>Sun, 04 Oct 2009 19:15:23 +0000</pubDate>
		<dc:creator>Q</dc:creator>
				<category><![CDATA[blog]]></category>
		<category><![CDATA[apple]]></category>
		<category><![CDATA[chargers]]></category>
		<category><![CDATA[crafts]]></category>
		<category><![CDATA[electricity]]></category>
		<category><![CDATA[gadgets]]></category>
		<category><![CDATA[hacking]]></category>
		<category><![CDATA[hub]]></category>
		<category><![CDATA[iphone]]></category>
		<category><![CDATA[modding]]></category>
		<category><![CDATA[nokia]]></category>
		<category><![CDATA[sony ericsson]]></category>
		<category><![CDATA[usb]]></category>
		<category><![CDATA[W880i]]></category>

		<guid isPermaLink="false">http://awooga.nl/?p=413</guid>
		<description><![CDATA[Who doesn&#8217;t have a multitude of devices, phones and other gadgets on their desks? I certainly have, and I finally had enough of all the chargers and wallwarts that each item seems to bring with them. With two iPhones almost constantly being charged, and a Nokia phone thrown in for good measure, I needed to [...]]]></description>
			<content:encoded><![CDATA[<p>Who doesn&#8217;t have a multitude of devices, phones and other gadgets on their desks?  I certainly have, and I finally had enough of all the chargers and wallwarts that each item seems to bring with them.  With two iPhones almost constantly being charged, and a Nokia phone thrown in for good measure, I needed to have something flexible enough for those plus any future gadgets.  So, I googled a bit, and found the <a href="http://www.idaptweb.com/UK/idapt/idapt_i3/overview.html" target="_blank" class="liexternal">IDAPT I3</a>, and the beautiful, but ridiculously priced <a href="http://www.pedlars.co.uk/page_1973.html" target="_blank" class="liexternal">The Sanctuary</a>.  And then I started to think, how easy would it be to put a mains powered USB hub inside a box and have several USB charger leads coming out of the box, each charging a different device?<br />
<br /><br /><center><script type="text/javascript"><!--
google_ad_client = "pub-3248212177098373";
google_ad_slot = "3039514391";
google_ad_width = 468;
google_ad_height = 60;
//--></script>
<script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
</center><br /><br />
And the answer is, very easy :)</p>
<p><a href="/gallery/modding/charger/DSC02612.JPG.html" class="liimagelink"><img src="/g/image/35708-3/DSC02612.JPG" alt="" /></a> <a href="/gallery/modding/charger/DSC02613.JPG.html" class="liimagelink"><img src="/g/image/35713-3/DSC02613.JPG" alt="" /></a> <a href="/gallery/modding/charger/DSC02614.JPG.html" class="liimagelink"><img src="/g/image/35717-3/DSC02614.JPG" alt="" /></a></p>
<p>I started off with a 4 port powered USB hub, which I had lying in a drawer and plugged my iPhone charger leads into it, expecting them to instantly charge my two iPhones.  But to my surpise, nothing happened&#8230;  so another quick Google later, I came accross a blog entry of <a href="http://carlhutzler.com/blog/2009/07/28/usb-hub-as-an-ipodiphone-charger/" target="_blank" class="liexternal">Carl Hutzler</a>, which details why they won&#8217;t charge.  All you have to do is sacrifice the hub and forego it&#8217;s PC functionality by cutting the D+/- lines and short them.  A quick test shows they now finally charge themselves.  Apparently it is better to stick 2x 100K Ohm resistors on the D+/- lines, which I will do at some point, but for now, this will do.</p>
<p><a href="/gallery/modding/charger/DSC02616.JPG.html" class="liimagelink"><img src="/g/image/35721-3/DSC02616.JPG" alt="" /></a> <a href="/gallery/modding/charger/DSC02617.JPG.html" class="liimagelink"><img src="/g/image/35725-3/DSC02617.JPG" alt="" /></a> <a href="/gallery/modding/charger/DSC02618.JPG.html" class="liimagelink"><img src="/g/image/35734-3/DSC02618.JPG" alt="" /></a></p>
<p>All I now had to do was find a suitable SWMBO friendly container, and as our furniture is all beech, the tea storage container I found for £1.99 at <a href="http://www.qdstores.co.uk/" target="_blank" class="liexternal">QD stores</a> was perfect.  I just needed to gut the compartiments out and put something on top of the plastic lid.  At my local crafts store I found a small foam pad for 50p which was nice and soft.  Unfortunately I got my measurements all wrong, so I messed up the black pad, but SWMBO came to the rescue by rummaging through my kids crafts drawers by digging up a piece of brown padding.</p>
<p><a href="/gallery/modding/charger/DSC02619.JPG.html" class="liimagelink"><img src="/g/image/35738-3/DSC02619.JPG" alt="" /></a> <a href="/gallery/modding/charger/DSC02620.JPG.html" class="liimagelink"><img src="/g/image/35742-3/DSC02620.JPG" alt="" /></a> <a href="/gallery/modding/charger/DSC02621.JPG.html" class="liimagelink"><img src="/g/image/35746-3/DSC02621.JPG" alt="" /></a> <a href="/gallery/modding/charger/DSC02622.JPG.html" class="liimagelink"><img src="/g/image/35750-3/DSC02622.JPG" alt="" /></a> <a href="/gallery/modding/charger/DSC02623.JPG.html" class="liimagelink"><img src="/g/image/35759-3/DSC02623.JPG" alt="" /></a></p>
<p>The final thing to do is then drill some holes at the locations convenient for your devices, and put it all together.  Job done!</p>
<p><a href="/gallery/modding/charger/DSC02624.JPG.html" class="liimagelink"><img src="/g/image/35763-3/DSC02624.JPG" alt="" /></a> <a href="/gallery/modding/charger/DSC02625.JPG.html" class="liimagelink"><img src="/g/image/35767-3/DSC02625.JPG" alt="" /></a> <a href="/gallery/modding/charger/DSC02626.JPG.html" class="liimagelink"><img src="/g/image/35771-3/DSC02626.JPG" alt="" /></a><br />
<br /><br /><center><script type="text/javascript"><!--
google_ad_client = "pub-3248212177098373";
google_ad_slot = "3039514391";
google_ad_width = 468;
google_ad_height = 60;
//--></script>
<script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
</center><br /></p>
]]></content:encoded>
			<wfw:commentRss>http://awooga.nl/the-mul-tea-charger/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

