
<?xml version="1.0"?>
<?xml-stylesheet type="text/css" href="http://combustory.com/wiki/skins/common/feed.css?301"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
		<id>http://combustory.com/wiki/index.php?feed=atom&amp;target=Combustor&amp;title=Special%3AContributions%2FCombustor</id>
		<title>Combustory - User contributions [en]</title>
		<link rel="self" type="application/atom+xml" href="http://combustory.com/wiki/index.php?feed=atom&amp;target=Combustor&amp;title=Special%3AContributions%2FCombustor"/>
		<link rel="alternate" type="text/html" href="http://combustory.com/wiki/index.php/Special:Contributions/Combustor"/>
		<updated>2026-04-04T08:00:30Z</updated>
		<subtitle>From Combustory</subtitle>
		<generator>MediaWiki 1.17.0</generator>

	<entry>
		<id>http://combustory.com/wiki/index.php/Main_Page</id>
		<title>Main Page</title>
		<link rel="alternate" type="text/html" href="http://combustory.com/wiki/index.php/Main_Page"/>
				<updated>2010-12-15T03:03:28Z</updated>
		
		<summary type="html">&lt;p&gt;Combustor: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;anyweb&amp;gt;http://combustory.com/wiki/ads/ad_rtc.html&amp;lt;/anyweb&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{default}}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--------------------------------Featured picture------------------------------&lt;br /&gt;
{| id=&amp;quot;mp-tfp&amp;quot; style=&amp;quot;margin:4px 0px 0px 0px; width:30%; background:none;&amp;quot;&lt;br /&gt;
|class=&amp;quot;MainPageBG&amp;quot; style=&amp;quot;width:30%; border:1px solid #ddcef2; background:#faf5ff; vertical-align:top; color:#000;&amp;quot;|&lt;br /&gt;
{| cellpadding=&amp;quot;2&amp;quot; cellspacing=&amp;quot;5&amp;quot; style=&amp;quot;vertical-align:top; background:#faf5ff; color:#000; width:30%&amp;quot;&lt;br /&gt;
! &amp;lt;h3  id=&amp;quot;mp-tfp-h2&amp;quot; style=&amp;quot;margin:0; background:#ddcef2; font-size:120%; font-weight:bold; border:1px solid #afa3bf; text-align:top; color:#000; padding:0.2em 0.4em&amp;quot;&amp;gt;Featured picture&amp;lt;/h3&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;color:#000;&amp;quot;| {{Featured Picture}}&lt;br /&gt;
|}&lt;br /&gt;
|}&amp;lt;!--&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;---------Interwiki strapline----------&amp;gt;&lt;br /&gt;
== Goal ==&lt;br /&gt;
&lt;br /&gt;
My original Goal was to create a website that is the most comprehensive website for Automobiles. However, as I soon found out while looking for a Domain Name that there were not many good choices related to cars.  Some how I came up with Combustory and it made me think of the History of Combustibles in general.  So I decided on a site that would include all machines dependent on Combustibles.  As you can see from the list below it is a fairly significant task that will require a world of help, so please feel free to join in the task by emailing me to create an account and start creating content. &lt;br /&gt;
&lt;br /&gt;
[[Image:lost_soul_1.jpg |frame|Roadside Assistance Required]]&lt;br /&gt;
&lt;br /&gt;
Contact: combustor@combustory.com&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;big&amp;gt;'''Categories'''&amp;lt;/big&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* [[Motorcycles]]&lt;br /&gt;
* [[Cars]] &lt;br /&gt;
* [[Trucks]] (Coming )&lt;br /&gt;
* [[Tractors]] (Coming)&lt;br /&gt;
* [[Earth Movers]] (Coming)&lt;br /&gt;
* [[Tanks]] (Coming)&lt;br /&gt;
* [[Airplanes]] (Coming)&lt;br /&gt;
* [[Jets]] (Coming)&lt;br /&gt;
* [[Rockets]] (Coming)&lt;br /&gt;
* [[Helicopters]] (Coming)&lt;br /&gt;
* [[Locomotives]] (Coming)&lt;br /&gt;
* [[General Electronics]]&lt;br /&gt;
&lt;br /&gt;
== Creators Note ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Links ==&lt;/div&gt;</summary>
		<author><name>Combustor</name></author>	</entry>

	<entry>
		<id>http://combustory.com/wiki/index.php/GPS_Sensors</id>
		<title>GPS Sensors</title>
		<link rel="alternate" type="text/html" href="http://combustory.com/wiki/index.php/GPS_Sensors"/>
				<updated>2010-12-06T03:30:20Z</updated>
		
		<summary type="html">&lt;p&gt;Combustor: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;anyweb&amp;gt;http://combustory.com/wiki/ads/ad_rtc.html&amp;lt;/anyweb&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{default}}&lt;br /&gt;
&lt;br /&gt;
=Pharos GPS-500=&lt;br /&gt;
&lt;br /&gt;
==Device Set Up on Linux==&lt;br /&gt;
&lt;br /&gt;
* Plug in GPS-500 device to a USB port&lt;br /&gt;
* Search for device on computer&lt;br /&gt;
&lt;br /&gt;
 lsusb&lt;br /&gt;
&lt;br /&gt;
This command should result in finding the Prolific Tech. line as seen below.&lt;br /&gt;
&lt;br /&gt;
example output:&lt;br /&gt;
&lt;br /&gt;
 Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub&lt;br /&gt;
 Bus 005 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub&lt;br /&gt;
 Bus 003 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub&lt;br /&gt;
 Bus 002 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub&lt;br /&gt;
 Bus 004 Device 008: ID 067b:aaa0 Prolific Technology, Inc. Prolific Pharos&lt;br /&gt;
 Bus 004 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub&lt;br /&gt;
&lt;br /&gt;
* Search for a tty device&lt;br /&gt;
&lt;br /&gt;
 ls /dev&lt;br /&gt;
&lt;br /&gt;
Look for a tty device: ttyUSB0 or ttyUSB1 or any other ttyUSBx, which depends on how many USB serial devices you have set up. (This was done on Fedora, other OS's may have a different designation)&lt;br /&gt;
&lt;br /&gt;
==View Data==&lt;br /&gt;
&lt;br /&gt;
* You may need to use sudo to allow permissions to the tty.&lt;br /&gt;
&lt;br /&gt;
* This command will set the device to allow you to log data via tail or cat&lt;br /&gt;
&lt;br /&gt;
 stty -F /dev/ttyUSB0 cs8 4800 ignbrk -brkint -icrnl -imaxbel -opost -onlcr -isig -icanon -iexten -echo -echoe -echok -echoctl -echoke noflsh -ixon -crtscts&lt;br /&gt;
&lt;br /&gt;
* View raw data after stty command&lt;br /&gt;
&lt;br /&gt;
 cat /dev/ttyUSB0&lt;br /&gt;
&lt;br /&gt;
* Log Data - You will need to manage the log file sizes&lt;br /&gt;
&lt;br /&gt;
 cat /dev/ttyUSB0 &amp;gt;&amp;gt; gps_log&lt;br /&gt;
&lt;br /&gt;
* Log Data with Filter - This significantly cuts down on the number of strings and is really the only string you need.&lt;br /&gt;
&lt;br /&gt;
 cat /dev/ttyUSB0 | grep GPRMC &amp;gt;&amp;gt; gps_logs&lt;/div&gt;</summary>
		<author><name>Combustor</name></author>	</entry>

	<entry>
		<id>http://combustory.com/wiki/index.php/GPS_Sensors</id>
		<title>GPS Sensors</title>
		<link rel="alternate" type="text/html" href="http://combustory.com/wiki/index.php/GPS_Sensors"/>
				<updated>2010-12-06T03:02:56Z</updated>
		
		<summary type="html">&lt;p&gt;Combustor: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;anyweb&amp;gt;http://combustory.com/wiki/ads/ad_rtc.html&amp;lt;/anyweb&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{default}}&lt;br /&gt;
&lt;br /&gt;
=Pharos GPS-500=&lt;br /&gt;
&lt;br /&gt;
==Device Set Up on Linux==&lt;br /&gt;
&lt;br /&gt;
* Plug in GPS-500 device to a USB port&lt;br /&gt;
* Search for device on computer&lt;br /&gt;
&lt;br /&gt;
 lsusb&lt;br /&gt;
&lt;br /&gt;
This command should result in a finding the Prolific Tech. line as seen below.&lt;br /&gt;
&lt;br /&gt;
example output:&lt;br /&gt;
&lt;br /&gt;
 Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub&lt;br /&gt;
 Bus 005 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub&lt;br /&gt;
 Bus 003 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub&lt;br /&gt;
 Bus 002 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub&lt;br /&gt;
 Bus 004 Device 008: ID 067b:aaa0 Prolific Technology, Inc. Prolific Pharos&lt;br /&gt;
 Bus 004 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub&lt;br /&gt;
&lt;br /&gt;
* Search for a tty device&lt;br /&gt;
&lt;br /&gt;
 ls /dev&lt;br /&gt;
&lt;br /&gt;
Look for a tty device: ttyUSB0 or ttyUSB1 or any other ttyUSBx, which depends on how many USB serial devices you have set up. (This was done on Fedora, other OS's may have a different designation)&lt;br /&gt;
&lt;br /&gt;
==View Data==&lt;br /&gt;
&lt;br /&gt;
* You may need to use sudo to allow permissions to the tty.&lt;br /&gt;
&lt;br /&gt;
* This command will set the device to allow you to log data via tail or cat&lt;br /&gt;
&lt;br /&gt;
 stty -F /dev/ttyUSB0 cs8 4800 ignbrk -brkint -icrnl -imaxbel -opost -onlcr -isig -icanon -iexten -echo -echoe -echok -echoctl -echoke noflsh -ixon -crtscts&lt;br /&gt;
&lt;br /&gt;
* View raw data after stty command&lt;br /&gt;
&lt;br /&gt;
 cat /dev/ttyUSB0&lt;br /&gt;
&lt;br /&gt;
* Log Data - You will need to manage the log file sizes&lt;br /&gt;
&lt;br /&gt;
 cat /dev/ttyUSB0 &amp;gt;&amp;gt; gps_log&lt;br /&gt;
&lt;br /&gt;
* Log Data with Filter - This significantly cuts down on the number of strings and is really the only string you need.&lt;br /&gt;
&lt;br /&gt;
 cat /dev/ttyUSB0 | grep GPRMC &amp;gt;&amp;gt; gps_logs&lt;/div&gt;</summary>
		<author><name>Combustor</name></author>	</entry>

	<entry>
		<id>http://combustory.com/wiki/index.php/GPS_Sensors</id>
		<title>GPS Sensors</title>
		<link rel="alternate" type="text/html" href="http://combustory.com/wiki/index.php/GPS_Sensors"/>
				<updated>2010-12-06T02:59:45Z</updated>
		
		<summary type="html">&lt;p&gt;Combustor: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;anyweb&amp;gt;http://combustory.com/wiki/ads/ad_rtc.html&amp;lt;/anyweb&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{default}}&lt;br /&gt;
&lt;br /&gt;
=Pharos GPS-500=&lt;br /&gt;
&lt;br /&gt;
==Device Set Up on Linux==&lt;br /&gt;
&lt;br /&gt;
* Plug in GPS-500 device to a USB port&lt;br /&gt;
* Search for device on computer&lt;br /&gt;
&lt;br /&gt;
 lsusb&lt;br /&gt;
&lt;br /&gt;
This command should result in a finding the Prolific Tech. line as seen below.&lt;br /&gt;
&lt;br /&gt;
example output:&lt;br /&gt;
&lt;br /&gt;
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub&lt;br /&gt;
Bus 005 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub&lt;br /&gt;
Bus 003 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub&lt;br /&gt;
Bus 002 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub&lt;br /&gt;
Bus 004 Device 008: ID 067b:aaa0 Prolific Technology, Inc. Prolific Pharos&lt;br /&gt;
Bus 004 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub&lt;br /&gt;
&lt;br /&gt;
* Search for a tty device&lt;br /&gt;
&lt;br /&gt;
 ls /dev&lt;br /&gt;
&lt;br /&gt;
Look for a tty device: ttyUSB0 or ttyUSB1 or any other ttyUSBx, which depends (This was done on Fedora, other OS's may have a different designation)&lt;br /&gt;
&lt;br /&gt;
==View Data==&lt;br /&gt;
&lt;br /&gt;
* You may need to use sudo to allow permissions to the tty.&lt;br /&gt;
* This command will output troubleshooting info from the server process.&lt;br /&gt;
&lt;br /&gt;
* This command will set the device to allow you to log data via tail or cat&lt;br /&gt;
&lt;br /&gt;
 stty -F /dev/ttyUSB0 cs8 4800 ignbrk -brkint -icrnl -imaxbel -opost -onlcr -isig -icanon -iexten -echo -echoe -echok -echoctl -echoke noflsh -ixon -crtscts&lt;br /&gt;
&lt;br /&gt;
* View raw data after stty command&lt;br /&gt;
&lt;br /&gt;
 cat /dev/ttyUSB0&lt;br /&gt;
&lt;br /&gt;
* Log Data - You will need to manage the log file sizes&lt;br /&gt;
&lt;br /&gt;
 cat /dev/ttyUSB0 &amp;gt;&amp;gt; gps_log&lt;br /&gt;
&lt;br /&gt;
* Log Data with Filter - This significantly cuts down on the number of strings and is really the only string you need.&lt;br /&gt;
&lt;br /&gt;
 cat /dev/ttyUSB0 | grep GPRMC &amp;gt;&amp;gt; gps_logs&lt;/div&gt;</summary>
		<author><name>Combustor</name></author>	</entry>

	<entry>
		<id>http://combustory.com/wiki/index.php/GPS_Sensors</id>
		<title>GPS Sensors</title>
		<link rel="alternate" type="text/html" href="http://combustory.com/wiki/index.php/GPS_Sensors"/>
				<updated>2010-12-06T02:37:46Z</updated>
		
		<summary type="html">&lt;p&gt;Combustor: New page: =Pharos GPS-500=  ==Device Set Up on Linux==  * Plug in GPS-500 device to a USB port * Search for device on computer   lsusb  This command should result in a finding the Prolific Tech. lin...&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Pharos GPS-500=&lt;br /&gt;
&lt;br /&gt;
==Device Set Up on Linux==&lt;br /&gt;
&lt;br /&gt;
* Plug in GPS-500 device to a USB port&lt;br /&gt;
* Search for device on computer&lt;br /&gt;
&lt;br /&gt;
 lsusb&lt;br /&gt;
&lt;br /&gt;
This command should result in a finding the Prolific Tech. line as seen below.&lt;br /&gt;
&lt;br /&gt;
example output:&lt;br /&gt;
&lt;br /&gt;
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub&lt;br /&gt;
Bus 005 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub&lt;br /&gt;
Bus 003 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub&lt;br /&gt;
Bus 002 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub&lt;br /&gt;
Bus 004 Device 008: ID 067b:aaa0 Prolific Technology, Inc. Prolific Pharos&lt;br /&gt;
Bus 004 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub&lt;br /&gt;
&lt;br /&gt;
* Search for a tty device&lt;br /&gt;
&lt;br /&gt;
 ls /dev&lt;br /&gt;
&lt;br /&gt;
Look for a tty device &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==View Data==&lt;br /&gt;
&lt;br /&gt;
* You may need to use sudo to allow permissions to the tty.&lt;br /&gt;
* This command will output troubleshooting info from the server process.&lt;br /&gt;
&lt;br /&gt;
* This command will set the device to allow you to log data via tail or cat&lt;br /&gt;
&lt;br /&gt;
 stty -F /dev/ttyUSB0 cs8 4800 ignbrk -brkint -icrnl -imaxbel -opost -onlcr -isig -icanon -iexten -echo -echoe -echok -echoctl -echoke noflsh -ixon -crtscts&lt;br /&gt;
&lt;br /&gt;
* View raw data after stty command&lt;br /&gt;
&lt;br /&gt;
 cat /dev/ttyUSB0&lt;br /&gt;
&lt;br /&gt;
* Log Data - You will need to manage the log file sizes&lt;br /&gt;
&lt;br /&gt;
 cat /dev/ttyUSB0 &amp;gt;&amp;gt; gps_log&lt;/div&gt;</summary>
		<author><name>Combustor</name></author>	</entry>

	<entry>
		<id>http://combustory.com/wiki/index.php/General_Electronics</id>
		<title>General Electronics</title>
		<link rel="alternate" type="text/html" href="http://combustory.com/wiki/index.php/General_Electronics"/>
				<updated>2010-12-06T02:09:02Z</updated>
		
		<summary type="html">&lt;p&gt;Combustor: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;anyweb&amp;gt;http://combustory.com/wiki/ads/ad_rtc.html&amp;lt;/anyweb&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{default}}&lt;br /&gt;
&lt;br /&gt;
== Topics ==&lt;br /&gt;
&lt;br /&gt;
This is just a general Electronics discussion zone for Combustory.  Certainly most Combustion utilizes electronics these days, so I am opening this platform to general electronics.&lt;br /&gt;
&lt;br /&gt;
* [[OBD-II Diagnostic Tools]]&lt;br /&gt;
* [[Arduino Electronics]]&lt;br /&gt;
* [[MPGuino]] - An MPG gauge based on the Arduino Platform&lt;br /&gt;
* [[GPS Sensors]]&lt;br /&gt;
&lt;br /&gt;
== Creators Note ==&lt;br /&gt;
== Links ==&lt;br /&gt;
[[Category:Electronics]]&lt;/div&gt;</summary>
		<author><name>Combustor</name></author>	</entry>

	<entry>
		<id>http://combustory.com/wiki/index.php/RTC1307_-_Real_Time_Clock</id>
		<title>RTC1307 - Real Time Clock</title>
		<link rel="alternate" type="text/html" href="http://combustory.com/wiki/index.php/RTC1307_-_Real_Time_Clock"/>
				<updated>2010-11-08T22:24:49Z</updated>
		
		<summary type="html">&lt;p&gt;Combustor: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;anyweb&amp;gt;http://combustory.com/wiki/ads/ad_rtc.html&amp;lt;/anyweb&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{default}}&lt;br /&gt;
__TOC__ &lt;br /&gt;
== Summary ==&lt;br /&gt;
This code shows how to communicate with the RTC DS1307 Real Time Clock, which is used to set and retrieve the date/time of the chip. As a bonus there are some additional bytes of data that can be used as general purpose memory.  The main reason for my use of this code is to be able to log events that occur in my applications.  I recommend for you to get the RTC DS1307 data sheet to help with understanding what was done here.  The bottom line is that I have created this program to accept commands via serial communication with a PC to instruct the Arduino to send or receive data via I2C to the storage registers of the RTC DS1307 chip. &lt;br /&gt;
&lt;br /&gt;
Note of gratitude to [http://www.glacialwanderer.com/hobbyrobotics/?p=12 Maurice Ribble - http://www.glacialwanderer.com/hobbyrobotics/?p=12] for the majority of the RTC DS1307 code.  To not repeat his excellent instructions on this chip I highly recommend you visit his site on this topic.  All I did here was expand his code a to get a little more functionality out of the DS1307 chip.&lt;br /&gt;
&lt;br /&gt;
== Method ==&lt;br /&gt;
&lt;br /&gt;
=== DS1307 Chip ===&lt;br /&gt;
&lt;br /&gt;
[[Image:DS1307_pin_out.jpg |left|thumb|300px|]]&lt;br /&gt;
&lt;br /&gt;
If you want to take the easy route, spend the extra bucks and buy a [http://www.sparkfun.com/commerce/product_info.php?products_id=99 Spark Fun] ready to go unit for around $20.  However, if you really prefer spending an extra hour or so (In my case 4 hours, but you get the benefit of my labor ;~), then buy a few chips from Digikey or Mouser. I think I spent a couple bucks to pay for the chip and the crystal, I ended up having to use two resistors as well, but those were from my existing inventory. If you go the chip route, just keep in mind that shipping can be significant, so you will want to buy more than just the chip. &lt;br /&gt;
&lt;br /&gt;
The reason I had to use the resistors, was to create a voltage divider to create a voltage on the battery backup pin.  As I found out and fortunately you will not endure because you are reading this right now, is that the battery pin must have 2.5-3vdc to operate properly or the chip will stop responding to IC2 requests. Ok, we all know the rule, &amp;quot;When all else fails, READ THE DIRECTIONS&amp;quot;. As wisdom will have it, I eventually read this seemingly insignificant information in the Data Sheet. Well if I get the time I will outline all the details on the parts and schematic, but the bottom line is that I was still to cheap to buy a 3v battery, so I just used the voltage divider to drop the 5vdc supply. The absolute most funny part is that the chip does run just fine without the 3vdc...... sometimes.  Meaning you think you have it all worked out and then......... sometimes.  Hence four hours.  But your not going to make that mistake are you?  Because you are here.  Soooooooo, after all is said and done the chip is very stable and works as expected and is reliable.  &lt;br /&gt;
&lt;br /&gt;
Now with all the wires flying on the breadboard, sometimes with voltage (Do as I say not as I do!), it is amazing that the chip even works anymore, but there is one further note I need to make about my chip. It is supposed to have 64 registers, but mine only has 31 registers that work.  Who knows, did I kill them?, or did I get a bad part? Either way the pointer still rolls through the dead registers as if they were there, but they do not accept any writing. I only bought one of these chips, so I could not test for repeatability.  No worry though, hopefully you will have better luck, and I will eventually get another chip to test. '''NOTE - The register issue may have been solved. [http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1264477731/7 Click Here] to see if this works for you. I have not tried it myself, but go to the bottom of the posting for the solution. Apparently you cannot write more than 32 times in one I2C serial session.'''&lt;br /&gt;
&lt;br /&gt;
This page does not cover the clock output pin that has several settings for outputting a clock frequency, so I will leave it to the reader to figure that function out, as I have no need for that right now.  Another interesting feature on this chip is that the time and memory is maintained as long as you have that battery backup at 2.5-3v. But if the chip goes into backup mode, you will not be able to read or write to any of the registers.  One misleading piece of data in the Data Sheet is that the memory is non-volatile, well that is true as long as you have the battery backup power.  In my voltage divider method, when the power is gone it is gone-gone, so basically no data is retained, but that is exactly why I made the date/time setting command, because I just reset it from the host software that I use to control the Arduino. Go to [[Arduino Communications]] to see how I am communicating with the Arduino.&lt;br /&gt;
&lt;br /&gt;
=== I2C ===&lt;br /&gt;
&lt;br /&gt;
There are basically only two operations that control this chip, a read or write to 64 data registers and the process is similar for both read or write.&lt;br /&gt;
&lt;br /&gt;
* Reading Data&lt;br /&gt;
** Reading date/time&lt;br /&gt;
*** Open the I2C communication in write mode.&lt;br /&gt;
*** Set the register pointer to (0x00) - To read the date/time you reset the pointer to the first register.&lt;br /&gt;
*** End write mode.&lt;br /&gt;
*** Open I2C in read mode and read seven bytes of data.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  Wire.beginTransmission(DS1307_I2C_ADDRESS);   // Open I2C line in write mode&lt;br /&gt;
  Wire.send(0x00);                              // Set the register pointer to (0x00)&lt;br /&gt;
  Wire.endTransmission();                       // End Write Transmission &lt;br /&gt;
&lt;br /&gt;
  Wire.requestFrom(DS1307_I2C_ADDRESS, 7);      // Open the I2C line in send mode&lt;br /&gt;
&lt;br /&gt;
  second     = bcdToDec(Wire.receive() &amp;amp; 0x7f); // Read seven bytes of data&lt;br /&gt;
  minute     = bcdToDec(Wire.receive());&lt;br /&gt;
  hour       = bcdToDec(Wire.receive() &amp;amp; 0x3f);  &lt;br /&gt;
  dayOfWeek  = bcdToDec(Wire.receive());&lt;br /&gt;
  dayOfMonth = bcdToDec(Wire.receive());&lt;br /&gt;
  month      = bcdToDec(Wire.receive());&lt;br /&gt;
  year       = bcdToDec(Wire.receive());&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
** Reading Memory - The process is essentially the same as Reading date/time with two small differences&lt;br /&gt;
*** (1) You have to set the register pointer where you want to read the memory.&lt;br /&gt;
*** (2) You have to indicate how many bytes to read.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  Wire.beginTransmission(DS1307_I2C_ADDRESS);  &lt;br /&gt;
  Wire.send(0x08);                             // Set the register pointer to (0x08) to read first memory byte&lt;br /&gt;
  Wire.endTransmission();                      &lt;br /&gt;
&lt;br /&gt;
  Wire.requestFrom(DS1307_I2C_ADDRESS, 1);     // In this case only read one byte&lt;br /&gt;
&lt;br /&gt;
  temp_byte     = Wire.receive();              // Read the desired byte&lt;br /&gt;
  &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* Write date/time.&lt;br /&gt;
** Open the I2C communication in write mode.&lt;br /&gt;
** Set the register pointer to (0x00) - To write the date/time you reset the pointer to the first register.&lt;br /&gt;
** Write seven bytes of data.&lt;br /&gt;
** End write mode.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   Wire.beginTransmission(DS1307_I2C_ADDRESS);  // Open I2C line in write mode&lt;br /&gt;
&lt;br /&gt;
   Wire.send(0x00);                           // Set the register pointer to (0x00)&lt;br /&gt;
   Wire.send(decToBcd(second));               // Write seven bytes&lt;br /&gt;
   Wire.send(decToBcd(minute));&lt;br /&gt;
   Wire.send(decToBcd(hour));      &lt;br /&gt;
   Wire.send(decToBcd(dayOfWeek));&lt;br /&gt;
   Wire.send(decToBcd(dayOfMonth));&lt;br /&gt;
   Wire.send(decToBcd(month));&lt;br /&gt;
   Wire.send(decToBcd(year));&lt;br /&gt;
   Wire.endTransmission();                    // End write mode&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
** Writing Memory - The process is essentially the same as writing date/time with two small differences&lt;br /&gt;
*** (1) You have to set the register pointer where you want to write the memory.&lt;br /&gt;
*** (2) Now write the byte value you want in that memory location.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Note: You can continue writing and the register pointer will go to the next memory location. When the pointer reaches the end of the memory it will start back at the beginning, which will overwrite your date/time if you are not careful.''' &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  Wire.beginTransmission(DS1307_I2C_ADDRESS);  &lt;br /&gt;
  Wire.send(0xf3);                             // Set the register pointer to (0xf3) to write the 11th memory byte&lt;br /&gt;
  Wire.send(0xa6);                             // Write the desired byte value&lt;br /&gt;
  Wire.endTransmission();&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== RTC_DS1307_v.01 code ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
/*&lt;br /&gt;
 * RTC Control v.01&lt;br /&gt;
 * by &amp;lt;http://www.combustory.com&amp;gt; John Vaughters&lt;br /&gt;
 * Credit to:&lt;br /&gt;
 * Maurice Ribble - http://www.glacialwanderer.com/hobbyrobotics for RTC DS1307 code&lt;br /&gt;
 *&lt;br /&gt;
 * With this code you can set the date/time, retreive the date/time and use the extra memory of an RTC DS1307 chip.  &lt;br /&gt;
 * The program also sets all the extra memory space to 0xff.&lt;br /&gt;
 * Serial Communication method with the Arduino that utilizes a leading CHAR for each command described below. &lt;br /&gt;
 * Commands:&lt;br /&gt;
 * T(00-59)(00-59)(00-23)(1-7)(01-31)(01-12)(00-99) - T(sec)(min)(hour)(dayOfWeek)(dayOfMonth)(month)(year) - T Sets the date of the RTC DS1307 Chip. &lt;br /&gt;
 * Example to set the time for 02-Feb-09 @ 19:57:11 for the 3 day of the week, use this command - T1157193020209&lt;br /&gt;
 * Q(1-2) - (Q1) Memory initialization  (Q2) RTC - Memory Dump&lt;br /&gt;
 */&lt;br /&gt;
&lt;br /&gt;
#include &amp;quot;Wire.h&amp;quot;&lt;br /&gt;
#define DS1307_I2C_ADDRESS 0x68  // This is the I2C address&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
// Global Variables&lt;br /&gt;
&lt;br /&gt;
int command = 0;       // This is the command char, in ascii form, sent from the serial port     &lt;br /&gt;
int i;&lt;br /&gt;
long previousMillis = 0;        // will store last time Temp was updated&lt;br /&gt;
byte second, minute, hour, dayOfWeek, dayOfMonth, month, year;&lt;br /&gt;
byte test; &lt;br /&gt;
  &lt;br /&gt;
// Convert normal decimal numbers to binary coded decimal&lt;br /&gt;
byte decToBcd(byte val)&lt;br /&gt;
{&lt;br /&gt;
  return ( (val/10*16) + (val%10) );&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
// Convert binary coded decimal to normal decimal numbers&lt;br /&gt;
byte bcdToDec(byte val)&lt;br /&gt;
{&lt;br /&gt;
  return ( (val/16*10) + (val%16) );&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
// 1) Sets the date and time on the ds1307&lt;br /&gt;
// 2) Starts the clock&lt;br /&gt;
// 3) Sets hour mode to 24 hour clock&lt;br /&gt;
// Assumes you're passing in valid numbers, Probably need to put in checks for valid numbers.&lt;br /&gt;
 &lt;br /&gt;
void setDateDs1307()                &lt;br /&gt;
{&lt;br /&gt;
&lt;br /&gt;
   second = (byte) ((Serial.read() - 48) * 10 + (Serial.read() - 48)); // Use of (byte) type casting and ascii math to achieve result.  &lt;br /&gt;
   minute = (byte) ((Serial.read() - 48) *10 +  (Serial.read() - 48));&lt;br /&gt;
   hour  = (byte) ((Serial.read() - 48) *10 +  (Serial.read() - 48));&lt;br /&gt;
   dayOfWeek = (byte) (Serial.read() - 48);&lt;br /&gt;
   dayOfMonth = (byte) ((Serial.read() - 48) *10 +  (Serial.read() - 48));&lt;br /&gt;
   month = (byte) ((Serial.read() - 48) *10 +  (Serial.read() - 48));&lt;br /&gt;
   year= (byte) ((Serial.read() - 48) *10 +  (Serial.read() - 48));&lt;br /&gt;
   Wire.beginTransmission(DS1307_I2C_ADDRESS);&lt;br /&gt;
   Wire.send(0x00);&lt;br /&gt;
   Wire.send(decToBcd(second));    // 0 to bit 7 starts the clock&lt;br /&gt;
   Wire.send(decToBcd(minute));&lt;br /&gt;
   Wire.send(decToBcd(hour));      // If you want 12 hour am/pm you need to set&lt;br /&gt;
                                   // bit 6 (also need to change readDateDs1307)&lt;br /&gt;
   Wire.send(decToBcd(dayOfWeek));&lt;br /&gt;
   Wire.send(decToBcd(dayOfMonth));&lt;br /&gt;
   Wire.send(decToBcd(month));&lt;br /&gt;
   Wire.send(decToBcd(year));&lt;br /&gt;
   Wire.endTransmission();&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
// Gets the date and time from the ds1307 and prints result&lt;br /&gt;
void getDateDs1307()&lt;br /&gt;
{&lt;br /&gt;
  // Reset the register pointer&lt;br /&gt;
  Wire.beginTransmission(DS1307_I2C_ADDRESS);&lt;br /&gt;
  Wire.send(0x00);&lt;br /&gt;
  Wire.endTransmission();&lt;br /&gt;
&lt;br /&gt;
  Wire.requestFrom(DS1307_I2C_ADDRESS, 7);&lt;br /&gt;
&lt;br /&gt;
  // A few of these need masks because certain bits are control bits&lt;br /&gt;
  second     = bcdToDec(Wire.receive() &amp;amp; 0x7f);&lt;br /&gt;
  minute     = bcdToDec(Wire.receive());&lt;br /&gt;
  hour       = bcdToDec(Wire.receive() &amp;amp; 0x3f);  // Need to change this if 12 hour am/pm&lt;br /&gt;
  dayOfWeek  = bcdToDec(Wire.receive());&lt;br /&gt;
  dayOfMonth = bcdToDec(Wire.receive());&lt;br /&gt;
  month      = bcdToDec(Wire.receive());&lt;br /&gt;
  year       = bcdToDec(Wire.receive());&lt;br /&gt;
  &lt;br /&gt;
  Serial.print(hour, DEC);&lt;br /&gt;
  Serial.print(&amp;quot;:&amp;quot;);&lt;br /&gt;
  Serial.print(minute, DEC);&lt;br /&gt;
  Serial.print(&amp;quot;:&amp;quot;);&lt;br /&gt;
  Serial.print(second, DEC);&lt;br /&gt;
  Serial.print(&amp;quot;  &amp;quot;);&lt;br /&gt;
  Serial.print(month, DEC);&lt;br /&gt;
  Serial.print(&amp;quot;/&amp;quot;);&lt;br /&gt;
  Serial.print(dayOfMonth, DEC);&lt;br /&gt;
  Serial.print(&amp;quot;/&amp;quot;);&lt;br /&gt;
  Serial.print(year, DEC);&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
void setup() {&lt;br /&gt;
  Wire.begin();&lt;br /&gt;
  Serial.begin(57600);&lt;br /&gt;
 &lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
void loop() {&lt;br /&gt;
     if (Serial.available()) {      // Look for char in serial que and process if found&lt;br /&gt;
      command = Serial.read();&lt;br /&gt;
      if (command == 84) {      //If command = &amp;quot;T&amp;quot; Set Date&lt;br /&gt;
       setDateDs1307();&lt;br /&gt;
       getDateDs1307();&lt;br /&gt;
       Serial.println(&amp;quot; &amp;quot;);&lt;br /&gt;
      }&lt;br /&gt;
      else if (command == 81) {      //If command = &amp;quot;Q&amp;quot; RTC1307 Memory Functions&lt;br /&gt;
        delay(100);     &lt;br /&gt;
        if (Serial.available()) {&lt;br /&gt;
         command = Serial.read(); &lt;br /&gt;
         if (command == 49) {      //If command = &amp;quot;1&amp;quot; RTC1307 Initialize Memory - All Data will be set to 255 (0xff).  Therefore 255 or 0 will be an invalid value.  &lt;br /&gt;
          Wire.beginTransmission(DS1307_I2C_ADDRESS); // 255 will be the init value and 0 will be considered an error that occurs when the RTC is in Battery mode.&lt;br /&gt;
          Wire.send(0x08); // Set the register pointer to be just past the date/time registers.&lt;br /&gt;
         for (i = 1; i &amp;lt;= 27; i++) {&lt;br /&gt;
             Wire.send(0xff);&lt;br /&gt;
            delay(100);&lt;br /&gt;
         }   &lt;br /&gt;
         Wire.endTransmission();&lt;br /&gt;
         getDateDs1307();&lt;br /&gt;
         Serial.println(&amp;quot;: RTC1307 Initialized Memory&amp;quot;);&lt;br /&gt;
         }&lt;br /&gt;
         else if (command == 50) {      //If command = &amp;quot;2&amp;quot; RTC1307 Memory Dump&lt;br /&gt;
          getDateDs1307();&lt;br /&gt;
          Serial.println(&amp;quot;: RTC 1307 Dump Begin&amp;quot;);&lt;br /&gt;
          Wire.beginTransmission(DS1307_I2C_ADDRESS);&lt;br /&gt;
          Wire.send(0x00);&lt;br /&gt;
          Wire.endTransmission();&lt;br /&gt;
          Wire.requestFrom(DS1307_I2C_ADDRESS, 64);&lt;br /&gt;
          for (i = 1; i &amp;lt;= 64; i++) {&lt;br /&gt;
             test = Wire.receive();&lt;br /&gt;
             Serial.print(i);&lt;br /&gt;
             Serial.print(&amp;quot;:&amp;quot;);&lt;br /&gt;
             Serial.println(test, DEC);&lt;br /&gt;
          }&lt;br /&gt;
          Serial.println(&amp;quot; RTC1307 Dump end&amp;quot;);&lt;br /&gt;
         } &lt;br /&gt;
        }  &lt;br /&gt;
       }&lt;br /&gt;
      Serial.print(&amp;quot;Command: &amp;quot;);&lt;br /&gt;
      Serial.println(command);     // Echo command CHAR in ascii that was sent&lt;br /&gt;
      }&lt;br /&gt;
      &lt;br /&gt;
      command = 0;                 // reset command &lt;br /&gt;
      delay(100);&lt;br /&gt;
    }&lt;br /&gt;
//*****************************************************The End***********************&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== RTC_DS1307_v.01 User Guide ==&lt;br /&gt;
&lt;br /&gt;
Not much to say here, I tend to use the Arduino in the [[Arduino Communications]] Method, so maybe someday I will present the other part of the controlling SW I made for this tool, but I will have to make changes to get it to work correctly for this particular set-up.  &lt;br /&gt;
&lt;br /&gt;
For now just enter the commands from the Arduino Environment or your favorite serial communications method.&lt;br /&gt;
&lt;br /&gt;
==== Commands ====&lt;br /&gt;
&lt;br /&gt;
* T(00-59)(00-59)(00-23)(1-7)(01-31)(01-12)(00-99) - T(sec)(min)(hour)(dayOfWeek)(dayOfMonth)(month)(year) - T Sets the date of the RTC DS1307 Chip. &lt;br /&gt;
** Example to set the time for 02-Feb-09 @ 19:57:11 for the 3 day of the week, use this command - T1157193020209&lt;br /&gt;
* Q1 - This command will initialize all the non date/time memory to 255 (0xff)&lt;br /&gt;
** I do this because when the RTC DS1307 goes into back up mode it returns 0 for any register, so for memory usage a 0 will be considered a failure to read memory and 255 will be a default value. Meaning it is considered null.&lt;br /&gt;
* Q2 - This command will Dump all 64 registers to the serial buffer&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Electronics]]&lt;/div&gt;</summary>
		<author><name>Combustor</name></author>	</entry>

	<entry>
		<id>http://combustory.com/wiki/index.php/Talk:Arduino_Communications</id>
		<title>Talk:Arduino Communications</title>
		<link rel="alternate" type="text/html" href="http://combustory.com/wiki/index.php/Talk:Arduino_Communications"/>
				<updated>2008-12-01T17:05:32Z</updated>
		
		<summary type="html">&lt;p&gt;Combustor: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Notes from Creator = &lt;br /&gt;
1 Dec 08 - Roland has provided an alternate solution that I have not investigated yet. By all means I recommend to look for a smoother way to accomplish this task, and please report any successes.  Right now I have invested my time and my method works for my needs, some day I may evaluate other ways as well.&lt;br /&gt;
&lt;br /&gt;
If you are like me and you are always on the lookout for a step by step that reduces your development time, then my method does work great and I built my specific windows Apps quite a bit since I authored this solution.&lt;br /&gt;
&lt;br /&gt;
One note on his comment concerning the resetting of the board.  My method does not reset the board as long as stty command remains active with the Arduino, and it does not disconnect unless there is a power failure, so this is not an issue.&lt;br /&gt;
&lt;br /&gt;
I would love to hear more comments.&lt;br /&gt;
&lt;br /&gt;
== 22 Nov 08 Discussion From Roland Latour ==&lt;br /&gt;
&lt;br /&gt;
Communication with Arduino Diecimila under linux is not that difficult.&lt;br /&gt;
The instructions at arduino.cc recommend using 'screen', which actually forks&lt;br /&gt;
a child of itself to handle responses from the board. You can do the same&lt;br /&gt;
from the bash shell. First, start a helper program:&lt;br /&gt;
  cat /dev/ttyUSB0 &amp;gt;&amp;gt; logfile1.raw &amp;amp;&lt;br /&gt;
When you unplug the Diecimila, ttyUSB0 goes away, causing this job to exit.&lt;br /&gt;
You also need this because without a process holding open the connection,&lt;br /&gt;
the Diecimila resets itself after every command.&lt;br /&gt;
&lt;br /&gt;
Then send commands to the unit. Here's a sample that sends 'r a' to Simple&lt;br /&gt;
Message System on the Diecimila to read the analog ports:&lt;br /&gt;
  /bin/echo -e -n &amp;quot;r a\r&amp;quot; &amp;gt; /dev/ttyUSB0&lt;br /&gt;
Then get the results with this command:&lt;br /&gt;
  tail -1 logfile1.raw&lt;br /&gt;
That's it! Everything else is window dressing.&lt;br /&gt;
&lt;br /&gt;
As proof of concept, check out my package of shell scripts to talk to&lt;br /&gt;
Simple Message System. Full IO &amp;amp; PWM control. AD is scaled to milliVolts&lt;br /&gt;
and formatted for import to most spreadsheets. Navigate to&lt;br /&gt;
  http://user.cavenet.com/rolandl&lt;br /&gt;
and download SMS1.tgz, a tar gzip'd archive file. Unpack it with:&lt;br /&gt;
  tar xvzf SMS1.tgz&lt;br /&gt;
You can't (under GPLv2) remove my name and claim it as your own, but you&lt;br /&gt;
can take it apart and re-assemble the pieces in new &amp;amp; interesting ways&lt;br /&gt;
(I hope you do). Written under Kubuntu, other OSes may vary (especially Slackware!) Questions: contact rolandl@cavenet.com. I hope you find&lt;br /&gt;
this useful.  -Roland Latour&lt;/div&gt;</summary>
		<author><name>Combustor</name></author>	</entry>

	<entry>
		<id>http://combustory.com/wiki/index.php/Talk:Arduino_Communications</id>
		<title>Talk:Arduino Communications</title>
		<link rel="alternate" type="text/html" href="http://combustory.com/wiki/index.php/Talk:Arduino_Communications"/>
				<updated>2008-12-01T17:02:08Z</updated>
		
		<summary type="html">&lt;p&gt;Combustor: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Notes from Creator = &lt;br /&gt;
1 Dec 08 - Roland has provided an alternate solution that I have not investigated yet. By all means I recommend to look for a smoother way to accomplish this task, and please report any successes.  Right now I have invested my time and my method works for my needs, some day I may evaluate other ways as well.  I also want to give Roland credit for the inspiration of his SMS solution, which I reviewed before I made my solution.  I liked his ideas and I used his basic concept to forge my method as well. &lt;br /&gt;
&lt;br /&gt;
If you are like me and you are always on the lookout for a step by step that reduces your development time, then my method does work great and I built my specific windows Apps quite a bit since I authored this solution.&lt;br /&gt;
&lt;br /&gt;
One note on his comment concerning the resetting of the board.  My method does not reset the board as long as stty command remains active with the Arduino.&lt;br /&gt;
&lt;br /&gt;
I would love to hear more comments.&lt;br /&gt;
&lt;br /&gt;
== 22 Nov 08 Discussion From Roland Latour ==&lt;br /&gt;
&lt;br /&gt;
Communication with Arduino Diecimila under linux is not that difficult.&lt;br /&gt;
The instructions at arduino.cc recommend using 'screen', which actually forks&lt;br /&gt;
a child of itself to handle responses from the board. You can do the same&lt;br /&gt;
from the bash shell. First, start a helper program:&lt;br /&gt;
  cat /dev/ttyUSB0 &amp;gt;&amp;gt; logfile1.raw &amp;amp;&lt;br /&gt;
When you unplug the Diecimila, ttyUSB0 goes away, causing this job to exit.&lt;br /&gt;
You also need this because without a process holding open the connection,&lt;br /&gt;
the Diecimila resets itself after every command.&lt;br /&gt;
&lt;br /&gt;
Then send commands to the unit. Here's a sample that sends 'r a' to Simple&lt;br /&gt;
Message System on the Diecimila to read the analog ports:&lt;br /&gt;
  /bin/echo -e -n &amp;quot;r a\r&amp;quot; &amp;gt; /dev/ttyUSB0&lt;br /&gt;
Then get the results with this command:&lt;br /&gt;
  tail -1 logfile1.raw&lt;br /&gt;
That's it! Everything else is window dressing.&lt;br /&gt;
&lt;br /&gt;
As proof of concept, check out my package of shell scripts to talk to&lt;br /&gt;
Simple Message System. Full IO &amp;amp; PWM control. AD is scaled to milliVolts&lt;br /&gt;
and formatted for import to most spreadsheets. Navigate to&lt;br /&gt;
  http://user.cavenet.com/rolandl&lt;br /&gt;
and download SMS1.tgz, a tar gzip'd archive file. Unpack it with:&lt;br /&gt;
  tar xvzf SMS1.tgz&lt;br /&gt;
You can't (under GPLv2) remove my name and claim it as your own, but you&lt;br /&gt;
can take it apart and re-assemble the pieces in new &amp;amp; interesting ways&lt;br /&gt;
(I hope you do). Written under Kubuntu, other OSes may vary (especially Slackware!) Questions: contact rolandl@cavenet.com. I hope you find&lt;br /&gt;
this useful.  -Roland Latour&lt;/div&gt;</summary>
		<author><name>Combustor</name></author>	</entry>

	<entry>
		<id>http://combustory.com/wiki/index.php/Arduino_Electronics</id>
		<title>Arduino Electronics</title>
		<link rel="alternate" type="text/html" href="http://combustory.com/wiki/index.php/Arduino_Electronics"/>
				<updated>2008-09-26T20:07:16Z</updated>
		
		<summary type="html">&lt;p&gt;Combustor: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{default}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Summary ==&lt;br /&gt;
&lt;br /&gt;
Arduino is an open-source hardware platform.  It is a micro controller with a free development environment that is greatly simplified for programming the controller. Visit this website for further details, http://www.arduino.cc/&lt;br /&gt;
&lt;br /&gt;
== Topics ==&lt;br /&gt;
&lt;br /&gt;
* [[Arduino Communications]] - A distributed network approach&lt;br /&gt;
* [[Temperature Controller]] - A/C control for multi-room space with air duct throttling (ie. Smart Thermostat)&lt;br /&gt;
* [[X9241A - Digital Potentiometer]] - Arduino code for using I2C to control this Digital Potentiometer&lt;br /&gt;
* [[MPGuino]] - An MPG gauge based on the Arduino Platform&lt;br /&gt;
* Suggestions Welcome&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Links ==&lt;br /&gt;
[[Category:Electronics]]&lt;/div&gt;</summary>
		<author><name>Combustor</name></author>	</entry>

	<entry>
		<id>http://combustory.com/wiki/index.php/X9241A_-_Digital_Potentiometer</id>
		<title>X9241A - Digital Potentiometer</title>
		<link rel="alternate" type="text/html" href="http://combustory.com/wiki/index.php/X9241A_-_Digital_Potentiometer"/>
				<updated>2008-09-26T00:03:53Z</updated>
		
		<summary type="html">&lt;p&gt;Combustor: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{default}}&lt;br /&gt;
&lt;br /&gt;
== Summary ==&lt;br /&gt;
This code shows how to communicate with the X9241A Digital Potentiometer.  I plan on updating this info eventually to explain this chip, but for now you will probably want to get the data sheet to help with understanding what was done here.  The bottom line is that I have created this program to accept commands via serial commands to set the storage registers to certain values and to modify the pot registers to change based on serial commands. I have not figured out how to read the registers, but that is not so important to my application.&lt;br /&gt;
&lt;br /&gt;
== Method ==&lt;br /&gt;
=== I2C ===&lt;br /&gt;
&lt;br /&gt;
There are basically only two functions that I am after right now which are both three byte instructions: &lt;br /&gt;
&lt;br /&gt;
* Read WCR(Wiper Control Register) for the four potentiometers 0-3 (So far this is failing miserably)&lt;br /&gt;
** Send 1st byte - Address (my circuit - 01011010 or 0x2D)(binary - 0101 A3 A2 A1 A0) A values are actual pins set to high or low for an address.&lt;br /&gt;
** Send 2nd byte - Instruction (binary - 1001 (1/0)(1/0) 00) - The two bits are used to choose the potentiometer&lt;br /&gt;
** Read WCR requested Byte&lt;br /&gt;
* Write WCR for the four potentiometers 0-3 (This works)&lt;br /&gt;
** Send 1st byte - Address (my circuit - 01011010 or 0x2D)(binary - 0101 A3 A2 A1 A0) A values are actual pins set to high or low for an address.&lt;br /&gt;
** Send 2nd byte - Instruction (binary - 1010 (1/0)(1/0) 00) - The two bits are used to choose the potentiometer&lt;br /&gt;
** Send WCR Byte - Potentiometer value (binary - 00 D5 D4 D3 D2 D1 D0) - D values are the 0-63 potentiometer positions&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== x9241A_Digital_Potentiometer_v.01 code ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
/*&lt;br /&gt;
 * x9241A Digital Potentiometer v.01&lt;br /&gt;
 * by &amp;lt;http://www.combustory.com&amp;gt; John Vaughters&lt;br /&gt;
 *&lt;br /&gt;
 * This Program illustrates the use of I2C to set up the x9241A Digital Potentiometer by setting and transferring the registers.&lt;br /&gt;
 * I attempted to read the register data through I2C, but was unable to get it to work.&lt;br /&gt;
 * Since the reading part was not so important to me I stopped trying.  &lt;br /&gt;
 * To set the registers up and transfer them to the Wiper registers met my goals and that is where I stopped.&lt;br /&gt;
 *&lt;br /&gt;
 * The x9142A has four Digital Pots and each pot has four static registers and one dynamic register the Wiper Control Register (WCR). &lt;br /&gt;
 * Therefore, there are 16 total bytes of storage and four WCR's.&lt;br /&gt;
 * This Program has the following commands:&lt;br /&gt;
 * S - Set the 16 registers.  Each pot has four registers and this command will set each register group with the same value. So register 00 for each pot will&lt;br /&gt;
 *     be the same value for each pot, and the same for register 01 through 11.&lt;br /&gt;
 * G(0-3) - Global Transfer of Registers to the WCR's.  This command will bulk load the values stored in registers into the WCR's.  &lt;br /&gt;
 *          For example, a G0 will load the 00 register for each pot into the WCR in one command. A G1 loads the 01 register for each pot, etc.&lt;br /&gt;
 * (0-3)(0-3) - This set of commands transfers a single register into a single WCR. The digits are arranged like this (WCR)(Reg). &lt;br /&gt;
 *              For example, a 00 command will load register 00 into WCR 00 or a 13 command will load register 11 into WCR 01, etc.&lt;br /&gt;
 * W(0-3) - This command writes directly to the WCR.  I have created four values that are just random, but the command shows how to write directly to the WCR for each pot.&lt;br /&gt;
 *          For example, a W0 command will write a value of decimal 16.  These commands are just for example purposes.&lt;br /&gt;
 *&lt;br /&gt;
 * Command Note: If you enter a command that is not recognized, then it is ignored and nothing happens and nothing is printed.&lt;br /&gt;
 */&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
#include &amp;quot;Wire.h&amp;quot;&lt;br /&gt;
#define X9241_I2C_ADDRESS 0x2D&lt;br /&gt;
&lt;br /&gt;
// Global Variables&lt;br /&gt;
long command;&lt;br /&gt;
  &lt;br /&gt;
&lt;br /&gt;
void setup() {&lt;br /&gt;
  Wire.begin();&lt;br /&gt;
  Serial.begin(57600);&lt;br /&gt;
  &lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
void loop() {&lt;br /&gt;
   if (Serial.available()) {      // Look for char in serial que and process if found&lt;br /&gt;
      command = Serial.read();&lt;br /&gt;
      if (command == 83) {      //If command = &amp;quot;S&amp;quot; Set Register Data&lt;br /&gt;
      // This sets the four registers of each Digital Pot&lt;br /&gt;
          Wire.beginTransmission(X9241_I2C_ADDRESS);&lt;br /&gt;
          Wire.send(0xc0);  // This is the set register command c and the 16 registers are 0-f&lt;br /&gt;
          Wire.send(0x0a);  // This line is the value to set the register: 0-63 is a valid setting&lt;br /&gt;
          Wire.endTransmission(); &lt;br /&gt;
          delay(100);&lt;br /&gt;
          Wire.beginTransmission(X9241_I2C_ADDRESS);&lt;br /&gt;
          Wire.send(0xc1);&lt;br /&gt;
          Wire.send(0x14);&lt;br /&gt;
          Wire.endTransmission();&lt;br /&gt;
          delay(100);&lt;br /&gt;
          Wire.beginTransmission(X9241_I2C_ADDRESS);&lt;br /&gt;
          Wire.send(0xc2);&lt;br /&gt;
          Wire.send(0x20);&lt;br /&gt;
          Wire.endTransmission();&lt;br /&gt;
          delay(100);&lt;br /&gt;
          Wire.beginTransmission(X9241_I2C_ADDRESS);&lt;br /&gt;
          Wire.send(0xc3);&lt;br /&gt;
          Wire.send(0x3c);&lt;br /&gt;
          Wire.endTransmission();&lt;br /&gt;
          delay(100);&lt;br /&gt;
          Wire.beginTransmission(X9241_I2C_ADDRESS);&lt;br /&gt;
          Wire.send(0xc4);&lt;br /&gt;
          Wire.send(0x0a);&lt;br /&gt;
          Wire.endTransmission(); &lt;br /&gt;
          delay(100);&lt;br /&gt;
          Wire.beginTransmission(X9241_I2C_ADDRESS);&lt;br /&gt;
          Wire.send(0xc5);&lt;br /&gt;
          Wire.send(0x14);&lt;br /&gt;
          Wire.endTransmission();&lt;br /&gt;
          delay(100);&lt;br /&gt;
          Wire.beginTransmission(X9241_I2C_ADDRESS);&lt;br /&gt;
          Wire.send(0xc6);&lt;br /&gt;
          Wire.send(0x20);&lt;br /&gt;
          Wire.endTransmission();&lt;br /&gt;
          delay(100);&lt;br /&gt;
          Wire.beginTransmission(X9241_I2C_ADDRESS);&lt;br /&gt;
          Wire.send(0xc7);&lt;br /&gt;
          Wire.send(0x3c);&lt;br /&gt;
          Wire.endTransmission();&lt;br /&gt;
          delay(100);          &lt;br /&gt;
          Wire.beginTransmission(X9241_I2C_ADDRESS);&lt;br /&gt;
          Wire.send(0xc8);&lt;br /&gt;
          Wire.send(0x0a);&lt;br /&gt;
          Wire.endTransmission(); &lt;br /&gt;
          delay(100);&lt;br /&gt;
          Wire.beginTransmission(X9241_I2C_ADDRESS);&lt;br /&gt;
          Wire.send(0xc9);&lt;br /&gt;
          Wire.send(0x14);&lt;br /&gt;
          Wire.endTransmission();&lt;br /&gt;
          delay(100);&lt;br /&gt;
          Wire.beginTransmission(X9241_I2C_ADDRESS);&lt;br /&gt;
          Wire.send(0xca);&lt;br /&gt;
          Wire.send(0x20);&lt;br /&gt;
          Wire.endTransmission();&lt;br /&gt;
          delay(100);&lt;br /&gt;
          Wire.beginTransmission(X9241_I2C_ADDRESS);&lt;br /&gt;
          Wire.send(0xcb);&lt;br /&gt;
          Wire.send(0x3c);&lt;br /&gt;
          Wire.endTransmission();&lt;br /&gt;
          delay(100);&lt;br /&gt;
          Wire.beginTransmission(X9241_I2C_ADDRESS);&lt;br /&gt;
          Wire.send(0xcc);&lt;br /&gt;
          Wire.send(0x0a);&lt;br /&gt;
          Wire.endTransmission(); &lt;br /&gt;
          delay(100);&lt;br /&gt;
          Wire.beginTransmission(X9241_I2C_ADDRESS);&lt;br /&gt;
          Wire.send(0xcd);&lt;br /&gt;
          Wire.send(0x14);&lt;br /&gt;
          Wire.endTransmission();&lt;br /&gt;
          delay(100);&lt;br /&gt;
          Wire.beginTransmission(X9241_I2C_ADDRESS);&lt;br /&gt;
          Wire.send(0xce);&lt;br /&gt;
          Wire.send(0x20);&lt;br /&gt;
          Wire.endTransmission();&lt;br /&gt;
          delay(100);&lt;br /&gt;
          Wire.beginTransmission(X9241_I2C_ADDRESS);&lt;br /&gt;
          Wire.send(0xcf);&lt;br /&gt;
          Wire.send(0x3c);&lt;br /&gt;
          Serial.println(&amp;quot;cmd: S&amp;quot;);&lt;br /&gt;
       }   &lt;br /&gt;
       else if (command == 71) {      //If command = &amp;quot;G&amp;quot; Transfer Global Register Data   &lt;br /&gt;
        delay(100);&lt;br /&gt;
        if (Serial.available()) {&lt;br /&gt;
         command = Serial.read(); &lt;br /&gt;
         if (command == 48) {        // If command = &amp;quot;0&amp;quot; &lt;br /&gt;
          Wire.beginTransmission(X9241_I2C_ADDRESS);&lt;br /&gt;
          Wire.send(0x10); // Global Load WCR's with Reg-00&lt;br /&gt;
          Wire.endTransmission();&lt;br /&gt;
          Serial.println(&amp;quot;cmd: G0&amp;quot;);&lt;br /&gt;
         }&lt;br /&gt;
         else if (command == 49) {        // If command = &amp;quot;1&amp;quot; &lt;br /&gt;
          Wire.beginTransmission(X9241_I2C_ADDRESS);&lt;br /&gt;
          Wire.send(0x11); // Global Load WCR's with Reg-01&lt;br /&gt;
          Wire.endTransmission();&lt;br /&gt;
          Serial.println(&amp;quot;cmd: G1&amp;quot;);&lt;br /&gt;
         }&lt;br /&gt;
         else if (command == 50) {        // If command = &amp;quot;2&amp;quot; &lt;br /&gt;
          Wire.beginTransmission(X9241_I2C_ADDRESS);&lt;br /&gt;
          Wire.send(0x12); // Global Load WCR's with Reg-10&lt;br /&gt;
          Wire.endTransmission();&lt;br /&gt;
          Serial.println(&amp;quot;cmd: G2&amp;quot;);&lt;br /&gt;
         }&lt;br /&gt;
         else if (command == 51) {        // If command = &amp;quot;3&amp;quot; &lt;br /&gt;
          Wire.beginTransmission(X9241_I2C_ADDRESS);&lt;br /&gt;
          Wire.send(0x13); // Global Load WCR's with Reg-11&lt;br /&gt;
          Wire.endTransmission();&lt;br /&gt;
          Serial.println(&amp;quot;cmd: G3&amp;quot;);&lt;br /&gt;
         }&lt;br /&gt;
        }&lt;br /&gt;
       }&lt;br /&gt;
       &lt;br /&gt;
       else if (command == 48) {      //If command = &amp;quot;0&amp;quot; Transfer Register-00 Data to WCR 0-3&lt;br /&gt;
         delay(100);&lt;br /&gt;
         if (Serial.available()) {&lt;br /&gt;
         command = Serial.read(); &lt;br /&gt;
         if (command == 48) {              // If command = &amp;quot;0&amp;quot; &lt;br /&gt;
          Wire.beginTransmission(X9241_I2C_ADDRESS);&lt;br /&gt;
          Wire.send(0xd0); // Load WCR-00 with Reg-00&lt;br /&gt;
          Wire.endTransmission();&lt;br /&gt;
          Serial.println(&amp;quot;cmd: 00&amp;quot;);&lt;br /&gt;
         }&lt;br /&gt;
         else if (command == 49) {        // If command = &amp;quot;1&amp;quot; &lt;br /&gt;
          Wire.beginTransmission(X9241_I2C_ADDRESS);&lt;br /&gt;
          Wire.send(0xd1); // Load WCR-00 with Reg-01&lt;br /&gt;
          Wire.endTransmission();&lt;br /&gt;
          Serial.println(&amp;quot;cmd: 01&amp;quot;);&lt;br /&gt;
         }&lt;br /&gt;
         else if (command == 50) {        // If command = &amp;quot;2&amp;quot; &lt;br /&gt;
          Wire.beginTransmission(X9241_I2C_ADDRESS);&lt;br /&gt;
          Wire.send(0xd2); // Load WCR-00 with Reg-10&lt;br /&gt;
          Wire.endTransmission();&lt;br /&gt;
          Serial.println(&amp;quot;cmd: 02&amp;quot;);&lt;br /&gt;
         }&lt;br /&gt;
         else if (command == 51) {        // If command = &amp;quot;3&amp;quot; &lt;br /&gt;
          Wire.beginTransmission(X9241_I2C_ADDRESS);&lt;br /&gt;
          Wire.send(0xd3); // Load WCR-00 with Reg-11&lt;br /&gt;
          Wire.endTransmission();&lt;br /&gt;
          Serial.println(&amp;quot;cmd: 03&amp;quot;);&lt;br /&gt;
         }&lt;br /&gt;
        }&lt;br /&gt;
       }&lt;br /&gt;
        else if (command == 49) {      //If command = &amp;quot;1&amp;quot; Transfer Register-01 Data to WCR 0-3&lt;br /&gt;
         delay(100);&lt;br /&gt;
         if (Serial.available()) {&lt;br /&gt;
         command = Serial.read(); &lt;br /&gt;
          if (command == 48) {              // If command = &amp;quot;0&amp;quot; &lt;br /&gt;
           Wire.beginTransmission(X9241_I2C_ADDRESS);&lt;br /&gt;
           Wire.send(0xd4); // Load WCR-01 with Reg-00&lt;br /&gt;
           Wire.endTransmission();&lt;br /&gt;
           Serial.println(&amp;quot;cmd: 10&amp;quot;);&lt;br /&gt;
          }&lt;br /&gt;
          else if (command == 49) {        // If command = &amp;quot;1&amp;quot; &lt;br /&gt;
           Wire.beginTransmission(X9241_I2C_ADDRESS);&lt;br /&gt;
           Wire.send(0xd5); // Load WCR-01 with Reg-01&lt;br /&gt;
           Wire.endTransmission();&lt;br /&gt;
           Serial.println(&amp;quot;cmd: 11&amp;quot;);&lt;br /&gt;
          }&lt;br /&gt;
          else if (command == 50) {        // If command = &amp;quot;2&amp;quot; &lt;br /&gt;
           Wire.beginTransmission(X9241_I2C_ADDRESS);&lt;br /&gt;
           Wire.send(0xd6); // Load WCR-01 with Reg-10&lt;br /&gt;
           Wire.endTransmission();&lt;br /&gt;
           Serial.println(&amp;quot;cmd: 12&amp;quot;);&lt;br /&gt;
          }&lt;br /&gt;
          else if (command == 51) {        // If command = &amp;quot;3&amp;quot; &lt;br /&gt;
           Wire.beginTransmission(X9241_I2C_ADDRESS);&lt;br /&gt;
           Wire.send(0xd7); // Load WCR-01 with Reg-11&lt;br /&gt;
           Wire.endTransmission();&lt;br /&gt;
           Serial.println(&amp;quot;cmd: 13&amp;quot;);&lt;br /&gt;
          }&lt;br /&gt;
         }&lt;br /&gt;
        }&lt;br /&gt;
        else if (command == 50) {      //If command = &amp;quot;2&amp;quot; Transfer Register-10 Data to WCR 0-3&lt;br /&gt;
         if (Serial.available()) {&lt;br /&gt;
          command = Serial.read(); &lt;br /&gt;
          if (command == 48) {              // If command = &amp;quot;0&amp;quot; &lt;br /&gt;
           Wire.beginTransmission(X9241_I2C_ADDRESS);&lt;br /&gt;
           Wire.send(0xd8); // Load WCR-10 with Reg-00&lt;br /&gt;
           Wire.endTransmission();&lt;br /&gt;
           Serial.println(&amp;quot;cmd: 20&amp;quot;);&lt;br /&gt;
          }&lt;br /&gt;
         else if (command == 49) {        // If command = &amp;quot;1&amp;quot; &lt;br /&gt;
          Wire.beginTransmission(X9241_I2C_ADDRESS);&lt;br /&gt;
          Wire.send(0xd9); // Load WCR-10 with Reg-01&lt;br /&gt;
          Wire.endTransmission();&lt;br /&gt;
          Serial.println(&amp;quot;cmd: 21&amp;quot;);&lt;br /&gt;
         }&lt;br /&gt;
         else if (command == 50) {        // If command = &amp;quot;2&amp;quot; &lt;br /&gt;
          Wire.beginTransmission(X9241_I2C_ADDRESS);&lt;br /&gt;
          Wire.send(0xda); // Load WCR-10 with Reg-10&lt;br /&gt;
          Wire.endTransmission();&lt;br /&gt;
          Serial.println(&amp;quot;cmd: 22&amp;quot;);&lt;br /&gt;
         }&lt;br /&gt;
         else if (command == 51) {        // If command = &amp;quot;3&amp;quot; &lt;br /&gt;
          Wire.beginTransmission(X9241_I2C_ADDRESS);&lt;br /&gt;
          Wire.send(0xdb); // Load WCR-10 with Reg-11&lt;br /&gt;
          Wire.endTransmission();&lt;br /&gt;
          Serial.println(&amp;quot;cmd: 23&amp;quot;);&lt;br /&gt;
         }&lt;br /&gt;
        }&lt;br /&gt;
       }&lt;br /&gt;
       else if (command == 51) {      //If command = &amp;quot;3&amp;quot; Transfer Register-11 Data to WCR 0-3&lt;br /&gt;
        delay(100);&lt;br /&gt;
        if (Serial.available()) {&lt;br /&gt;
         command = Serial.read(); &lt;br /&gt;
        if (command == 48) {              // If command = &amp;quot;0&amp;quot; &lt;br /&gt;
          Wire.beginTransmission(X9241_I2C_ADDRESS);&lt;br /&gt;
          Wire.send(0xdc); // Load WCR-11 with Reg-00&lt;br /&gt;
          Wire.endTransmission();&lt;br /&gt;
          Serial.println(&amp;quot;cmd: 30&amp;quot;);&lt;br /&gt;
         }&lt;br /&gt;
         else if (command == 49) {        // If command = &amp;quot;1&amp;quot; &lt;br /&gt;
          Wire.beginTransmission(X9241_I2C_ADDRESS);&lt;br /&gt;
          Wire.send(0xdd); // Load WCR-11 with Reg-01&lt;br /&gt;
          Wire.endTransmission();&lt;br /&gt;
          Serial.println(&amp;quot;cmd: 31&amp;quot;);&lt;br /&gt;
         }&lt;br /&gt;
         else if (command == 50) {        // If command = &amp;quot;2&amp;quot; &lt;br /&gt;
          Wire.beginTransmission(X9241_I2C_ADDRESS);&lt;br /&gt;
          Wire.send(0xde); // Load WCR-11 with Reg-10&lt;br /&gt;
          Wire.endTransmission();&lt;br /&gt;
          Serial.println(&amp;quot;cmd: 32&amp;quot;);&lt;br /&gt;
         }&lt;br /&gt;
         else if (command == 51) {        // If command = &amp;quot;3&amp;quot; &lt;br /&gt;
          Wire.beginTransmission(X9241_I2C_ADDRESS);&lt;br /&gt;
          Wire.send(0xdf); // Load WCR-11 with Reg-11&lt;br /&gt;
          Wire.endTransmission();&lt;br /&gt;
          Serial.println(&amp;quot;cmd: 33&amp;quot;);&lt;br /&gt;
         }&lt;br /&gt;
        }&lt;br /&gt;
       }&lt;br /&gt;
       else if (command == 87) {      //If command = &amp;quot;W&amp;quot; write directly to WCR 0-3&lt;br /&gt;
        delay(100);&lt;br /&gt;
        if (Serial.available()) {&lt;br /&gt;
         command = Serial.read(); &lt;br /&gt;
        if (command == 48) {              // If command = &amp;quot;0&amp;quot; &lt;br /&gt;
          Wire.beginTransmission(X9241_I2C_ADDRESS);&lt;br /&gt;
          Wire.send(0xa0); //Instruction to write WCR-00&lt;br /&gt;
          Wire.send(0x10); //Send a D value of 16&lt;br /&gt;
          Wire.endTransmission();&lt;br /&gt;
          Serial.println(&amp;quot;cmd: W0&amp;quot;);&lt;br /&gt;
         }&lt;br /&gt;
         else if (command == 49) {        // If command = &amp;quot;1&amp;quot; &lt;br /&gt;
          Wire.beginTransmission(X9241_I2C_ADDRESS);&lt;br /&gt;
          Wire.send(0xa4); //Instruction to write WCR-01&lt;br /&gt;
          Wire.send(0x20); //Send a D value of 32&lt;br /&gt;
          Wire.endTransmission();&lt;br /&gt;
          Serial.println(&amp;quot;cmd: W1&amp;quot;);&lt;br /&gt;
         }&lt;br /&gt;
         else if (command == 50) {        // If command = &amp;quot;2&amp;quot; &lt;br /&gt;
          Wire.beginTransmission(X9241_I2C_ADDRESS);&lt;br /&gt;
          Wire.send(0xa8); //Instruction to write WCR-10&lt;br /&gt;
          Wire.send(0x2a); //Send a D value of 26&lt;br /&gt;
          Wire.endTransmission();&lt;br /&gt;
          Serial.println(&amp;quot;cmd: W2&amp;quot;);&lt;br /&gt;
         }&lt;br /&gt;
         else if (command == 51) {        // If command = &amp;quot;3&amp;quot; &lt;br /&gt;
          Wire.beginTransmission(X9241_I2C_ADDRESS);&lt;br /&gt;
          Wire.send(0xac); //Instruction to write WCR-11&lt;br /&gt;
          Wire.send(0x30); //Send a D value of 48&lt;br /&gt;
          Wire.endTransmission();&lt;br /&gt;
          Serial.println(&amp;quot;cmd: W3&amp;quot;);&lt;br /&gt;
         }&lt;br /&gt;
        }&lt;br /&gt;
       }&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
//*****************************************************The End***********************&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== x9241A_Digital_Potentiometer_v.01 User Guide ==&lt;br /&gt;
==== Commands ====&lt;br /&gt;
[[Category:Electronics]]&lt;/div&gt;</summary>
		<author><name>Combustor</name></author>	</entry>

	<entry>
		<id>http://combustory.com/wiki/index.php/Temperature_Controller</id>
		<title>Temperature Controller</title>
		<link rel="alternate" type="text/html" href="http://combustory.com/wiki/index.php/Temperature_Controller"/>
				<updated>2008-09-26T00:02:55Z</updated>
		
		<summary type="html">&lt;p&gt;Combustor: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{default}}&lt;br /&gt;
== Warning ==&lt;br /&gt;
'''This page is in progress and none of the code can be considered good or complete. I am just using this as an alternate storage of the code for right now.'''&lt;br /&gt;
&lt;br /&gt;
== Summary ==&lt;br /&gt;
== Functional Description of the Method ==&lt;br /&gt;
== Requirements ==&lt;br /&gt;
== Example of Method ==&lt;br /&gt;
=== Quick Guide: ===&lt;br /&gt;
=== Detailed Guide: ===&lt;br /&gt;
=== I2C ===&lt;br /&gt;
==== X9241A - Digital Potentiometer ====&lt;br /&gt;
&lt;br /&gt;
Detail on this page [[X9241A - Digital Potentiometer]]&lt;br /&gt;
&lt;br /&gt;
There are basically only two functions that I am after right now which are both three byte instructions: &lt;br /&gt;
&lt;br /&gt;
* Read WCR(Wiper Control Register) for the four potentiometers 0-3 (So far this is failing miserably)&lt;br /&gt;
** Send 1st byte - Address (my circuit - 01011010 or 0x2D)(binary - 0101 A3 A2 A1 A0) A values are actual pins set to high or low for an address.&lt;br /&gt;
** Send 2nd byte - Instruction (binary - 1001 (1/0)(1/0) 00) - The two bits are used to choose the potentiometer&lt;br /&gt;
** Read WCR requested Byte&lt;br /&gt;
* Write WCR for the four potentiometers 0-3 (This works)&lt;br /&gt;
** Send 1st byte - Address (my circuit - 01011010 or 0x2D)(binary - 0101 A3 A2 A1 A0) A values are actual pins set to high or low for an address.&lt;br /&gt;
** Send 2nd byte - Instruction (binary - 1010 (1/0)(1/0) 00) - The two bits are used to choose the potentiometer&lt;br /&gt;
** Send WCR Byte - Potentiometer value (binary - 00 D5 D4 D3 D2 D1 D0) - D values are the 0-63 potentiometer positions&lt;br /&gt;
&lt;br /&gt;
'''Sample Code'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
       Wire.beginTransmission(X9241_I2C_ADDRESS);&lt;br /&gt;
       Wire.send(0xa0); //Instruction to write WCR-00&lt;br /&gt;
       Wire.send(0x20); //Send a D value of 32&lt;br /&gt;
       Wire.endTransmission();&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
==== DS1307 - Real Time Clock ====&lt;br /&gt;
&lt;br /&gt;
The code for this very useful chip came from the [[http://www.glacialwanderer.com/hobbyrobotics/?p=12 Glacial Wanderer]]&lt;br /&gt;
&lt;br /&gt;
==== A/C_Control_v.01 code ====&lt;br /&gt;
&lt;br /&gt;
''' While this says v.01, don't count on it being a released v.01, I am still working on v.01, this is a back up '''&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
/*&lt;br /&gt;
 * A/C Control v.01&lt;br /&gt;
 * by &amp;lt;http://www.combustory.com&amp;gt; John Vaughters&lt;br /&gt;
 * Credit to:&lt;br /&gt;
 * Maurice Ribble - http://www.glacialwanderer.com/hobbyrobotics for RTC DS1307 code&lt;br /&gt;
 *&lt;br /&gt;
 * Turns on an LED for temperatures from analog pins 1-5 on&lt;br /&gt;
 * digital pins 2-6 when the temperature rises above the THRESHOLDS 1-5.&lt;br /&gt;
 * The program also implements a &lt;br /&gt;
 * Serial Communication method that utilizes a leading CHAR for each command Described below. &lt;br /&gt;
 * Commands:&lt;br /&gt;
 * T(1-4) - Temp1-5 Status ex. T1, T2, etc&lt;br /&gt;
 * C(1-4)(0-9) - Increment THRESHOLD1-4 by (1-9) ex. C15 increments THRESHOLD1 BY 5 (Note: C40 will give you a status of THRESHOLD4)&lt;br /&gt;
 * D(1-4)(0-9) - Decrement THRESHOLD1-4 by (1-9) ex. D59 decrements THRESHOLD5 BY 9 (Note: D10 will give you a status of THRESHOLD1)&lt;br /&gt;
 * A(0-1) - Manual AC on command A1 is AC on, A0 is AC off&lt;br /&gt;
 * F(0-1) - Manual AC on command A1 is FAN on, A0 is FAN off &lt;br /&gt;
 * Q - Q Sets the date of the RTC DS1307 Chip&lt;br /&gt;
 */&lt;br /&gt;
&lt;br /&gt;
#include &amp;quot;Wire.h&amp;quot;&lt;br /&gt;
#define DS1307_I2C_ADDRESS 0x68&lt;br /&gt;
&lt;br /&gt;
// Global Variables&lt;br /&gt;
int val_cnt = 0;               // counter for the temp_val                   &lt;br /&gt;
int temp1Pin = 0;    // select the input pin for the Thermistor&lt;br /&gt;
int temp2Pin = 1;    // select the input pin for the Thermistor&lt;br /&gt;
int temp3Pin = 2;    // select the input pin for the Thermistor&lt;br /&gt;
int temp4Pin = 3;    // select the input pin for the Thermistor&lt;br /&gt;
int temp1_val[5] = {0,0,0,0,0};       // variable to store the value coming from the sensor&lt;br /&gt;
int temp2_val[5] = {0,0,0,0,0};       //           &lt;br /&gt;
int temp3_val[5] = {0,0,0,0,0};       //&lt;br /&gt;
int temp4_val[5] = {0,0,0,0,0};       //&lt;br /&gt;
int temp1_avg;                   // average over poll time of the temp values&lt;br /&gt;
int temp2_avg;&lt;br /&gt;
int temp3_avg;&lt;br /&gt;
int temp4_avg;&lt;br /&gt;
int duct1 = 2;                   // Ducts open or close using a digital output&lt;br /&gt;
int duct2 = 3;&lt;br /&gt;
int duct3 = 4;&lt;br /&gt;
int duct4 = 5;&lt;br /&gt;
int THRESHOLD1 = 580;    // Default theshold values&lt;br /&gt;
int THRESHOLD2 = 580;&lt;br /&gt;
int THRESHOLD3 = 580;&lt;br /&gt;
int THRESHOLD4 = 580;&lt;br /&gt;
int ac_on = 13;&lt;br /&gt;
int fan_on = 12;&lt;br /&gt;
int command = 0;       // This is the command char, in ascii form, sent from the serial port     &lt;br /&gt;
long polltime = 1000;  // The time to Poll the tempPins&lt;br /&gt;
long previousMillis = 0;        // will store last time Temp was updated&lt;br /&gt;
long ac_on_start = 0;     // Start A/C delay timer&lt;br /&gt;
long ac_on_delay = 10000;   // Time to wait before checking the ducts again&lt;br /&gt;
byte second, minute, hour, dayOfWeek, dayOfMonth, month, year;&lt;br /&gt;
&lt;br /&gt;
  &lt;br /&gt;
// Convert normal decimal numbers to binary coded decimal&lt;br /&gt;
byte decToBcd(byte val)&lt;br /&gt;
{&lt;br /&gt;
  return ( (val/10*16) + (val%10) );&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
// Convert binary coded decimal to normal decimal numbers&lt;br /&gt;
byte bcdToDec(byte val)&lt;br /&gt;
{&lt;br /&gt;
  return ( (val/16*10) + (val%16) );&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
// 1) Sets the date and time on the ds1307&lt;br /&gt;
// 2) Starts the clock&lt;br /&gt;
// 3) Sets hour mode to 24 hour clock&lt;br /&gt;
// Assumes you're passing in valid numbers&lt;br /&gt;
// Watch for scope issues with Global Variables&lt;br /&gt;
/*void setDateDs1307(byte second,        // 0-59&lt;br /&gt;
                   byte minute,        // 0-59&lt;br /&gt;
                   byte hour,          // 1-23&lt;br /&gt;
                   byte dayOfWeek,     // 1-7&lt;br /&gt;
                   byte dayOfMonth,    // 1-28/29/30/31&lt;br /&gt;
                   byte month,         // 1-12&lt;br /&gt;
                   byte year)          // 0-99*/&lt;br /&gt;
void setDateDs1307()                &lt;br /&gt;
{&lt;br /&gt;
   Wire.beginTransmission(DS1307_I2C_ADDRESS);&lt;br /&gt;
   Wire.send(0);&lt;br /&gt;
   Wire.send(decToBcd(second));    // 0 to bit 7 starts the clock&lt;br /&gt;
   Wire.send(decToBcd(minute));&lt;br /&gt;
   Wire.send(decToBcd(hour));      // If you want 12 hour am/pm you need to set&lt;br /&gt;
                                   // bit 6 (also need to change readDateDs1307)&lt;br /&gt;
   Wire.send(decToBcd(dayOfWeek));&lt;br /&gt;
   Wire.send(decToBcd(dayOfMonth));&lt;br /&gt;
   Wire.send(decToBcd(month));&lt;br /&gt;
   Wire.send(decToBcd(year));&lt;br /&gt;
   Wire.endTransmission();&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
// Gets the date and time from the ds1307 and prints result&lt;br /&gt;
// Watch for scope issues with Global Variables&lt;br /&gt;
void getDateDs1307()&lt;br /&gt;
{&lt;br /&gt;
  // Reset the register pointer&lt;br /&gt;
  Wire.beginTransmission(DS1307_I2C_ADDRESS);&lt;br /&gt;
  Wire.send(0);&lt;br /&gt;
  Wire.endTransmission();&lt;br /&gt;
&lt;br /&gt;
  Wire.requestFrom(DS1307_I2C_ADDRESS, 7);&lt;br /&gt;
&lt;br /&gt;
  // A few of these need masks because certain bits are control bits&lt;br /&gt;
  second     = bcdToDec(Wire.receive() &amp;amp; 0x7f);&lt;br /&gt;
  minute     = bcdToDec(Wire.receive());&lt;br /&gt;
  hour       = bcdToDec(Wire.receive() &amp;amp; 0x3f);  // Need to change this if 12 hour am/pm&lt;br /&gt;
  dayOfWeek  = bcdToDec(Wire.receive());&lt;br /&gt;
  dayOfMonth = bcdToDec(Wire.receive());&lt;br /&gt;
  month      = bcdToDec(Wire.receive());&lt;br /&gt;
  year       = bcdToDec(Wire.receive());&lt;br /&gt;
  &lt;br /&gt;
  Serial.print(hour, DEC);&lt;br /&gt;
  Serial.print(&amp;quot;:&amp;quot;);&lt;br /&gt;
  Serial.print(minute, DEC);&lt;br /&gt;
  Serial.print(&amp;quot;:&amp;quot;);&lt;br /&gt;
  Serial.print(second, DEC);&lt;br /&gt;
  Serial.print(&amp;quot;  &amp;quot;);&lt;br /&gt;
  Serial.print(month, DEC);&lt;br /&gt;
  Serial.print(&amp;quot;/&amp;quot;);&lt;br /&gt;
  Serial.print(dayOfMonth, DEC);&lt;br /&gt;
  Serial.print(&amp;quot;/&amp;quot;);&lt;br /&gt;
  Serial.print(year, DEC);&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
void setup() {&lt;br /&gt;
  Wire.begin();&lt;br /&gt;
  Serial.begin(57600);&lt;br /&gt;
  pinMode(duct1, OUTPUT);&lt;br /&gt;
  pinMode(duct2, OUTPUT);&lt;br /&gt;
  pinMode(duct3, OUTPUT);&lt;br /&gt;
  pinMode(duct4, OUTPUT);&lt;br /&gt;
  pinMode(ac_on, OUTPUT);&lt;br /&gt;
  pinMode(fan_on, OUTPUT);&lt;br /&gt;
  // Initialize Date/Time to update RTC DS1307 - You need to run the Q command right after you download this program&lt;br /&gt;
  // This is temporary until a more complex date time command is finished&lt;br /&gt;
  second = 15;&lt;br /&gt;
  minute = 41;&lt;br /&gt;
  hour = 12;&lt;br /&gt;
  dayOfWeek = 5;&lt;br /&gt;
  dayOfMonth = 5;&lt;br /&gt;
  month = 9;&lt;br /&gt;
  year = 8;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
void loop() {&lt;br /&gt;
  if (millis() - previousMillis &amp;gt; polltime) {&lt;br /&gt;
    previousMillis = millis();   // remember the last time&lt;br /&gt;
    if (millis() - ac_on_start &amp;gt; ac_on_delay) { &lt;br /&gt;
      if (digitalRead(duct1) || digitalRead(duct2) || digitalRead(duct3) || digitalRead(duct4)){  // If any ducts are turned on turn on the A/C&lt;br /&gt;
       if (digitalRead(ac_on) != HIGH) { // Check ac_on state&lt;br /&gt;
        digitalWrite(ac_on,HIGH);&lt;br /&gt;
        getDateDs1307();&lt;br /&gt;
        Serial.println(&amp;quot; - AC ON&amp;quot;);&lt;br /&gt;
       }&lt;br /&gt;
       ac_on_start = millis();&lt;br /&gt;
      } &lt;br /&gt;
      else if (digitalRead(ac_on) != LOW){ //Check ac_on state&lt;br /&gt;
       digitalWrite(ac_on,LOW);&lt;br /&gt;
       getDateDs1307();&lt;br /&gt;
       Serial.println(&amp;quot; - AC OFF&amp;quot;);&lt;br /&gt;
      }&lt;br /&gt;
    }&lt;br /&gt;
    temp1_val[val_cnt] = analogRead(temp1Pin);    // read the value from the sensors&lt;br /&gt;
    temp2_val[val_cnt] = analogRead(temp2Pin);&lt;br /&gt;
    temp3_val[val_cnt] = analogRead(temp3Pin);&lt;br /&gt;
    temp4_val[val_cnt] = analogRead(temp4Pin);&lt;br /&gt;
    val_cnt ++;&lt;br /&gt;
    if (val_cnt == 5) {&lt;br /&gt;
      val_cnt = 0;&lt;br /&gt;
    }&lt;br /&gt;
    temp1_avg = (temp1_val[0] + temp1_val[1] + temp1_val[2] + temp1_val[3] + temp1_val[4])/5;&lt;br /&gt;
    temp2_avg = (temp2_val[0] + temp2_val[1] + temp2_val[2] + temp2_val[3] + temp2_val[4])/5;&lt;br /&gt;
    temp3_avg = (temp3_val[0] + temp3_val[1] + temp3_val[2] + temp3_val[3] + temp3_val[4])/5;&lt;br /&gt;
    temp4_avg = (temp4_val[0] + temp4_val[1] + temp4_val[2] + temp4_val[3] + temp4_val[4])/5;&lt;br /&gt;
// Check Thresholds against the Temperatures and set the ducts HIGH or LOW    &lt;br /&gt;
    if (temp1_avg &amp;gt;= THRESHOLD1) {digitalWrite(duct1, HIGH);}&lt;br /&gt;
    else {digitalWrite(duct1, LOW);}&lt;br /&gt;
    if (temp2_avg &amp;gt;= THRESHOLD2) {digitalWrite(duct2, HIGH);}&lt;br /&gt;
    else {digitalWrite(duct2, LOW);}&lt;br /&gt;
    if (temp3_avg &amp;gt;= THRESHOLD3) {digitalWrite(duct3, HIGH);}&lt;br /&gt;
    else {digitalWrite(duct3, LOW);}&lt;br /&gt;
    if (temp4_avg &amp;gt;= THRESHOLD4) {digitalWrite(duct4, HIGH);}&lt;br /&gt;
    else {digitalWrite(duct4, LOW);}&lt;br /&gt;
    if (Serial.available()) {      // Look for char in serial que and process if found&lt;br /&gt;
      command = Serial.read();&lt;br /&gt;
      if (command == 84) {          // If command = &amp;quot;T&amp;quot; &lt;br /&gt;
        command = Serial.read();&lt;br /&gt;
        if (command == 49) {          // If command = &amp;quot;1&amp;quot; print the Temp1&lt;br /&gt;
         Serial.print(&amp;quot;Temp1 = &amp;quot;);&lt;br /&gt;
         Serial.print(temp1_avg);           // &lt;br /&gt;
         Serial.print(&amp;quot; &amp;quot;);&lt;br /&gt;
        }&lt;br /&gt;
        else if (command == 50) {      // If command = &amp;quot;2&amp;quot; print the Temp2&lt;br /&gt;
         Serial.print(&amp;quot;Temp2 = &amp;quot;);&lt;br /&gt;
         Serial.print(temp2_avg);           // &lt;br /&gt;
         Serial.print(&amp;quot; &amp;quot;);&lt;br /&gt;
        }&lt;br /&gt;
        else if (command == 51) {      // If command = &amp;quot;3&amp;quot; print the Temp3&lt;br /&gt;
         Serial.print(&amp;quot;Temp3 = &amp;quot;);&lt;br /&gt;
         Serial.print(temp3_avg);           // &lt;br /&gt;
         Serial.print(&amp;quot; &amp;quot;);&lt;br /&gt;
        }&lt;br /&gt;
        else if (command == 52) {      // If command = &amp;quot;4&amp;quot; print the Temp4&lt;br /&gt;
         Serial.print(&amp;quot;Temp4 = &amp;quot;);&lt;br /&gt;
         Serial.print(temp4_avg);           // &lt;br /&gt;
         Serial.print(&amp;quot; &amp;quot;);&lt;br /&gt;
         }&lt;br /&gt;
       }&lt;br /&gt;
      else if (command == 67) {      //If command = &amp;quot;C&amp;quot; Change Temp Threshhold&lt;br /&gt;
        if (Serial.available()) {&lt;br /&gt;
         command = Serial.read();&lt;br /&gt;
         if (command == 49) {        // If command = &amp;quot;1&amp;quot; print the THRESHOLD1&lt;br /&gt;
           command = Serial.read();&lt;br /&gt;
           if (command &amp;gt; 47 &amp;amp;&amp;amp; command &amp;lt; 58) {          // If command is between 0-9 Increment the Threshold by number sent&lt;br /&gt;
             THRESHOLD1 += command - 48;                 // ASCII math to get value sent   &lt;br /&gt;
                  Serial.print(&amp;quot;THRESHOLD1 = &amp;quot;);&lt;br /&gt;
                  Serial.print(THRESHOLD1);           // &lt;br /&gt;
                  Serial.print(&amp;quot; &amp;quot;);&lt;br /&gt;
           }&lt;br /&gt;
         }  &lt;br /&gt;
         else if (command == 50) {     // If command = &amp;quot;2&amp;quot; print the THRESHOLD2&lt;br /&gt;
           command = Serial.read();&lt;br /&gt;
           if (command &amp;gt; 47 &amp;amp;&amp;amp; command &amp;lt; 58) {          // If command is between 0-9 Increment the Threshold by number sent&lt;br /&gt;
             THRESHOLD2 += command - 48;                 // ASCII math to get value sent   &lt;br /&gt;
                  Serial.print(&amp;quot;THRESHOLD2 = &amp;quot;);&lt;br /&gt;
                  Serial.print(THRESHOLD2);           // &lt;br /&gt;
                  Serial.print(&amp;quot; &amp;quot;);&lt;br /&gt;
           }&lt;br /&gt;
         }&lt;br /&gt;
         else if (command == 51) {             // If command = &amp;quot;3&amp;quot; print the THRESHOLD3&lt;br /&gt;
           command = Serial.read();&lt;br /&gt;
           if (command &amp;gt; 47 &amp;amp;&amp;amp; command &amp;lt; 58) {          // If command is between 0-9 Increment the Threshold by number sent&lt;br /&gt;
             THRESHOLD3 += command - 48;                 // ASCII math to get value sent   &lt;br /&gt;
                  Serial.print(&amp;quot;THRESHOLD3 = &amp;quot;);&lt;br /&gt;
                  Serial.print(THRESHOLD3);           // &lt;br /&gt;
                  Serial.print(&amp;quot; &amp;quot;);&lt;br /&gt;
           }&lt;br /&gt;
         }&lt;br /&gt;
         else if (command == 52) {             // If command = &amp;quot;4&amp;quot; print the THRESHOLD4&lt;br /&gt;
           command = Serial.read();&lt;br /&gt;
           if (command &amp;gt; 47 &amp;amp;&amp;amp; command &amp;lt; 58) {          // If command is between 0-9 Increment the Threshold by number sent&lt;br /&gt;
             THRESHOLD4 += command - 48;                 // ASCII math to get value sent   &lt;br /&gt;
                  Serial.print(&amp;quot;THRESHOLD4 = &amp;quot;);&lt;br /&gt;
                  Serial.print(THRESHOLD4);           // &lt;br /&gt;
                  Serial.print(&amp;quot; &amp;quot;);&lt;br /&gt;
           }&lt;br /&gt;
         }          &lt;br /&gt;
        }  &lt;br /&gt;
      }&lt;br /&gt;
      else if (command == 68) {      //If command = &amp;quot;D&amp;quot; Change Temp Threshhold&lt;br /&gt;
        if (Serial.available()) {&lt;br /&gt;
         command = Serial.read();&lt;br /&gt;
         if (command == 49) {           // If command = &amp;quot;1&amp;quot; print the THRESHOLD1&lt;br /&gt;
           command = Serial.read();&lt;br /&gt;
           if (command &amp;gt; 47 &amp;amp;&amp;amp; command &amp;lt; 58) {          // If command is between 0-9 Decrement the Threshold by number sent&lt;br /&gt;
             THRESHOLD1 -= command - 48;                 // ASCII math to get value sent   &lt;br /&gt;
                  Serial.print(&amp;quot;THRESHOLD1 = &amp;quot;);&lt;br /&gt;
                  Serial.print(THRESHOLD1);           // &lt;br /&gt;
                  Serial.print(&amp;quot; &amp;quot;);&lt;br /&gt;
           }&lt;br /&gt;
         }  &lt;br /&gt;
         else if (command == 50) {               // If command = &amp;quot;2&amp;quot; print the THRESHOLD2&lt;br /&gt;
           command = Serial.read();&lt;br /&gt;
           if (command &amp;gt; 47 &amp;amp;&amp;amp; command &amp;lt; 58) {          // If command is between 0-9 Decrement the Threshold by number sent&lt;br /&gt;
             THRESHOLD2 -= command - 48;                 // ASCII math to get value sent   &lt;br /&gt;
                  Serial.print(&amp;quot;THRESHOLD2 = &amp;quot;);&lt;br /&gt;
                  Serial.print(THRESHOLD2);           // &lt;br /&gt;
                  Serial.print(&amp;quot; &amp;quot;);&lt;br /&gt;
           }&lt;br /&gt;
         }&lt;br /&gt;
         else if (command == 51) {              // If command = &amp;quot;3&amp;quot; print the THRESHOLD3&lt;br /&gt;
           command = Serial.read();&lt;br /&gt;
           if (command &amp;gt; 47 &amp;amp;&amp;amp; command &amp;lt; 58) {          // If command is between 0-9 Decrement the Threshold by number sent&lt;br /&gt;
             THRESHOLD3 -= command - 48;                 // ASCII math to get value sent   &lt;br /&gt;
                  Serial.print(&amp;quot;THRESHOLD3 = &amp;quot;);&lt;br /&gt;
                  Serial.print(THRESHOLD3);           // &lt;br /&gt;
                  Serial.print(&amp;quot; &amp;quot;);&lt;br /&gt;
           }&lt;br /&gt;
         }&lt;br /&gt;
         else if (command == 52) {                    // If command = &amp;quot;4&amp;quot; print the THRESHOLD4&lt;br /&gt;
           command = Serial.read();&lt;br /&gt;
           if (command &amp;gt; 47 &amp;amp;&amp;amp; command &amp;lt; 58) {          // If command is between 0-9 Decrement the Threshold by number sent&lt;br /&gt;
             THRESHOLD4 -= command - 48;                 // ASCII math to get value sent   &lt;br /&gt;
                  Serial.print(&amp;quot;THRESHOLD4 = &amp;quot;);&lt;br /&gt;
                  Serial.print(THRESHOLD4);           // &lt;br /&gt;
                  Serial.print(&amp;quot; &amp;quot;);&lt;br /&gt;
           }&lt;br /&gt;
         }           &lt;br /&gt;
        }  &lt;br /&gt;
      }&lt;br /&gt;
//****************  Warning - This is a potential for problem - Consider a manual lock out feature to lock out manual commands &lt;br /&gt;
//****************  Possibly create a command to open up manual commands for a certian time period then shut them off again automatically&lt;br /&gt;
      else if (command == 65) {      //If command = &amp;quot;A&amp;quot; Change Temp Threshhold&lt;br /&gt;
       if (Serial.available()) {&lt;br /&gt;
        command = Serial.read();&lt;br /&gt;
        if (command == 49) {        // If command = &amp;quot;1&amp;quot; print the AC ON message&lt;br /&gt;
         getDateDs1307();&lt;br /&gt;
         Serial.print(&amp;quot; - Manual AC ON &amp;quot;);&lt;br /&gt;
         ac_on_start = millis();   // Set the AC to a delay before it can be turned off again&lt;br /&gt;
         digitalWrite(ac_on,HIGH);&lt;br /&gt;
        }&lt;br /&gt;
        else if (command == 48) {        // If command = &amp;quot;0&amp;quot; print the AC OFF message&lt;br /&gt;
         getDateDs1307();&lt;br /&gt;
         Serial.print(&amp;quot; - Manual AC OFF &amp;quot;);&lt;br /&gt;
         digitalWrite(ac_on,LOW);&lt;br /&gt;
        }&lt;br /&gt;
       } &lt;br /&gt;
      } &lt;br /&gt;
      else if (command == 70) {      //If command = &amp;quot;F&amp;quot; Change Temp Threshhold&lt;br /&gt;
       if (Serial.available()) {&lt;br /&gt;
        command = Serial.read();&lt;br /&gt;
        if (command == 49) {        // If command = &amp;quot;1&amp;quot; print the FAN ON message&lt;br /&gt;
         getDateDs1307();&lt;br /&gt;
         Serial.print(&amp;quot; - Manual FAN ON &amp;quot;);&lt;br /&gt;
         ac_on_start = millis();&lt;br /&gt;
         digitalWrite(fan_on,HIGH);&lt;br /&gt;
        }&lt;br /&gt;
        else if (command == 48) {        // If command = &amp;quot;0&amp;quot; print the FAN OFF message&lt;br /&gt;
         getDateDs1307();&lt;br /&gt;
         Serial.print(&amp;quot; - Manual FAN OFF &amp;quot;);&lt;br /&gt;
         digitalWrite(fan_on,LOW);&lt;br /&gt;
        }&lt;br /&gt;
       } &lt;br /&gt;
      }&lt;br /&gt;
//********************** End of Warning Zone *******************************&lt;br /&gt;
&lt;br /&gt;
// ***************  This Section Will list the Staus of the Controller&lt;br /&gt;
      else if (command == 83) {      //If command = &amp;quot;S&amp;quot; Print Controller Status&lt;br /&gt;
        getDateDs1307();&lt;br /&gt;
        Serial.println(&amp;quot; &amp;quot;);&lt;br /&gt;
        Serial.println(&amp;quot; &amp;quot;);&lt;br /&gt;
        Serial.print(&amp;quot;Temp1 = &amp;quot;);&lt;br /&gt;
        Serial.println(temp1_avg);   &lt;br /&gt;
        Serial.print(&amp;quot;Temp2 = &amp;quot;);&lt;br /&gt;
        Serial.println(temp2_avg);&lt;br /&gt;
        Serial.print(&amp;quot;Temp3 = &amp;quot;);&lt;br /&gt;
        Serial.println(temp3_avg);   &lt;br /&gt;
        Serial.print(&amp;quot;Temp4 = &amp;quot;);&lt;br /&gt;
        Serial.println(temp4_avg);   &lt;br /&gt;
        Serial.println(&amp;quot; &amp;quot;);&lt;br /&gt;
        Serial.print(&amp;quot;THRESHOLD1 = &amp;quot;);&lt;br /&gt;
        Serial.println(THRESHOLD1);   &lt;br /&gt;
        Serial.print(&amp;quot;THRESHOLD2 = &amp;quot;);&lt;br /&gt;
        Serial.println(THRESHOLD2); &lt;br /&gt;
        Serial.print(&amp;quot;THRESHOLD3 = &amp;quot;);&lt;br /&gt;
        Serial.println(THRESHOLD3); &lt;br /&gt;
        Serial.print(&amp;quot;THRESHOLD4 = &amp;quot;);&lt;br /&gt;
        Serial.println(THRESHOLD4);&lt;br /&gt;
        Serial.println(&amp;quot; &amp;quot;);&lt;br /&gt;
        if (digitalRead(duct1) == HIGH) {Serial.println(&amp;quot;duct1 ON&amp;quot;);}&lt;br /&gt;
        else{Serial.println(&amp;quot;duct1 OFF&amp;quot;);}&lt;br /&gt;
        if (digitalRead(duct2) == HIGH) {Serial.println(&amp;quot;duct2 ON&amp;quot;);}&lt;br /&gt;
        else{Serial.println(&amp;quot;duct2 OFF&amp;quot;);}&lt;br /&gt;
        if (digitalRead(duct3) == HIGH) {Serial.println(&amp;quot;duct3 ON&amp;quot;);}&lt;br /&gt;
        else{Serial.println(&amp;quot;duct3 OFF&amp;quot;);}&lt;br /&gt;
        if (digitalRead(duct4) == HIGH) {Serial.println(&amp;quot;duct4 ON&amp;quot;);}&lt;br /&gt;
        else{Serial.println(&amp;quot;duct4 OFF&amp;quot;);}&lt;br /&gt;
        Serial.println(&amp;quot; &amp;quot;);&lt;br /&gt;
        if (digitalRead(fan_on) == HIGH) {Serial.println(&amp;quot;Fan ON&amp;quot;);}&lt;br /&gt;
        else{Serial.println(&amp;quot;Fan OFF&amp;quot;);}&lt;br /&gt;
        if (digitalRead(ac_on) == HIGH) {Serial.println(&amp;quot;AC  ON&amp;quot;);}&lt;br /&gt;
        else{Serial.println(&amp;quot;AC  OFF&amp;quot;);}&lt;br /&gt;
        Serial.print(&amp;quot;A/C Delay (millisec) = &amp;quot;);&lt;br /&gt;
        Serial.println(ac_on_delay);&lt;br /&gt;
        Serial.print(&amp;quot;Temp Polling (millisec) = &amp;quot;);&lt;br /&gt;
        Serial.println(polltime);          &lt;br /&gt;
        Serial.println(&amp;quot; &amp;quot;);&lt;br /&gt;
        &lt;br /&gt;
      }&lt;br /&gt;
      else if (command == 81) {      //If command = &amp;quot;Q&amp;quot; Set Date&lt;br /&gt;
       setDateDs1307();&lt;br /&gt;
       getDateDs1307();&lt;br /&gt;
       Serial.println(&amp;quot; &amp;quot;);&lt;br /&gt;
      }&lt;br /&gt;
      Serial.println(command);     // Echo command char found in serial que&lt;br /&gt;
      command = 0;                 // reset command &lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
//*****************************************************The End***********************&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== A/C_Control_v.01 User Guide ==&lt;br /&gt;
==== Commands ====&lt;br /&gt;
== Troubleshooting ==&lt;br /&gt;
=== Summary ===&lt;br /&gt;
When Troubleshooting a multi-functional issue, it is best practice to break down the issue into pieces and test each piece as a separate system.  However, we will first run through a quick test to see if we can find any obvious issues first.&lt;br /&gt;
=== Quick Test ===&lt;br /&gt;
[[Category:Electronics]]&lt;/div&gt;</summary>
		<author><name>Combustor</name></author>	</entry>

	<entry>
		<id>http://combustory.com/wiki/index.php/X9241A_-_Digital_Potentiometer</id>
		<title>X9241A - Digital Potentiometer</title>
		<link rel="alternate" type="text/html" href="http://combustory.com/wiki/index.php/X9241A_-_Digital_Potentiometer"/>
				<updated>2008-09-26T00:00:45Z</updated>
		
		<summary type="html">&lt;p&gt;Combustor: /* Summary */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{default}}&lt;br /&gt;
&lt;br /&gt;
== Summary ==&lt;br /&gt;
This code shows how to communicate with the X9241A Digital Potentiometer.  I plan on updating this info eventually to explain this chip, but for now you will probably want to get the data sheet to help with understanding what was done here.  The bottom line is that I have created this program to accept commands via serial commands to set the storage registers to certain values and to modify the pot registers to change based on serial commands. I have not figured out how to read the registers, but that is not so important to my application.&lt;br /&gt;
&lt;br /&gt;
== Method ==&lt;br /&gt;
=== I2C ===&lt;br /&gt;
&lt;br /&gt;
There are basically only two functions that I am after right now which are both three byte instructions: &lt;br /&gt;
&lt;br /&gt;
* Read WCR(Wiper Control Register) for the four potentiometers 0-3 (So far this is failing miserably)&lt;br /&gt;
** Send 1st byte - Address (my circuit - 01011010 or 0x2D)(binary - 0101 A3 A2 A1 A0) A values are actual pins set to high or low for an address.&lt;br /&gt;
** Send 2nd byte - Instruction (binary - 1001 (1/0)(1/0) 00) - The two bits are used to choose the potentiometer&lt;br /&gt;
** Read WCR requested Byte&lt;br /&gt;
* Write WCR for the four potentiometers 0-3 (This works)&lt;br /&gt;
** Send 1st byte - Address (my circuit - 01011010 or 0x2D)(binary - 0101 A3 A2 A1 A0) A values are actual pins set to high or low for an address.&lt;br /&gt;
** Send 2nd byte - Instruction (binary - 1010 (1/0)(1/0) 00) - The two bits are used to choose the potentiometer&lt;br /&gt;
** Send WCR Byte - Potentiometer value (binary - 00 D5 D4 D3 D2 D1 D0) - D values are the 0-63 potentiometer positions&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== x9241A_Digital_Potentiometer_v.01 code ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
/*&lt;br /&gt;
 * x9241A Digital Potentiometer v.01&lt;br /&gt;
 * by &amp;lt;http://www.combustory.com&amp;gt; John Vaughters&lt;br /&gt;
 *&lt;br /&gt;
 * This Program illustrates the use of I2C to set up the x9241A Digital Potentiometer by setting and transferring the registers.&lt;br /&gt;
 * I attempted to read the register data through I2C, but was unable to get it to work.&lt;br /&gt;
 * Since the reading part was not so important to me I stopped trying.  &lt;br /&gt;
 * To set the registers up and transfer them to the Wiper registers met my goals and that is where I stopped.&lt;br /&gt;
 *&lt;br /&gt;
 * The x9142A has four Digital Pots and each pot has four static registers and one dynamic register the Wiper Control Register (WCR). &lt;br /&gt;
 * Therefore, there are 16 total bytes of storage and four WCR's.&lt;br /&gt;
 * This Program has the following commands:&lt;br /&gt;
 * S - Set the 16 registers.  Each pot has four registers and this command will set each register group with the same value. So register 00 for each pot will&lt;br /&gt;
 *     be the same value for each pot, and the same for register 01 through 11.&lt;br /&gt;
 * G(0-3) - Global Transfer of Registers to the WCR's.  This command will bulk load the values stored in registers into the WCR's.  &lt;br /&gt;
 *          For example, a G0 will load the 00 register for each pot into the WCR in one command. A G1 loads the 01 register for each pot, etc.&lt;br /&gt;
 * (0-3)(0-3) - This set of commands transfers a single register into a single WCR. The digits are arranged like this (WCR)(Reg). &lt;br /&gt;
 *              For example, a 00 command will load register 00 into WCR 00 or a 13 command will load register 11 into WCR 01, etc.&lt;br /&gt;
 * W(0-3) - This command writes directly to the WCR.  I have created four values that are just random, but the command shows how to write directly to the WCR for each pot.&lt;br /&gt;
 *          For example, a W0 command will write a value of decimal 16.  These commands are just for example purposes.&lt;br /&gt;
 *&lt;br /&gt;
 * Command Note: If you enter a command that is not recognized, then it is ignored and nothing happens and nothing is printed.&lt;br /&gt;
 */&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
#include &amp;quot;Wire.h&amp;quot;&lt;br /&gt;
#define X9241_I2C_ADDRESS 0x2D&lt;br /&gt;
&lt;br /&gt;
// Global Variables&lt;br /&gt;
long command;&lt;br /&gt;
  &lt;br /&gt;
&lt;br /&gt;
void setup() {&lt;br /&gt;
  Wire.begin();&lt;br /&gt;
  Serial.begin(57600);&lt;br /&gt;
  &lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
void loop() {&lt;br /&gt;
   if (Serial.available()) {      // Look for char in serial que and process if found&lt;br /&gt;
      command = Serial.read();&lt;br /&gt;
      if (command == 83) {      //If command = &amp;quot;S&amp;quot; Set Register Data&lt;br /&gt;
      // This sets the four registers of each Digital Pot&lt;br /&gt;
          Wire.beginTransmission(X9241_I2C_ADDRESS);&lt;br /&gt;
          Wire.send(0xc0);  // This is the set register command c and the 16 registers are 0-f&lt;br /&gt;
          Wire.send(0x0a);  // This line is the value to set the register: 0-63 is a valid setting&lt;br /&gt;
          Wire.endTransmission(); &lt;br /&gt;
          delay(100);&lt;br /&gt;
          Wire.beginTransmission(X9241_I2C_ADDRESS);&lt;br /&gt;
          Wire.send(0xc1);&lt;br /&gt;
          Wire.send(0x14);&lt;br /&gt;
          Wire.endTransmission();&lt;br /&gt;
          delay(100);&lt;br /&gt;
          Wire.beginTransmission(X9241_I2C_ADDRESS);&lt;br /&gt;
          Wire.send(0xc2);&lt;br /&gt;
          Wire.send(0x20);&lt;br /&gt;
          Wire.endTransmission();&lt;br /&gt;
          delay(100);&lt;br /&gt;
          Wire.beginTransmission(X9241_I2C_ADDRESS);&lt;br /&gt;
          Wire.send(0xc3);&lt;br /&gt;
          Wire.send(0x3c);&lt;br /&gt;
          Wire.endTransmission();&lt;br /&gt;
          delay(100);&lt;br /&gt;
          Wire.beginTransmission(X9241_I2C_ADDRESS);&lt;br /&gt;
          Wire.send(0xc4);&lt;br /&gt;
          Wire.send(0x0a);&lt;br /&gt;
          Wire.endTransmission(); &lt;br /&gt;
          delay(100);&lt;br /&gt;
          Wire.beginTransmission(X9241_I2C_ADDRESS);&lt;br /&gt;
          Wire.send(0xc5);&lt;br /&gt;
          Wire.send(0x14);&lt;br /&gt;
          Wire.endTransmission();&lt;br /&gt;
          delay(100);&lt;br /&gt;
          Wire.beginTransmission(X9241_I2C_ADDRESS);&lt;br /&gt;
          Wire.send(0xc6);&lt;br /&gt;
          Wire.send(0x20);&lt;br /&gt;
          Wire.endTransmission();&lt;br /&gt;
          delay(100);&lt;br /&gt;
          Wire.beginTransmission(X9241_I2C_ADDRESS);&lt;br /&gt;
          Wire.send(0xc7);&lt;br /&gt;
          Wire.send(0x3c);&lt;br /&gt;
          Wire.endTransmission();&lt;br /&gt;
          delay(100);          &lt;br /&gt;
          Wire.beginTransmission(X9241_I2C_ADDRESS);&lt;br /&gt;
          Wire.send(0xc8);&lt;br /&gt;
          Wire.send(0x0a);&lt;br /&gt;
          Wire.endTransmission(); &lt;br /&gt;
          delay(100);&lt;br /&gt;
          Wire.beginTransmission(X9241_I2C_ADDRESS);&lt;br /&gt;
          Wire.send(0xc9);&lt;br /&gt;
          Wire.send(0x14);&lt;br /&gt;
          Wire.endTransmission();&lt;br /&gt;
          delay(100);&lt;br /&gt;
          Wire.beginTransmission(X9241_I2C_ADDRESS);&lt;br /&gt;
          Wire.send(0xca);&lt;br /&gt;
          Wire.send(0x20);&lt;br /&gt;
          Wire.endTransmission();&lt;br /&gt;
          delay(100);&lt;br /&gt;
          Wire.beginTransmission(X9241_I2C_ADDRESS);&lt;br /&gt;
          Wire.send(0xcb);&lt;br /&gt;
          Wire.send(0x3c);&lt;br /&gt;
          Wire.endTransmission();&lt;br /&gt;
          delay(100);&lt;br /&gt;
          Wire.beginTransmission(X9241_I2C_ADDRESS);&lt;br /&gt;
          Wire.send(0xcc);&lt;br /&gt;
          Wire.send(0x0a);&lt;br /&gt;
          Wire.endTransmission(); &lt;br /&gt;
          delay(100);&lt;br /&gt;
          Wire.beginTransmission(X9241_I2C_ADDRESS);&lt;br /&gt;
          Wire.send(0xcd);&lt;br /&gt;
          Wire.send(0x14);&lt;br /&gt;
          Wire.endTransmission();&lt;br /&gt;
          delay(100);&lt;br /&gt;
          Wire.beginTransmission(X9241_I2C_ADDRESS);&lt;br /&gt;
          Wire.send(0xce);&lt;br /&gt;
          Wire.send(0x20);&lt;br /&gt;
          Wire.endTransmission();&lt;br /&gt;
          delay(100);&lt;br /&gt;
          Wire.beginTransmission(X9241_I2C_ADDRESS);&lt;br /&gt;
          Wire.send(0xcf);&lt;br /&gt;
          Wire.send(0x3c);&lt;br /&gt;
          Serial.println(&amp;quot;cmd: S&amp;quot;);&lt;br /&gt;
       }   &lt;br /&gt;
       else if (command == 71) {      //If command = &amp;quot;G&amp;quot; Transfer Global Register Data   &lt;br /&gt;
        delay(100);&lt;br /&gt;
        if (Serial.available()) {&lt;br /&gt;
         command = Serial.read(); &lt;br /&gt;
         if (command == 48) {        // If command = &amp;quot;0&amp;quot; &lt;br /&gt;
          Wire.beginTransmission(X9241_I2C_ADDRESS);&lt;br /&gt;
          Wire.send(0x10); // Global Load WCR's with Reg-00&lt;br /&gt;
          Wire.endTransmission();&lt;br /&gt;
          Serial.println(&amp;quot;cmd: G0&amp;quot;);&lt;br /&gt;
         }&lt;br /&gt;
         else if (command == 49) {        // If command = &amp;quot;1&amp;quot; &lt;br /&gt;
          Wire.beginTransmission(X9241_I2C_ADDRESS);&lt;br /&gt;
          Wire.send(0x11); // Global Load WCR's with Reg-01&lt;br /&gt;
          Wire.endTransmission();&lt;br /&gt;
          Serial.println(&amp;quot;cmd: G1&amp;quot;);&lt;br /&gt;
         }&lt;br /&gt;
         else if (command == 50) {        // If command = &amp;quot;2&amp;quot; &lt;br /&gt;
          Wire.beginTransmission(X9241_I2C_ADDRESS);&lt;br /&gt;
          Wire.send(0x12); // Global Load WCR's with Reg-10&lt;br /&gt;
          Wire.endTransmission();&lt;br /&gt;
          Serial.println(&amp;quot;cmd: G2&amp;quot;);&lt;br /&gt;
         }&lt;br /&gt;
         else if (command == 51) {        // If command = &amp;quot;3&amp;quot; &lt;br /&gt;
          Wire.beginTransmission(X9241_I2C_ADDRESS);&lt;br /&gt;
          Wire.send(0x13); // Global Load WCR's with Reg-11&lt;br /&gt;
          Wire.endTransmission();&lt;br /&gt;
          Serial.println(&amp;quot;cmd: G3&amp;quot;);&lt;br /&gt;
         }&lt;br /&gt;
        }&lt;br /&gt;
       }&lt;br /&gt;
       &lt;br /&gt;
       else if (command == 48) {      //If command = &amp;quot;0&amp;quot; Transfer Register-00 Data to WCR 0-3&lt;br /&gt;
         delay(100);&lt;br /&gt;
         if (Serial.available()) {&lt;br /&gt;
         command = Serial.read(); &lt;br /&gt;
         if (command == 48) {              // If command = &amp;quot;0&amp;quot; &lt;br /&gt;
          Wire.beginTransmission(X9241_I2C_ADDRESS);&lt;br /&gt;
          Wire.send(0xd0); // Load WCR-00 with Reg-00&lt;br /&gt;
          Wire.endTransmission();&lt;br /&gt;
          Serial.println(&amp;quot;cmd: 00&amp;quot;);&lt;br /&gt;
         }&lt;br /&gt;
         else if (command == 49) {        // If command = &amp;quot;1&amp;quot; &lt;br /&gt;
          Wire.beginTransmission(X9241_I2C_ADDRESS);&lt;br /&gt;
          Wire.send(0xd1); // Load WCR-00 with Reg-01&lt;br /&gt;
          Wire.endTransmission();&lt;br /&gt;
          Serial.println(&amp;quot;cmd: 01&amp;quot;);&lt;br /&gt;
         }&lt;br /&gt;
         else if (command == 50) {        // If command = &amp;quot;2&amp;quot; &lt;br /&gt;
          Wire.beginTransmission(X9241_I2C_ADDRESS);&lt;br /&gt;
          Wire.send(0xd2); // Load WCR-00 with Reg-10&lt;br /&gt;
          Wire.endTransmission();&lt;br /&gt;
          Serial.println(&amp;quot;cmd: 02&amp;quot;);&lt;br /&gt;
         }&lt;br /&gt;
         else if (command == 51) {        // If command = &amp;quot;3&amp;quot; &lt;br /&gt;
          Wire.beginTransmission(X9241_I2C_ADDRESS);&lt;br /&gt;
          Wire.send(0xd3); // Load WCR-00 with Reg-11&lt;br /&gt;
          Wire.endTransmission();&lt;br /&gt;
          Serial.println(&amp;quot;cmd: 03&amp;quot;);&lt;br /&gt;
         }&lt;br /&gt;
        }&lt;br /&gt;
       }&lt;br /&gt;
        else if (command == 49) {      //If command = &amp;quot;1&amp;quot; Transfer Register-01 Data to WCR 0-3&lt;br /&gt;
         delay(100);&lt;br /&gt;
         if (Serial.available()) {&lt;br /&gt;
         command = Serial.read(); &lt;br /&gt;
          if (command == 48) {              // If command = &amp;quot;0&amp;quot; &lt;br /&gt;
           Wire.beginTransmission(X9241_I2C_ADDRESS);&lt;br /&gt;
           Wire.send(0xd4); // Load WCR-01 with Reg-00&lt;br /&gt;
           Wire.endTransmission();&lt;br /&gt;
           Serial.println(&amp;quot;cmd: 10&amp;quot;);&lt;br /&gt;
          }&lt;br /&gt;
          else if (command == 49) {        // If command = &amp;quot;1&amp;quot; &lt;br /&gt;
           Wire.beginTransmission(X9241_I2C_ADDRESS);&lt;br /&gt;
           Wire.send(0xd5); // Load WCR-01 with Reg-01&lt;br /&gt;
           Wire.endTransmission();&lt;br /&gt;
           Serial.println(&amp;quot;cmd: 11&amp;quot;);&lt;br /&gt;
          }&lt;br /&gt;
          else if (command == 50) {        // If command = &amp;quot;2&amp;quot; &lt;br /&gt;
           Wire.beginTransmission(X9241_I2C_ADDRESS);&lt;br /&gt;
           Wire.send(0xd6); // Load WCR-01 with Reg-10&lt;br /&gt;
           Wire.endTransmission();&lt;br /&gt;
           Serial.println(&amp;quot;cmd: 12&amp;quot;);&lt;br /&gt;
          }&lt;br /&gt;
          else if (command == 51) {        // If command = &amp;quot;3&amp;quot; &lt;br /&gt;
           Wire.beginTransmission(X9241_I2C_ADDRESS);&lt;br /&gt;
           Wire.send(0xd7); // Load WCR-01 with Reg-11&lt;br /&gt;
           Wire.endTransmission();&lt;br /&gt;
           Serial.println(&amp;quot;cmd: 13&amp;quot;);&lt;br /&gt;
          }&lt;br /&gt;
         }&lt;br /&gt;
        }&lt;br /&gt;
        else if (command == 50) {      //If command = &amp;quot;2&amp;quot; Transfer Register-10 Data to WCR 0-3&lt;br /&gt;
         if (Serial.available()) {&lt;br /&gt;
          command = Serial.read(); &lt;br /&gt;
          if (command == 48) {              // If command = &amp;quot;0&amp;quot; &lt;br /&gt;
           Wire.beginTransmission(X9241_I2C_ADDRESS);&lt;br /&gt;
           Wire.send(0xd8); // Load WCR-10 with Reg-00&lt;br /&gt;
           Wire.endTransmission();&lt;br /&gt;
           Serial.println(&amp;quot;cmd: 20&amp;quot;);&lt;br /&gt;
          }&lt;br /&gt;
         else if (command == 49) {        // If command = &amp;quot;1&amp;quot; &lt;br /&gt;
          Wire.beginTransmission(X9241_I2C_ADDRESS);&lt;br /&gt;
          Wire.send(0xd9); // Load WCR-10 with Reg-01&lt;br /&gt;
          Wire.endTransmission();&lt;br /&gt;
          Serial.println(&amp;quot;cmd: 21&amp;quot;);&lt;br /&gt;
         }&lt;br /&gt;
         else if (command == 50) {        // If command = &amp;quot;2&amp;quot; &lt;br /&gt;
          Wire.beginTransmission(X9241_I2C_ADDRESS);&lt;br /&gt;
          Wire.send(0xda); // Load WCR-10 with Reg-10&lt;br /&gt;
          Wire.endTransmission();&lt;br /&gt;
          Serial.println(&amp;quot;cmd: 22&amp;quot;);&lt;br /&gt;
         }&lt;br /&gt;
         else if (command == 51) {        // If command = &amp;quot;3&amp;quot; &lt;br /&gt;
          Wire.beginTransmission(X9241_I2C_ADDRESS);&lt;br /&gt;
          Wire.send(0xdb); // Load WCR-10 with Reg-11&lt;br /&gt;
          Wire.endTransmission();&lt;br /&gt;
          Serial.println(&amp;quot;cmd: 23&amp;quot;);&lt;br /&gt;
         }&lt;br /&gt;
        }&lt;br /&gt;
       }&lt;br /&gt;
       else if (command == 51) {      //If command = &amp;quot;3&amp;quot; Transfer Register-11 Data to WCR 0-3&lt;br /&gt;
        delay(100);&lt;br /&gt;
        if (Serial.available()) {&lt;br /&gt;
         command = Serial.read(); &lt;br /&gt;
        if (command == 48) {              // If command = &amp;quot;0&amp;quot; &lt;br /&gt;
          Wire.beginTransmission(X9241_I2C_ADDRESS);&lt;br /&gt;
          Wire.send(0xdc); // Load WCR-11 with Reg-00&lt;br /&gt;
          Wire.endTransmission();&lt;br /&gt;
          Serial.println(&amp;quot;cmd: 30&amp;quot;);&lt;br /&gt;
         }&lt;br /&gt;
         else if (command == 49) {        // If command = &amp;quot;1&amp;quot; &lt;br /&gt;
          Wire.beginTransmission(X9241_I2C_ADDRESS);&lt;br /&gt;
          Wire.send(0xdd); // Load WCR-11 with Reg-01&lt;br /&gt;
          Wire.endTransmission();&lt;br /&gt;
          Serial.println(&amp;quot;cmd: 31&amp;quot;);&lt;br /&gt;
         }&lt;br /&gt;
         else if (command == 50) {        // If command = &amp;quot;2&amp;quot; &lt;br /&gt;
          Wire.beginTransmission(X9241_I2C_ADDRESS);&lt;br /&gt;
          Wire.send(0xde); // Load WCR-11 with Reg-10&lt;br /&gt;
          Wire.endTransmission();&lt;br /&gt;
          Serial.println(&amp;quot;cmd: 32&amp;quot;);&lt;br /&gt;
         }&lt;br /&gt;
         else if (command == 51) {        // If command = &amp;quot;3&amp;quot; &lt;br /&gt;
          Wire.beginTransmission(X9241_I2C_ADDRESS);&lt;br /&gt;
          Wire.send(0xdf); // Load WCR-11 with Reg-11&lt;br /&gt;
          Wire.endTransmission();&lt;br /&gt;
          Serial.println(&amp;quot;cmd: 33&amp;quot;);&lt;br /&gt;
         }&lt;br /&gt;
        }&lt;br /&gt;
       }&lt;br /&gt;
       else if (command == 87) {      //If command = &amp;quot;W&amp;quot; write directly to WCR 0-3&lt;br /&gt;
        delay(100);&lt;br /&gt;
        if (Serial.available()) {&lt;br /&gt;
         command = Serial.read(); &lt;br /&gt;
        if (command == 48) {              // If command = &amp;quot;0&amp;quot; &lt;br /&gt;
          Wire.beginTransmission(X9241_I2C_ADDRESS);&lt;br /&gt;
          Wire.send(0xa0); //Instruction to write WCR-00&lt;br /&gt;
          Wire.send(0x10); //Send a D value of 16&lt;br /&gt;
          Wire.endTransmission();&lt;br /&gt;
          Serial.println(&amp;quot;cmd: W0&amp;quot;);&lt;br /&gt;
         }&lt;br /&gt;
         else if (command == 49) {        // If command = &amp;quot;1&amp;quot; &lt;br /&gt;
          Wire.beginTransmission(X9241_I2C_ADDRESS);&lt;br /&gt;
          Wire.send(0xa4); //Instruction to write WCR-01&lt;br /&gt;
          Wire.send(0x20); //Send a D value of 32&lt;br /&gt;
          Wire.endTransmission();&lt;br /&gt;
          Serial.println(&amp;quot;cmd: W1&amp;quot;);&lt;br /&gt;
         }&lt;br /&gt;
         else if (command == 50) {        // If command = &amp;quot;2&amp;quot; &lt;br /&gt;
          Wire.beginTransmission(X9241_I2C_ADDRESS);&lt;br /&gt;
          Wire.send(0xa8); //Instruction to write WCR-10&lt;br /&gt;
          Wire.send(0x2a); //Send a D value of 26&lt;br /&gt;
          Wire.endTransmission();&lt;br /&gt;
          Serial.println(&amp;quot;cmd: W2&amp;quot;);&lt;br /&gt;
         }&lt;br /&gt;
         else if (command == 51) {        // If command = &amp;quot;3&amp;quot; &lt;br /&gt;
          Wire.beginTransmission(X9241_I2C_ADDRESS);&lt;br /&gt;
          Wire.send(0xac); //Instruction to write WCR-11&lt;br /&gt;
          Wire.send(0x30); //Send a D value of 48&lt;br /&gt;
          Wire.endTransmission();&lt;br /&gt;
          Serial.println(&amp;quot;cmd: W3&amp;quot;);&lt;br /&gt;
         }&lt;br /&gt;
        }&lt;br /&gt;
       }&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
//*****************************************************The End***********************&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== x9241A_Digital_Potentiometer_v.01 User Guide ==&lt;br /&gt;
==== Commands ====&lt;/div&gt;</summary>
		<author><name>Combustor</name></author>	</entry>

	<entry>
		<id>http://combustory.com/wiki/index.php/X9241A_-_Digital_Potentiometer</id>
		<title>X9241A - Digital Potentiometer</title>
		<link rel="alternate" type="text/html" href="http://combustory.com/wiki/index.php/X9241A_-_Digital_Potentiometer"/>
				<updated>2008-09-25T23:55:03Z</updated>
		
		<summary type="html">&lt;p&gt;Combustor: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{default}}&lt;br /&gt;
&lt;br /&gt;
== Summary ==&lt;br /&gt;
&lt;br /&gt;
== Method ==&lt;br /&gt;
=== I2C ===&lt;br /&gt;
&lt;br /&gt;
There are basically only two functions that I am after right now which are both three byte instructions: &lt;br /&gt;
&lt;br /&gt;
* Read WCR(Wiper Control Register) for the four potentiometers 0-3 (So far this is failing miserably)&lt;br /&gt;
** Send 1st byte - Address (my circuit - 01011010 or 0x2D)(binary - 0101 A3 A2 A1 A0) A values are actual pins set to high or low for an address.&lt;br /&gt;
** Send 2nd byte - Instruction (binary - 1001 (1/0)(1/0) 00) - The two bits are used to choose the potentiometer&lt;br /&gt;
** Read WCR requested Byte&lt;br /&gt;
* Write WCR for the four potentiometers 0-3 (This works)&lt;br /&gt;
** Send 1st byte - Address (my circuit - 01011010 or 0x2D)(binary - 0101 A3 A2 A1 A0) A values are actual pins set to high or low for an address.&lt;br /&gt;
** Send 2nd byte - Instruction (binary - 1010 (1/0)(1/0) 00) - The two bits are used to choose the potentiometer&lt;br /&gt;
** Send WCR Byte - Potentiometer value (binary - 00 D5 D4 D3 D2 D1 D0) - D values are the 0-63 potentiometer positions&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== x9241A_Digital_Potentiometer_v.01 code ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
/*&lt;br /&gt;
 * x9241A Digital Potentiometer v.01&lt;br /&gt;
 * by &amp;lt;http://www.combustory.com&amp;gt; John Vaughters&lt;br /&gt;
 *&lt;br /&gt;
 * This Program illustrates the use of I2C to set up the x9241A Digital Potentiometer by setting and transferring the registers.&lt;br /&gt;
 * I attempted to read the register data through I2C, but was unable to get it to work.&lt;br /&gt;
 * Since the reading part was not so important to me I stopped trying.  &lt;br /&gt;
 * To set the registers up and transfer them to the Wiper registers met my goals and that is where I stopped.&lt;br /&gt;
 *&lt;br /&gt;
 * The x9142A has four Digital Pots and each pot has four static registers and one dynamic register the Wiper Control Register (WCR). &lt;br /&gt;
 * Therefore, there are 16 total bytes of storage and four WCR's.&lt;br /&gt;
 * This Program has the following commands:&lt;br /&gt;
 * S - Set the 16 registers.  Each pot has four registers and this command will set each register group with the same value. So register 00 for each pot will&lt;br /&gt;
 *     be the same value for each pot, and the same for register 01 through 11.&lt;br /&gt;
 * G(0-3) - Global Transfer of Registers to the WCR's.  This command will bulk load the values stored in registers into the WCR's.  &lt;br /&gt;
 *          For example, a G0 will load the 00 register for each pot into the WCR in one command. A G1 loads the 01 register for each pot, etc.&lt;br /&gt;
 * (0-3)(0-3) - This set of commands transfers a single register into a single WCR. The digits are arranged like this (WCR)(Reg). &lt;br /&gt;
 *              For example, a 00 command will load register 00 into WCR 00 or a 13 command will load register 11 into WCR 01, etc.&lt;br /&gt;
 * W(0-3) - This command writes directly to the WCR.  I have created four values that are just random, but the command shows how to write directly to the WCR for each pot.&lt;br /&gt;
 *          For example, a W0 command will write a value of decimal 16.  These commands are just for example purposes.&lt;br /&gt;
 *&lt;br /&gt;
 * Command Note: If you enter a command that is not recognized, then it is ignored and nothing happens and nothing is printed.&lt;br /&gt;
 */&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
#include &amp;quot;Wire.h&amp;quot;&lt;br /&gt;
#define X9241_I2C_ADDRESS 0x2D&lt;br /&gt;
&lt;br /&gt;
// Global Variables&lt;br /&gt;
long command;&lt;br /&gt;
  &lt;br /&gt;
&lt;br /&gt;
void setup() {&lt;br /&gt;
  Wire.begin();&lt;br /&gt;
  Serial.begin(57600);&lt;br /&gt;
  &lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
void loop() {&lt;br /&gt;
   if (Serial.available()) {      // Look for char in serial que and process if found&lt;br /&gt;
      command = Serial.read();&lt;br /&gt;
      if (command == 83) {      //If command = &amp;quot;S&amp;quot; Set Register Data&lt;br /&gt;
      // This sets the four registers of each Digital Pot&lt;br /&gt;
          Wire.beginTransmission(X9241_I2C_ADDRESS);&lt;br /&gt;
          Wire.send(0xc0);  // This is the set register command c and the 16 registers are 0-f&lt;br /&gt;
          Wire.send(0x0a);  // This line is the value to set the register: 0-63 is a valid setting&lt;br /&gt;
          Wire.endTransmission(); &lt;br /&gt;
          delay(100);&lt;br /&gt;
          Wire.beginTransmission(X9241_I2C_ADDRESS);&lt;br /&gt;
          Wire.send(0xc1);&lt;br /&gt;
          Wire.send(0x14);&lt;br /&gt;
          Wire.endTransmission();&lt;br /&gt;
          delay(100);&lt;br /&gt;
          Wire.beginTransmission(X9241_I2C_ADDRESS);&lt;br /&gt;
          Wire.send(0xc2);&lt;br /&gt;
          Wire.send(0x20);&lt;br /&gt;
          Wire.endTransmission();&lt;br /&gt;
          delay(100);&lt;br /&gt;
          Wire.beginTransmission(X9241_I2C_ADDRESS);&lt;br /&gt;
          Wire.send(0xc3);&lt;br /&gt;
          Wire.send(0x3c);&lt;br /&gt;
          Wire.endTransmission();&lt;br /&gt;
          delay(100);&lt;br /&gt;
          Wire.beginTransmission(X9241_I2C_ADDRESS);&lt;br /&gt;
          Wire.send(0xc4);&lt;br /&gt;
          Wire.send(0x0a);&lt;br /&gt;
          Wire.endTransmission(); &lt;br /&gt;
          delay(100);&lt;br /&gt;
          Wire.beginTransmission(X9241_I2C_ADDRESS);&lt;br /&gt;
          Wire.send(0xc5);&lt;br /&gt;
          Wire.send(0x14);&lt;br /&gt;
          Wire.endTransmission();&lt;br /&gt;
          delay(100);&lt;br /&gt;
          Wire.beginTransmission(X9241_I2C_ADDRESS);&lt;br /&gt;
          Wire.send(0xc6);&lt;br /&gt;
          Wire.send(0x20);&lt;br /&gt;
          Wire.endTransmission();&lt;br /&gt;
          delay(100);&lt;br /&gt;
          Wire.beginTransmission(X9241_I2C_ADDRESS);&lt;br /&gt;
          Wire.send(0xc7);&lt;br /&gt;
          Wire.send(0x3c);&lt;br /&gt;
          Wire.endTransmission();&lt;br /&gt;
          delay(100);          &lt;br /&gt;
          Wire.beginTransmission(X9241_I2C_ADDRESS);&lt;br /&gt;
          Wire.send(0xc8);&lt;br /&gt;
          Wire.send(0x0a);&lt;br /&gt;
          Wire.endTransmission(); &lt;br /&gt;
          delay(100);&lt;br /&gt;
          Wire.beginTransmission(X9241_I2C_ADDRESS);&lt;br /&gt;
          Wire.send(0xc9);&lt;br /&gt;
          Wire.send(0x14);&lt;br /&gt;
          Wire.endTransmission();&lt;br /&gt;
          delay(100);&lt;br /&gt;
          Wire.beginTransmission(X9241_I2C_ADDRESS);&lt;br /&gt;
          Wire.send(0xca);&lt;br /&gt;
          Wire.send(0x20);&lt;br /&gt;
          Wire.endTransmission();&lt;br /&gt;
          delay(100);&lt;br /&gt;
          Wire.beginTransmission(X9241_I2C_ADDRESS);&lt;br /&gt;
          Wire.send(0xcb);&lt;br /&gt;
          Wire.send(0x3c);&lt;br /&gt;
          Wire.endTransmission();&lt;br /&gt;
          delay(100);&lt;br /&gt;
          Wire.beginTransmission(X9241_I2C_ADDRESS);&lt;br /&gt;
          Wire.send(0xcc);&lt;br /&gt;
          Wire.send(0x0a);&lt;br /&gt;
          Wire.endTransmission(); &lt;br /&gt;
          delay(100);&lt;br /&gt;
          Wire.beginTransmission(X9241_I2C_ADDRESS);&lt;br /&gt;
          Wire.send(0xcd);&lt;br /&gt;
          Wire.send(0x14);&lt;br /&gt;
          Wire.endTransmission();&lt;br /&gt;
          delay(100);&lt;br /&gt;
          Wire.beginTransmission(X9241_I2C_ADDRESS);&lt;br /&gt;
          Wire.send(0xce);&lt;br /&gt;
          Wire.send(0x20);&lt;br /&gt;
          Wire.endTransmission();&lt;br /&gt;
          delay(100);&lt;br /&gt;
          Wire.beginTransmission(X9241_I2C_ADDRESS);&lt;br /&gt;
          Wire.send(0xcf);&lt;br /&gt;
          Wire.send(0x3c);&lt;br /&gt;
          Serial.println(&amp;quot;cmd: S&amp;quot;);&lt;br /&gt;
       }   &lt;br /&gt;
       else if (command == 71) {      //If command = &amp;quot;G&amp;quot; Transfer Global Register Data   &lt;br /&gt;
        delay(100);&lt;br /&gt;
        if (Serial.available()) {&lt;br /&gt;
         command = Serial.read(); &lt;br /&gt;
         if (command == 48) {        // If command = &amp;quot;0&amp;quot; &lt;br /&gt;
          Wire.beginTransmission(X9241_I2C_ADDRESS);&lt;br /&gt;
          Wire.send(0x10); // Global Load WCR's with Reg-00&lt;br /&gt;
          Wire.endTransmission();&lt;br /&gt;
          Serial.println(&amp;quot;cmd: G0&amp;quot;);&lt;br /&gt;
         }&lt;br /&gt;
         else if (command == 49) {        // If command = &amp;quot;1&amp;quot; &lt;br /&gt;
          Wire.beginTransmission(X9241_I2C_ADDRESS);&lt;br /&gt;
          Wire.send(0x11); // Global Load WCR's with Reg-01&lt;br /&gt;
          Wire.endTransmission();&lt;br /&gt;
          Serial.println(&amp;quot;cmd: G1&amp;quot;);&lt;br /&gt;
         }&lt;br /&gt;
         else if (command == 50) {        // If command = &amp;quot;2&amp;quot; &lt;br /&gt;
          Wire.beginTransmission(X9241_I2C_ADDRESS);&lt;br /&gt;
          Wire.send(0x12); // Global Load WCR's with Reg-10&lt;br /&gt;
          Wire.endTransmission();&lt;br /&gt;
          Serial.println(&amp;quot;cmd: G2&amp;quot;);&lt;br /&gt;
         }&lt;br /&gt;
         else if (command == 51) {        // If command = &amp;quot;3&amp;quot; &lt;br /&gt;
          Wire.beginTransmission(X9241_I2C_ADDRESS);&lt;br /&gt;
          Wire.send(0x13); // Global Load WCR's with Reg-11&lt;br /&gt;
          Wire.endTransmission();&lt;br /&gt;
          Serial.println(&amp;quot;cmd: G3&amp;quot;);&lt;br /&gt;
         }&lt;br /&gt;
        }&lt;br /&gt;
       }&lt;br /&gt;
       &lt;br /&gt;
       else if (command == 48) {      //If command = &amp;quot;0&amp;quot; Transfer Register-00 Data to WCR 0-3&lt;br /&gt;
         delay(100);&lt;br /&gt;
         if (Serial.available()) {&lt;br /&gt;
         command = Serial.read(); &lt;br /&gt;
         if (command == 48) {              // If command = &amp;quot;0&amp;quot; &lt;br /&gt;
          Wire.beginTransmission(X9241_I2C_ADDRESS);&lt;br /&gt;
          Wire.send(0xd0); // Load WCR-00 with Reg-00&lt;br /&gt;
          Wire.endTransmission();&lt;br /&gt;
          Serial.println(&amp;quot;cmd: 00&amp;quot;);&lt;br /&gt;
         }&lt;br /&gt;
         else if (command == 49) {        // If command = &amp;quot;1&amp;quot; &lt;br /&gt;
          Wire.beginTransmission(X9241_I2C_ADDRESS);&lt;br /&gt;
          Wire.send(0xd1); // Load WCR-00 with Reg-01&lt;br /&gt;
          Wire.endTransmission();&lt;br /&gt;
          Serial.println(&amp;quot;cmd: 01&amp;quot;);&lt;br /&gt;
         }&lt;br /&gt;
         else if (command == 50) {        // If command = &amp;quot;2&amp;quot; &lt;br /&gt;
          Wire.beginTransmission(X9241_I2C_ADDRESS);&lt;br /&gt;
          Wire.send(0xd2); // Load WCR-00 with Reg-10&lt;br /&gt;
          Wire.endTransmission();&lt;br /&gt;
          Serial.println(&amp;quot;cmd: 02&amp;quot;);&lt;br /&gt;
         }&lt;br /&gt;
         else if (command == 51) {        // If command = &amp;quot;3&amp;quot; &lt;br /&gt;
          Wire.beginTransmission(X9241_I2C_ADDRESS);&lt;br /&gt;
          Wire.send(0xd3); // Load WCR-00 with Reg-11&lt;br /&gt;
          Wire.endTransmission();&lt;br /&gt;
          Serial.println(&amp;quot;cmd: 03&amp;quot;);&lt;br /&gt;
         }&lt;br /&gt;
        }&lt;br /&gt;
       }&lt;br /&gt;
        else if (command == 49) {      //If command = &amp;quot;1&amp;quot; Transfer Register-01 Data to WCR 0-3&lt;br /&gt;
         delay(100);&lt;br /&gt;
         if (Serial.available()) {&lt;br /&gt;
         command = Serial.read(); &lt;br /&gt;
          if (command == 48) {              // If command = &amp;quot;0&amp;quot; &lt;br /&gt;
           Wire.beginTransmission(X9241_I2C_ADDRESS);&lt;br /&gt;
           Wire.send(0xd4); // Load WCR-01 with Reg-00&lt;br /&gt;
           Wire.endTransmission();&lt;br /&gt;
           Serial.println(&amp;quot;cmd: 10&amp;quot;);&lt;br /&gt;
          }&lt;br /&gt;
          else if (command == 49) {        // If command = &amp;quot;1&amp;quot; &lt;br /&gt;
           Wire.beginTransmission(X9241_I2C_ADDRESS);&lt;br /&gt;
           Wire.send(0xd5); // Load WCR-01 with Reg-01&lt;br /&gt;
           Wire.endTransmission();&lt;br /&gt;
           Serial.println(&amp;quot;cmd: 11&amp;quot;);&lt;br /&gt;
          }&lt;br /&gt;
          else if (command == 50) {        // If command = &amp;quot;2&amp;quot; &lt;br /&gt;
           Wire.beginTransmission(X9241_I2C_ADDRESS);&lt;br /&gt;
           Wire.send(0xd6); // Load WCR-01 with Reg-10&lt;br /&gt;
           Wire.endTransmission();&lt;br /&gt;
           Serial.println(&amp;quot;cmd: 12&amp;quot;);&lt;br /&gt;
          }&lt;br /&gt;
          else if (command == 51) {        // If command = &amp;quot;3&amp;quot; &lt;br /&gt;
           Wire.beginTransmission(X9241_I2C_ADDRESS);&lt;br /&gt;
           Wire.send(0xd7); // Load WCR-01 with Reg-11&lt;br /&gt;
           Wire.endTransmission();&lt;br /&gt;
           Serial.println(&amp;quot;cmd: 13&amp;quot;);&lt;br /&gt;
          }&lt;br /&gt;
         }&lt;br /&gt;
        }&lt;br /&gt;
        else if (command == 50) {      //If command = &amp;quot;2&amp;quot; Transfer Register-10 Data to WCR 0-3&lt;br /&gt;
         if (Serial.available()) {&lt;br /&gt;
          command = Serial.read(); &lt;br /&gt;
          if (command == 48) {              // If command = &amp;quot;0&amp;quot; &lt;br /&gt;
           Wire.beginTransmission(X9241_I2C_ADDRESS);&lt;br /&gt;
           Wire.send(0xd8); // Load WCR-10 with Reg-00&lt;br /&gt;
           Wire.endTransmission();&lt;br /&gt;
           Serial.println(&amp;quot;cmd: 20&amp;quot;);&lt;br /&gt;
          }&lt;br /&gt;
         else if (command == 49) {        // If command = &amp;quot;1&amp;quot; &lt;br /&gt;
          Wire.beginTransmission(X9241_I2C_ADDRESS);&lt;br /&gt;
          Wire.send(0xd9); // Load WCR-10 with Reg-01&lt;br /&gt;
          Wire.endTransmission();&lt;br /&gt;
          Serial.println(&amp;quot;cmd: 21&amp;quot;);&lt;br /&gt;
         }&lt;br /&gt;
         else if (command == 50) {        // If command = &amp;quot;2&amp;quot; &lt;br /&gt;
          Wire.beginTransmission(X9241_I2C_ADDRESS);&lt;br /&gt;
          Wire.send(0xda); // Load WCR-10 with Reg-10&lt;br /&gt;
          Wire.endTransmission();&lt;br /&gt;
          Serial.println(&amp;quot;cmd: 22&amp;quot;);&lt;br /&gt;
         }&lt;br /&gt;
         else if (command == 51) {        // If command = &amp;quot;3&amp;quot; &lt;br /&gt;
          Wire.beginTransmission(X9241_I2C_ADDRESS);&lt;br /&gt;
          Wire.send(0xdb); // Load WCR-10 with Reg-11&lt;br /&gt;
          Wire.endTransmission();&lt;br /&gt;
          Serial.println(&amp;quot;cmd: 23&amp;quot;);&lt;br /&gt;
         }&lt;br /&gt;
        }&lt;br /&gt;
       }&lt;br /&gt;
       else if (command == 51) {      //If command = &amp;quot;3&amp;quot; Transfer Register-11 Data to WCR 0-3&lt;br /&gt;
        delay(100);&lt;br /&gt;
        if (Serial.available()) {&lt;br /&gt;
         command = Serial.read(); &lt;br /&gt;
        if (command == 48) {              // If command = &amp;quot;0&amp;quot; &lt;br /&gt;
          Wire.beginTransmission(X9241_I2C_ADDRESS);&lt;br /&gt;
          Wire.send(0xdc); // Load WCR-11 with Reg-00&lt;br /&gt;
          Wire.endTransmission();&lt;br /&gt;
          Serial.println(&amp;quot;cmd: 30&amp;quot;);&lt;br /&gt;
         }&lt;br /&gt;
         else if (command == 49) {        // If command = &amp;quot;1&amp;quot; &lt;br /&gt;
          Wire.beginTransmission(X9241_I2C_ADDRESS);&lt;br /&gt;
          Wire.send(0xdd); // Load WCR-11 with Reg-01&lt;br /&gt;
          Wire.endTransmission();&lt;br /&gt;
          Serial.println(&amp;quot;cmd: 31&amp;quot;);&lt;br /&gt;
         }&lt;br /&gt;
         else if (command == 50) {        // If command = &amp;quot;2&amp;quot; &lt;br /&gt;
          Wire.beginTransmission(X9241_I2C_ADDRESS);&lt;br /&gt;
          Wire.send(0xde); // Load WCR-11 with Reg-10&lt;br /&gt;
          Wire.endTransmission();&lt;br /&gt;
          Serial.println(&amp;quot;cmd: 32&amp;quot;);&lt;br /&gt;
         }&lt;br /&gt;
         else if (command == 51) {        // If command = &amp;quot;3&amp;quot; &lt;br /&gt;
          Wire.beginTransmission(X9241_I2C_ADDRESS);&lt;br /&gt;
          Wire.send(0xdf); // Load WCR-11 with Reg-11&lt;br /&gt;
          Wire.endTransmission();&lt;br /&gt;
          Serial.println(&amp;quot;cmd: 33&amp;quot;);&lt;br /&gt;
         }&lt;br /&gt;
        }&lt;br /&gt;
       }&lt;br /&gt;
       else if (command == 87) {      //If command = &amp;quot;W&amp;quot; write directly to WCR 0-3&lt;br /&gt;
        delay(100);&lt;br /&gt;
        if (Serial.available()) {&lt;br /&gt;
         command = Serial.read(); &lt;br /&gt;
        if (command == 48) {              // If command = &amp;quot;0&amp;quot; &lt;br /&gt;
          Wire.beginTransmission(X9241_I2C_ADDRESS);&lt;br /&gt;
          Wire.send(0xa0); //Instruction to write WCR-00&lt;br /&gt;
          Wire.send(0x10); //Send a D value of 16&lt;br /&gt;
          Wire.endTransmission();&lt;br /&gt;
          Serial.println(&amp;quot;cmd: W0&amp;quot;);&lt;br /&gt;
         }&lt;br /&gt;
         else if (command == 49) {        // If command = &amp;quot;1&amp;quot; &lt;br /&gt;
          Wire.beginTransmission(X9241_I2C_ADDRESS);&lt;br /&gt;
          Wire.send(0xa4); //Instruction to write WCR-01&lt;br /&gt;
          Wire.send(0x20); //Send a D value of 32&lt;br /&gt;
          Wire.endTransmission();&lt;br /&gt;
          Serial.println(&amp;quot;cmd: W1&amp;quot;);&lt;br /&gt;
         }&lt;br /&gt;
         else if (command == 50) {        // If command = &amp;quot;2&amp;quot; &lt;br /&gt;
          Wire.beginTransmission(X9241_I2C_ADDRESS);&lt;br /&gt;
          Wire.send(0xa8); //Instruction to write WCR-10&lt;br /&gt;
          Wire.send(0x2a); //Send a D value of 26&lt;br /&gt;
          Wire.endTransmission();&lt;br /&gt;
          Serial.println(&amp;quot;cmd: W2&amp;quot;);&lt;br /&gt;
         }&lt;br /&gt;
         else if (command == 51) {        // If command = &amp;quot;3&amp;quot; &lt;br /&gt;
          Wire.beginTransmission(X9241_I2C_ADDRESS);&lt;br /&gt;
          Wire.send(0xac); //Instruction to write WCR-11&lt;br /&gt;
          Wire.send(0x30); //Send a D value of 48&lt;br /&gt;
          Wire.endTransmission();&lt;br /&gt;
          Serial.println(&amp;quot;cmd: W3&amp;quot;);&lt;br /&gt;
         }&lt;br /&gt;
        }&lt;br /&gt;
       }&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
//*****************************************************The End***********************&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== x9241A_Digital_Potentiometer_v.01 User Guide ==&lt;br /&gt;
==== Commands ====&lt;/div&gt;</summary>
		<author><name>Combustor</name></author>	</entry>

	<entry>
		<id>http://combustory.com/wiki/index.php/X9241A_-_Digital_Potentiometer</id>
		<title>X9241A - Digital Potentiometer</title>
		<link rel="alternate" type="text/html" href="http://combustory.com/wiki/index.php/X9241A_-_Digital_Potentiometer"/>
				<updated>2008-09-14T02:33:41Z</updated>
		
		<summary type="html">&lt;p&gt;Combustor: /* x9241A_Digital_Potentiometer_v.01 code */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{default}}&lt;br /&gt;
&lt;br /&gt;
== Summary ==&lt;br /&gt;
&lt;br /&gt;
== Example of Method ==&lt;br /&gt;
=== I2C ===&lt;br /&gt;
&lt;br /&gt;
There are basically only two functions that I am after right now which are both three byte instructions: &lt;br /&gt;
&lt;br /&gt;
* Read WCR(Wiper Control Register) for the four potentiometers 0-3 (So far this is failing miserably)&lt;br /&gt;
** Send 1st byte - Address (my circuit - 01011010 or 0x2D)(binary - 0101 A3 A2 A1 A0) A values are actual pins set to high or low for an address.&lt;br /&gt;
** Send 2nd byte - Instruction (binary - 1001 (1/0)(1/0) 00) - The two bits are used to choose the potentiometer&lt;br /&gt;
** Read WCR requested Byte&lt;br /&gt;
* Write WCR for the four potentiometers 0-3 (This works)&lt;br /&gt;
** Send 1st byte - Address (my circuit - 01011010 or 0x2D)(binary - 0101 A3 A2 A1 A0) A values are actual pins set to high or low for an address.&lt;br /&gt;
** Send 2nd byte - Instruction (binary - 1010 (1/0)(1/0) 00) - The two bits are used to choose the potentiometer&lt;br /&gt;
** Send WCR Byte - Potentiometer value (binary - 00 D5 D4 D3 D2 D1 D0) - D values are the 0-63 potentiometer positions&lt;br /&gt;
&lt;br /&gt;
'''Sample Code'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
       Wire.beginTransmission(X9241_I2C_ADDRESS);&lt;br /&gt;
       Wire.send(0xa0); //Instruction to write WCR-00&lt;br /&gt;
       Wire.send(0x20); //Send a D value of 32&lt;br /&gt;
       Wire.endTransmission();&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== x9241A_Digital_Potentiometer_v.01 code ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
/*&lt;br /&gt;
 * x9241A Digital Potentiometer v.01&lt;br /&gt;
 * by &amp;lt;http://www.combustory.com&amp;gt; John Vaughters&lt;br /&gt;
 *&lt;br /&gt;
 * This Program illustrates the use of I2C to set up the x9241A Digital Potentiometer by setting and transferring the registers.&lt;br /&gt;
 * I attempted to read the register data through I2C, but was unable to get it to work.&lt;br /&gt;
 * Since the reading part was not so important to me I stopped trying.  &lt;br /&gt;
 * To set the registers up and transfer them to the Wiper registers met my goals and that is where I stopped.&lt;br /&gt;
 *&lt;br /&gt;
 * The x9142A has four Digital Pots and each pot has four static registers and one dynamic register the Wiper Control Register (WCR). &lt;br /&gt;
 * Therefore, there are 16 total bytes of storage and four WCR's.&lt;br /&gt;
 * This Program has the following commands:&lt;br /&gt;
 * S - Set the 16 registers.  Each pot has four registers and this command will set each register group with the same value. So register 00 for each pot will&lt;br /&gt;
 *     be the same value for each pot, and the same for register 01 through 11.&lt;br /&gt;
 * G(0-3) - Global Transfer of Registers to the WCR's.  This command will bulk load the values stored in registers into the WCR's.  &lt;br /&gt;
 *          For example, a G0 will load the 00 register for each pot into the WCR in one command. A G1 loads the 01 register for each pot, etc.&lt;br /&gt;
 * (0-3)(0-3) - This set of commands transfers a single register into a single WCR. The digits are arranged like this (WCR)(Reg). &lt;br /&gt;
 *              For example, a 00 command will load register 00 into WCR 00 or a 13 command will load register 11 into WCR 01, etc.&lt;br /&gt;
 * W(0-3) - This command writes directly to the WCR.  I have created four values that are just random, but the command shows how to write directly to the WCR for each pot.&lt;br /&gt;
 *          For example, a W0 command will write a value of decimal 16.  These commands are just for example purposes.&lt;br /&gt;
 *&lt;br /&gt;
 * Command Note: If you enter a command that is not recognized, then it is ignored and nothing happens and nothing is printed.&lt;br /&gt;
 */&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
#include &amp;quot;Wire.h&amp;quot;&lt;br /&gt;
#define X9241_I2C_ADDRESS 0x2D&lt;br /&gt;
&lt;br /&gt;
// Global Variables&lt;br /&gt;
long command;&lt;br /&gt;
  &lt;br /&gt;
&lt;br /&gt;
void setup() {&lt;br /&gt;
  Wire.begin();&lt;br /&gt;
  Serial.begin(57600);&lt;br /&gt;
  &lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
void loop() {&lt;br /&gt;
   if (Serial.available()) {      // Look for char in serial que and process if found&lt;br /&gt;
      command = Serial.read();&lt;br /&gt;
      if (command == 83) {      //If command = &amp;quot;S&amp;quot; Set Register Data&lt;br /&gt;
      // This sets the four registers of each Digital Pot&lt;br /&gt;
          Wire.beginTransmission(X9241_I2C_ADDRESS);&lt;br /&gt;
          Wire.send(0xc0);  // This is the set register command c and the 16 registers are 0-f&lt;br /&gt;
          Wire.send(0x0a);  // This line is the value to set the register: 0-63 is a valid setting&lt;br /&gt;
          Wire.endTransmission(); &lt;br /&gt;
          delay(100);&lt;br /&gt;
          Wire.beginTransmission(X9241_I2C_ADDRESS);&lt;br /&gt;
          Wire.send(0xc1);&lt;br /&gt;
          Wire.send(0x14);&lt;br /&gt;
          Wire.endTransmission();&lt;br /&gt;
          delay(100);&lt;br /&gt;
          Wire.beginTransmission(X9241_I2C_ADDRESS);&lt;br /&gt;
          Wire.send(0xc2);&lt;br /&gt;
          Wire.send(0x20);&lt;br /&gt;
          Wire.endTransmission();&lt;br /&gt;
          delay(100);&lt;br /&gt;
          Wire.beginTransmission(X9241_I2C_ADDRESS);&lt;br /&gt;
          Wire.send(0xc3);&lt;br /&gt;
          Wire.send(0x3c);&lt;br /&gt;
          Wire.endTransmission();&lt;br /&gt;
          delay(100);&lt;br /&gt;
          Wire.beginTransmission(X9241_I2C_ADDRESS);&lt;br /&gt;
          Wire.send(0xc4);&lt;br /&gt;
          Wire.send(0x0a);&lt;br /&gt;
          Wire.endTransmission(); &lt;br /&gt;
          delay(100);&lt;br /&gt;
          Wire.beginTransmission(X9241_I2C_ADDRESS);&lt;br /&gt;
          Wire.send(0xc5);&lt;br /&gt;
          Wire.send(0x14);&lt;br /&gt;
          Wire.endTransmission();&lt;br /&gt;
          delay(100);&lt;br /&gt;
          Wire.beginTransmission(X9241_I2C_ADDRESS);&lt;br /&gt;
          Wire.send(0xc6);&lt;br /&gt;
          Wire.send(0x20);&lt;br /&gt;
          Wire.endTransmission();&lt;br /&gt;
          delay(100);&lt;br /&gt;
          Wire.beginTransmission(X9241_I2C_ADDRESS);&lt;br /&gt;
          Wire.send(0xc7);&lt;br /&gt;
          Wire.send(0x3c);&lt;br /&gt;
          Wire.endTransmission();&lt;br /&gt;
          delay(100);          &lt;br /&gt;
          Wire.beginTransmission(X9241_I2C_ADDRESS);&lt;br /&gt;
          Wire.send(0xc8);&lt;br /&gt;
          Wire.send(0x0a);&lt;br /&gt;
          Wire.endTransmission(); &lt;br /&gt;
          delay(100);&lt;br /&gt;
          Wire.beginTransmission(X9241_I2C_ADDRESS);&lt;br /&gt;
          Wire.send(0xc9);&lt;br /&gt;
          Wire.send(0x14);&lt;br /&gt;
          Wire.endTransmission();&lt;br /&gt;
          delay(100);&lt;br /&gt;
          Wire.beginTransmission(X9241_I2C_ADDRESS);&lt;br /&gt;
          Wire.send(0xca);&lt;br /&gt;
          Wire.send(0x20);&lt;br /&gt;
          Wire.endTransmission();&lt;br /&gt;
          delay(100);&lt;br /&gt;
          Wire.beginTransmission(X9241_I2C_ADDRESS);&lt;br /&gt;
          Wire.send(0xcb);&lt;br /&gt;
          Wire.send(0x3c);&lt;br /&gt;
          Wire.endTransmission();&lt;br /&gt;
          delay(100);&lt;br /&gt;
          Wire.beginTransmission(X9241_I2C_ADDRESS);&lt;br /&gt;
          Wire.send(0xcc);&lt;br /&gt;
          Wire.send(0x0a);&lt;br /&gt;
          Wire.endTransmission(); &lt;br /&gt;
          delay(100);&lt;br /&gt;
          Wire.beginTransmission(X9241_I2C_ADDRESS);&lt;br /&gt;
          Wire.send(0xcd);&lt;br /&gt;
          Wire.send(0x14);&lt;br /&gt;
          Wire.endTransmission();&lt;br /&gt;
          delay(100);&lt;br /&gt;
          Wire.beginTransmission(X9241_I2C_ADDRESS);&lt;br /&gt;
          Wire.send(0xce);&lt;br /&gt;
          Wire.send(0x20);&lt;br /&gt;
          Wire.endTransmission();&lt;br /&gt;
          delay(100);&lt;br /&gt;
          Wire.beginTransmission(X9241_I2C_ADDRESS);&lt;br /&gt;
          Wire.send(0xcf);&lt;br /&gt;
          Wire.send(0x3c);&lt;br /&gt;
          Serial.println(&amp;quot;cmd: S&amp;quot;);&lt;br /&gt;
       }   &lt;br /&gt;
       else if (command == 71) {      //If command = &amp;quot;G&amp;quot; Transfer Global Register Data   &lt;br /&gt;
        delay(100);&lt;br /&gt;
        if (Serial.available()) {&lt;br /&gt;
         command = Serial.read(); &lt;br /&gt;
         if (command == 48) {        // If command = &amp;quot;0&amp;quot; &lt;br /&gt;
          Wire.beginTransmission(X9241_I2C_ADDRESS);&lt;br /&gt;
          Wire.send(0x10); // Global Load WCR's with Reg-00&lt;br /&gt;
          Wire.endTransmission();&lt;br /&gt;
          Serial.println(&amp;quot;cmd: G0&amp;quot;);&lt;br /&gt;
         }&lt;br /&gt;
         else if (command == 49) {        // If command = &amp;quot;1&amp;quot; &lt;br /&gt;
          Wire.beginTransmission(X9241_I2C_ADDRESS);&lt;br /&gt;
          Wire.send(0x11); // Global Load WCR's with Reg-01&lt;br /&gt;
          Wire.endTransmission();&lt;br /&gt;
          Serial.println(&amp;quot;cmd: G1&amp;quot;);&lt;br /&gt;
         }&lt;br /&gt;
         else if (command == 50) {        // If command = &amp;quot;2&amp;quot; &lt;br /&gt;
          Wire.beginTransmission(X9241_I2C_ADDRESS);&lt;br /&gt;
          Wire.send(0x12); // Global Load WCR's with Reg-10&lt;br /&gt;
          Wire.endTransmission();&lt;br /&gt;
          Serial.println(&amp;quot;cmd: G2&amp;quot;);&lt;br /&gt;
         }&lt;br /&gt;
         else if (command == 51) {        // If command = &amp;quot;3&amp;quot; &lt;br /&gt;
          Wire.beginTransmission(X9241_I2C_ADDRESS);&lt;br /&gt;
          Wire.send(0x13); // Global Load WCR's with Reg-11&lt;br /&gt;
          Wire.endTransmission();&lt;br /&gt;
          Serial.println(&amp;quot;cmd: G3&amp;quot;);&lt;br /&gt;
         }&lt;br /&gt;
        }&lt;br /&gt;
       }&lt;br /&gt;
       &lt;br /&gt;
       else if (command == 48) {      //If command = &amp;quot;0&amp;quot; Transfer Register-00 Data to WCR 0-3&lt;br /&gt;
         delay(100);&lt;br /&gt;
         if (Serial.available()) {&lt;br /&gt;
         command = Serial.read(); &lt;br /&gt;
         if (command == 48) {              // If command = &amp;quot;0&amp;quot; &lt;br /&gt;
          Wire.beginTransmission(X9241_I2C_ADDRESS);&lt;br /&gt;
          Wire.send(0xd0); // Load WCR-00 with Reg-00&lt;br /&gt;
          Wire.endTransmission();&lt;br /&gt;
          Serial.println(&amp;quot;cmd: 00&amp;quot;);&lt;br /&gt;
         }&lt;br /&gt;
         else if (command == 49) {        // If command = &amp;quot;1&amp;quot; &lt;br /&gt;
          Wire.beginTransmission(X9241_I2C_ADDRESS);&lt;br /&gt;
          Wire.send(0xd1); // Load WCR-00 with Reg-01&lt;br /&gt;
          Wire.endTransmission();&lt;br /&gt;
          Serial.println(&amp;quot;cmd: 01&amp;quot;);&lt;br /&gt;
         }&lt;br /&gt;
         else if (command == 50) {        // If command = &amp;quot;2&amp;quot; &lt;br /&gt;
          Wire.beginTransmission(X9241_I2C_ADDRESS);&lt;br /&gt;
          Wire.send(0xd2); // Load WCR-00 with Reg-10&lt;br /&gt;
          Wire.endTransmission();&lt;br /&gt;
          Serial.println(&amp;quot;cmd: 02&amp;quot;);&lt;br /&gt;
         }&lt;br /&gt;
         else if (command == 51) {        // If command = &amp;quot;3&amp;quot; &lt;br /&gt;
          Wire.beginTransmission(X9241_I2C_ADDRESS);&lt;br /&gt;
          Wire.send(0xd3); // Load WCR-00 with Reg-11&lt;br /&gt;
          Wire.endTransmission();&lt;br /&gt;
          Serial.println(&amp;quot;cmd: 03&amp;quot;);&lt;br /&gt;
         }&lt;br /&gt;
        }&lt;br /&gt;
       }&lt;br /&gt;
        else if (command == 49) {      //If command = &amp;quot;1&amp;quot; Transfer Register-01 Data to WCR 0-3&lt;br /&gt;
         delay(100);&lt;br /&gt;
         if (Serial.available()) {&lt;br /&gt;
         command = Serial.read(); &lt;br /&gt;
          if (command == 48) {              // If command = &amp;quot;0&amp;quot; &lt;br /&gt;
           Wire.beginTransmission(X9241_I2C_ADDRESS);&lt;br /&gt;
           Wire.send(0xd4); // Load WCR-01 with Reg-00&lt;br /&gt;
           Wire.endTransmission();&lt;br /&gt;
           Serial.println(&amp;quot;cmd: 10&amp;quot;);&lt;br /&gt;
          }&lt;br /&gt;
          else if (command == 49) {        // If command = &amp;quot;1&amp;quot; &lt;br /&gt;
           Wire.beginTransmission(X9241_I2C_ADDRESS);&lt;br /&gt;
           Wire.send(0xd5); // Load WCR-01 with Reg-01&lt;br /&gt;
           Wire.endTransmission();&lt;br /&gt;
           Serial.println(&amp;quot;cmd: 11&amp;quot;);&lt;br /&gt;
          }&lt;br /&gt;
          else if (command == 50) {        // If command = &amp;quot;2&amp;quot; &lt;br /&gt;
           Wire.beginTransmission(X9241_I2C_ADDRESS);&lt;br /&gt;
           Wire.send(0xd6); // Load WCR-01 with Reg-10&lt;br /&gt;
           Wire.endTransmission();&lt;br /&gt;
           Serial.println(&amp;quot;cmd: 12&amp;quot;);&lt;br /&gt;
          }&lt;br /&gt;
          else if (command == 51) {        // If command = &amp;quot;3&amp;quot; &lt;br /&gt;
           Wire.beginTransmission(X9241_I2C_ADDRESS);&lt;br /&gt;
           Wire.send(0xd7); // Load WCR-01 with Reg-11&lt;br /&gt;
           Wire.endTransmission();&lt;br /&gt;
           Serial.println(&amp;quot;cmd: 13&amp;quot;);&lt;br /&gt;
          }&lt;br /&gt;
         }&lt;br /&gt;
        }&lt;br /&gt;
        else if (command == 50) {      //If command = &amp;quot;2&amp;quot; Transfer Register-10 Data to WCR 0-3&lt;br /&gt;
         if (Serial.available()) {&lt;br /&gt;
          command = Serial.read(); &lt;br /&gt;
          if (command == 48) {              // If command = &amp;quot;0&amp;quot; &lt;br /&gt;
           Wire.beginTransmission(X9241_I2C_ADDRESS);&lt;br /&gt;
           Wire.send(0xd8); // Load WCR-10 with Reg-00&lt;br /&gt;
           Wire.endTransmission();&lt;br /&gt;
           Serial.println(&amp;quot;cmd: 20&amp;quot;);&lt;br /&gt;
          }&lt;br /&gt;
         else if (command == 49) {        // If command = &amp;quot;1&amp;quot; &lt;br /&gt;
          Wire.beginTransmission(X9241_I2C_ADDRESS);&lt;br /&gt;
          Wire.send(0xd9); // Load WCR-10 with Reg-01&lt;br /&gt;
          Wire.endTransmission();&lt;br /&gt;
          Serial.println(&amp;quot;cmd: 21&amp;quot;);&lt;br /&gt;
         }&lt;br /&gt;
         else if (command == 50) {        // If command = &amp;quot;2&amp;quot; &lt;br /&gt;
          Wire.beginTransmission(X9241_I2C_ADDRESS);&lt;br /&gt;
          Wire.send(0xda); // Load WCR-10 with Reg-10&lt;br /&gt;
          Wire.endTransmission();&lt;br /&gt;
          Serial.println(&amp;quot;cmd: 22&amp;quot;);&lt;br /&gt;
         }&lt;br /&gt;
         else if (command == 51) {        // If command = &amp;quot;3&amp;quot; &lt;br /&gt;
          Wire.beginTransmission(X9241_I2C_ADDRESS);&lt;br /&gt;
          Wire.send(0xdb); // Load WCR-10 with Reg-11&lt;br /&gt;
          Wire.endTransmission();&lt;br /&gt;
          Serial.println(&amp;quot;cmd: 23&amp;quot;);&lt;br /&gt;
         }&lt;br /&gt;
        }&lt;br /&gt;
       }&lt;br /&gt;
       else if (command == 51) {      //If command = &amp;quot;3&amp;quot; Transfer Register-11 Data to WCR 0-3&lt;br /&gt;
        delay(100);&lt;br /&gt;
        if (Serial.available()) {&lt;br /&gt;
         command = Serial.read(); &lt;br /&gt;
        if (command == 48) {              // If command = &amp;quot;0&amp;quot; &lt;br /&gt;
          Wire.beginTransmission(X9241_I2C_ADDRESS);&lt;br /&gt;
          Wire.send(0xdc); // Load WCR-11 with Reg-00&lt;br /&gt;
          Wire.endTransmission();&lt;br /&gt;
          Serial.println(&amp;quot;cmd: 30&amp;quot;);&lt;br /&gt;
         }&lt;br /&gt;
         else if (command == 49) {        // If command = &amp;quot;1&amp;quot; &lt;br /&gt;
          Wire.beginTransmission(X9241_I2C_ADDRESS);&lt;br /&gt;
          Wire.send(0xdd); // Load WCR-11 with Reg-01&lt;br /&gt;
          Wire.endTransmission();&lt;br /&gt;
          Serial.println(&amp;quot;cmd: 31&amp;quot;);&lt;br /&gt;
         }&lt;br /&gt;
         else if (command == 50) {        // If command = &amp;quot;2&amp;quot; &lt;br /&gt;
          Wire.beginTransmission(X9241_I2C_ADDRESS);&lt;br /&gt;
          Wire.send(0xde); // Load WCR-11 with Reg-10&lt;br /&gt;
          Wire.endTransmission();&lt;br /&gt;
          Serial.println(&amp;quot;cmd: 32&amp;quot;);&lt;br /&gt;
         }&lt;br /&gt;
         else if (command == 51) {        // If command = &amp;quot;3&amp;quot; &lt;br /&gt;
          Wire.beginTransmission(X9241_I2C_ADDRESS);&lt;br /&gt;
          Wire.send(0xdf); // Load WCR-11 with Reg-11&lt;br /&gt;
          Wire.endTransmission();&lt;br /&gt;
          Serial.println(&amp;quot;cmd: 33&amp;quot;);&lt;br /&gt;
         }&lt;br /&gt;
        }&lt;br /&gt;
       }&lt;br /&gt;
       else if (command == 87) {      //If command = &amp;quot;W&amp;quot; write directly to WCR 0-3&lt;br /&gt;
        delay(100);&lt;br /&gt;
        if (Serial.available()) {&lt;br /&gt;
         command = Serial.read(); &lt;br /&gt;
        if (command == 48) {              // If command = &amp;quot;0&amp;quot; &lt;br /&gt;
          Wire.beginTransmission(X9241_I2C_ADDRESS);&lt;br /&gt;
          Wire.send(0xa0); //Instruction to write WCR-00&lt;br /&gt;
          Wire.send(0x10); //Send a D value of 16&lt;br /&gt;
          Wire.endTransmission();&lt;br /&gt;
          Serial.println(&amp;quot;cmd: W0&amp;quot;);&lt;br /&gt;
         }&lt;br /&gt;
         else if (command == 49) {        // If command = &amp;quot;1&amp;quot; &lt;br /&gt;
          Wire.beginTransmission(X9241_I2C_ADDRESS);&lt;br /&gt;
          Wire.send(0xa4); //Instruction to write WCR-01&lt;br /&gt;
          Wire.send(0x20); //Send a D value of 32&lt;br /&gt;
          Wire.endTransmission();&lt;br /&gt;
          Serial.println(&amp;quot;cmd: W1&amp;quot;);&lt;br /&gt;
         }&lt;br /&gt;
         else if (command == 50) {        // If command = &amp;quot;2&amp;quot; &lt;br /&gt;
          Wire.beginTransmission(X9241_I2C_ADDRESS);&lt;br /&gt;
          Wire.send(0xa8); //Instruction to write WCR-10&lt;br /&gt;
          Wire.send(0x2a); //Send a D value of 26&lt;br /&gt;
          Wire.endTransmission();&lt;br /&gt;
          Serial.println(&amp;quot;cmd: W2&amp;quot;);&lt;br /&gt;
         }&lt;br /&gt;
         else if (command == 51) {        // If command = &amp;quot;3&amp;quot; &lt;br /&gt;
          Wire.beginTransmission(X9241_I2C_ADDRESS);&lt;br /&gt;
          Wire.send(0xac); //Instruction to write WCR-11&lt;br /&gt;
          Wire.send(0x30); //Send a D value of 48&lt;br /&gt;
          Wire.endTransmission();&lt;br /&gt;
          Serial.println(&amp;quot;cmd: W3&amp;quot;);&lt;br /&gt;
         }&lt;br /&gt;
        }&lt;br /&gt;
       }&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
//*****************************************************The End***********************&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== x9241A_Digital_Potentiometer_v.01 User Guide ==&lt;br /&gt;
==== Commands ====&lt;br /&gt;
== Troubleshooting ==&lt;br /&gt;
=== Summary ===&lt;br /&gt;
=== Quick Test ===&lt;/div&gt;</summary>
		<author><name>Combustor</name></author>	</entry>

	<entry>
		<id>http://combustory.com/wiki/index.php/X9241A_-_Digital_Potentiometer</id>
		<title>X9241A - Digital Potentiometer</title>
		<link rel="alternate" type="text/html" href="http://combustory.com/wiki/index.php/X9241A_-_Digital_Potentiometer"/>
				<updated>2008-09-13T02:08:12Z</updated>
		
		<summary type="html">&lt;p&gt;Combustor: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{default}}&lt;br /&gt;
&lt;br /&gt;
== Summary ==&lt;br /&gt;
&lt;br /&gt;
== Example of Method ==&lt;br /&gt;
=== I2C ===&lt;br /&gt;
&lt;br /&gt;
There are basically only two functions that I am after right now which are both three byte instructions: &lt;br /&gt;
&lt;br /&gt;
* Read WCR(Wiper Control Register) for the four potentiometers 0-3 (So far this is failing miserably)&lt;br /&gt;
** Send 1st byte - Address (my circuit - 01011010 or 0x2D)(binary - 0101 A3 A2 A1 A0) A values are actual pins set to high or low for an address.&lt;br /&gt;
** Send 2nd byte - Instruction (binary - 1001 (1/0)(1/0) 00) - The two bits are used to choose the potentiometer&lt;br /&gt;
** Read WCR requested Byte&lt;br /&gt;
* Write WCR for the four potentiometers 0-3 (This works)&lt;br /&gt;
** Send 1st byte - Address (my circuit - 01011010 or 0x2D)(binary - 0101 A3 A2 A1 A0) A values are actual pins set to high or low for an address.&lt;br /&gt;
** Send 2nd byte - Instruction (binary - 1010 (1/0)(1/0) 00) - The two bits are used to choose the potentiometer&lt;br /&gt;
** Send WCR Byte - Potentiometer value (binary - 00 D5 D4 D3 D2 D1 D0) - D values are the 0-63 potentiometer positions&lt;br /&gt;
&lt;br /&gt;
'''Sample Code'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
       Wire.beginTransmission(X9241_I2C_ADDRESS);&lt;br /&gt;
       Wire.send(0xa0); //Instruction to write WCR-00&lt;br /&gt;
       Wire.send(0x20); //Send a D value of 32&lt;br /&gt;
       Wire.endTransmission();&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== x9241A_Digital_Potentiometer_v.01 code ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
/*&lt;br /&gt;
 * x9241A Digital Potentiometer v.01&lt;br /&gt;
 * by &amp;lt;http://www.combustory.com&amp;gt; John Vaughters&lt;br /&gt;
 *&lt;br /&gt;
 * This Program illustrates the use of I2C to set up the x9241A Digital Potentiometer by setting and transferring the registers.&lt;br /&gt;
 * I attempted to read the register data through I2C, but was unable to get it to work.&lt;br /&gt;
 * Since the reading part was not so important to me I stopped trying.  &lt;br /&gt;
 * To set the registers up and transfer them to the Wiper registers met my goals and that is where I stopped.&lt;br /&gt;
 *&lt;br /&gt;
 * The x9142A has four Digital Pots and each pot has four static registers and one dynamic register the Wiper Control Register (WCR). &lt;br /&gt;
 * Therefore, there are 16 total bytes of storage and four WCR's.&lt;br /&gt;
 * This Program has the following commands:&lt;br /&gt;
 * S - Set the 16 registers.  Each pot has four registers and this command will set each register group with the same value. So register 00 for each pot will&lt;br /&gt;
 *     be the same value for each pot, and the same for register 01 through 11.&lt;br /&gt;
 * G(0-3) - Global Transfer of Registers to the WCR's.  This command will bulk load the values stored in registers into the WCR's.  &lt;br /&gt;
 *          For example, a G0 will load the 00 register for each pot into the WCR in one command. A G1 loads the 01 register for each pot, etc.&lt;br /&gt;
 * (0-3)(0-3) - This set of commands transfers a single register into a single WCR. The digits are arranged like this (WCR)(Reg). &lt;br /&gt;
 *              For example, a 00 command will load register 00 into WCR 00 or a 13 command will load register 11 into WCR 01, etc.&lt;br /&gt;
 * W(0-3) - This command writes directly to the WCR.  I have created four values that are just random, but the command shows how to write directly to the WCR for each pot.&lt;br /&gt;
 *          For example, a W0 command will write a value of decimal 16.  These commands are just for example purposes.&lt;br /&gt;
 *&lt;br /&gt;
 * Command Note: If you enter a command that is not recognized, then it is ignored and nothing happens and nothing is printed.&lt;br /&gt;
 */&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
#include &amp;quot;Wire.h&amp;quot;&lt;br /&gt;
#define X9241_I2C_ADDRESS 0x2D&lt;br /&gt;
&lt;br /&gt;
// Global Variables&lt;br /&gt;
long command;&lt;br /&gt;
  &lt;br /&gt;
&lt;br /&gt;
void setup() {&lt;br /&gt;
  Wire.begin();&lt;br /&gt;
  Serial.begin(57600);&lt;br /&gt;
  &lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
void loop() {&lt;br /&gt;
   if (Serial.available()) {      // Look for char in serial que and process if found&lt;br /&gt;
      command = Serial.read();&lt;br /&gt;
      if (command == 83) {      //If command = &amp;quot;S&amp;quot; Set Register Data&lt;br /&gt;
      // This sets the four registers of each Digital Pot&lt;br /&gt;
          Wire.beginTransmission(X9241_I2C_ADDRESS);&lt;br /&gt;
          Wire.send(0xc0);  // This is the set register command c and the 16 registers are 0-f&lt;br /&gt;
          Wire.send(0x0a);  // This line is the value to set the register: 0-63 is a valid setting&lt;br /&gt;
          Wire.endTransmission(); &lt;br /&gt;
          delay(100);&lt;br /&gt;
          Wire.beginTransmission(X9241_I2C_ADDRESS);&lt;br /&gt;
          Wire.send(0xc1);&lt;br /&gt;
          Wire.send(0x14);&lt;br /&gt;
          Wire.endTransmission();&lt;br /&gt;
          delay(100);&lt;br /&gt;
          Wire.beginTransmission(X9241_I2C_ADDRESS);&lt;br /&gt;
          Wire.send(0xc2);&lt;br /&gt;
          Wire.send(0x20);&lt;br /&gt;
          Wire.endTransmission();&lt;br /&gt;
          delay(100);&lt;br /&gt;
          Wire.beginTransmission(X9241_I2C_ADDRESS);&lt;br /&gt;
          Wire.send(0xc3);&lt;br /&gt;
          Wire.send(0x3c);&lt;br /&gt;
          Wire.endTransmission();&lt;br /&gt;
          delay(100);&lt;br /&gt;
          Wire.beginTransmission(X9241_I2C_ADDRESS);&lt;br /&gt;
          Wire.send(0xc4);&lt;br /&gt;
          Wire.send(0x0a);&lt;br /&gt;
          Wire.endTransmission(); &lt;br /&gt;
          delay(100);&lt;br /&gt;
          Wire.beginTransmission(X9241_I2C_ADDRESS);&lt;br /&gt;
          Wire.send(0xc5);&lt;br /&gt;
          Wire.send(0x14);&lt;br /&gt;
          Wire.endTransmission();&lt;br /&gt;
          delay(100);&lt;br /&gt;
          Wire.beginTransmission(X9241_I2C_ADDRESS);&lt;br /&gt;
          Wire.send(0xc6);&lt;br /&gt;
          Wire.send(0x20);&lt;br /&gt;
          Wire.endTransmission();&lt;br /&gt;
          delay(100);&lt;br /&gt;
          Wire.beginTransmission(X9241_I2C_ADDRESS);&lt;br /&gt;
          Wire.send(0xc7);&lt;br /&gt;
          Wire.send(0x3c);&lt;br /&gt;
          delay(100);          &lt;br /&gt;
          Wire.beginTransmission(X9241_I2C_ADDRESS);&lt;br /&gt;
          Wire.send(0xc8);&lt;br /&gt;
          Wire.send(0x0a);&lt;br /&gt;
          Wire.endTransmission(); &lt;br /&gt;
          delay(100);&lt;br /&gt;
          Wire.beginTransmission(X9241_I2C_ADDRESS);&lt;br /&gt;
          Wire.send(0xc9);&lt;br /&gt;
          Wire.send(0x14);&lt;br /&gt;
          Wire.endTransmission();&lt;br /&gt;
          delay(100);&lt;br /&gt;
          Wire.beginTransmission(X9241_I2C_ADDRESS);&lt;br /&gt;
          Wire.send(0xca);&lt;br /&gt;
          Wire.send(0x20);&lt;br /&gt;
          Wire.endTransmission();&lt;br /&gt;
          delay(100);&lt;br /&gt;
          Wire.beginTransmission(X9241_I2C_ADDRESS);&lt;br /&gt;
          Wire.send(0xcb);&lt;br /&gt;
          Wire.send(0x3c);&lt;br /&gt;
          Wire.endTransmission();&lt;br /&gt;
          delay(100);&lt;br /&gt;
          Wire.beginTransmission(X9241_I2C_ADDRESS);&lt;br /&gt;
          Wire.send(0xcc);&lt;br /&gt;
          Wire.send(0x0a);&lt;br /&gt;
          Wire.endTransmission(); &lt;br /&gt;
          delay(100);&lt;br /&gt;
          Wire.beginTransmission(X9241_I2C_ADDRESS);&lt;br /&gt;
          Wire.send(0xcd);&lt;br /&gt;
          Wire.send(0x14);&lt;br /&gt;
          Wire.endTransmission();&lt;br /&gt;
          delay(100);&lt;br /&gt;
          Wire.beginTransmission(X9241_I2C_ADDRESS);&lt;br /&gt;
          Wire.send(0xce);&lt;br /&gt;
          Wire.send(0x20);&lt;br /&gt;
          Wire.endTransmission();&lt;br /&gt;
          delay(100);&lt;br /&gt;
          Wire.beginTransmission(X9241_I2C_ADDRESS);&lt;br /&gt;
          Wire.send(0xcf);&lt;br /&gt;
          Wire.send(0x3c);&lt;br /&gt;
          Serial.println(&amp;quot;cmd: S&amp;quot;);&lt;br /&gt;
       }   &lt;br /&gt;
       else if (command == 71) {      //If command = &amp;quot;G&amp;quot; Transfer Global Register Data   &lt;br /&gt;
        delay(100);&lt;br /&gt;
        if (Serial.available()) {&lt;br /&gt;
         command = Serial.read(); &lt;br /&gt;
         if (command == 48) {        // If command = &amp;quot;0&amp;quot; &lt;br /&gt;
          Wire.beginTransmission(X9241_I2C_ADDRESS);&lt;br /&gt;
          Wire.send(0x10); // Global Load WCR's with Reg-00&lt;br /&gt;
          Wire.endTransmission();&lt;br /&gt;
          Serial.println(&amp;quot;cmd: G0&amp;quot;);&lt;br /&gt;
         }&lt;br /&gt;
         else if (command == 49) {        // If command = &amp;quot;1&amp;quot; &lt;br /&gt;
          Wire.beginTransmission(X9241_I2C_ADDRESS);&lt;br /&gt;
          Wire.send(0x11); // Global Load WCR's with Reg-01&lt;br /&gt;
          Wire.endTransmission();&lt;br /&gt;
          Serial.println(&amp;quot;cmd: G1&amp;quot;);&lt;br /&gt;
         }&lt;br /&gt;
         else if (command == 50) {        // If command = &amp;quot;2&amp;quot; &lt;br /&gt;
          Wire.beginTransmission(X9241_I2C_ADDRESS);&lt;br /&gt;
          Wire.send(0x12); // Global Load WCR's with Reg-10&lt;br /&gt;
          Wire.endTransmission();&lt;br /&gt;
          Serial.println(&amp;quot;cmd: G2&amp;quot;);&lt;br /&gt;
         }&lt;br /&gt;
         else if (command == 51) {        // If command = &amp;quot;3&amp;quot; &lt;br /&gt;
          Wire.beginTransmission(X9241_I2C_ADDRESS);&lt;br /&gt;
          Wire.send(0x13); // Global Load WCR's with Reg-11&lt;br /&gt;
          Wire.endTransmission();&lt;br /&gt;
          Serial.println(&amp;quot;cmd: G3&amp;quot;);&lt;br /&gt;
         }&lt;br /&gt;
        }&lt;br /&gt;
       }&lt;br /&gt;
       &lt;br /&gt;
       else if (command == 48) {      //If command = &amp;quot;0&amp;quot; Transfer Register-00 Data to WCR 0-3&lt;br /&gt;
         delay(100);&lt;br /&gt;
         if (Serial.available()) {&lt;br /&gt;
         command = Serial.read(); &lt;br /&gt;
         if (command == 48) {              // If command = &amp;quot;0&amp;quot; &lt;br /&gt;
          Wire.beginTransmission(X9241_I2C_ADDRESS);&lt;br /&gt;
          Wire.send(0xd0); // Load WCR-00 with Reg-00&lt;br /&gt;
          Wire.endTransmission();&lt;br /&gt;
          Serial.println(&amp;quot;cmd: 00&amp;quot;);&lt;br /&gt;
         }&lt;br /&gt;
         else if (command == 49) {        // If command = &amp;quot;1&amp;quot; &lt;br /&gt;
          Wire.beginTransmission(X9241_I2C_ADDRESS);&lt;br /&gt;
          Wire.send(0xd1); // Load WCR-00 with Reg-01&lt;br /&gt;
          Wire.endTransmission();&lt;br /&gt;
          Serial.println(&amp;quot;cmd: 01&amp;quot;);&lt;br /&gt;
         }&lt;br /&gt;
         else if (command == 50) {        // If command = &amp;quot;2&amp;quot; &lt;br /&gt;
          Wire.beginTransmission(X9241_I2C_ADDRESS);&lt;br /&gt;
          Wire.send(0xd2); // Load WCR-00 with Reg-10&lt;br /&gt;
          Wire.endTransmission();&lt;br /&gt;
          Serial.println(&amp;quot;cmd: 02&amp;quot;);&lt;br /&gt;
         }&lt;br /&gt;
         else if (command == 51) {        // If command = &amp;quot;3&amp;quot; &lt;br /&gt;
          Wire.beginTransmission(X9241_I2C_ADDRESS);&lt;br /&gt;
          Wire.send(0xd3); // Load WCR-00 with Reg-11&lt;br /&gt;
          Wire.endTransmission();&lt;br /&gt;
          Serial.println(&amp;quot;cmd: 03&amp;quot;);&lt;br /&gt;
         }&lt;br /&gt;
        }&lt;br /&gt;
       }&lt;br /&gt;
        else if (command == 49) {      //If command = &amp;quot;1&amp;quot; Transfer Register-01 Data to WCR 0-3&lt;br /&gt;
         delay(100);&lt;br /&gt;
         if (Serial.available()) {&lt;br /&gt;
         command = Serial.read(); &lt;br /&gt;
          if (command == 48) {              // If command = &amp;quot;0&amp;quot; &lt;br /&gt;
           Wire.beginTransmission(X9241_I2C_ADDRESS);&lt;br /&gt;
           Wire.send(0xd4); // Load WCR-01 with Reg-00&lt;br /&gt;
           Wire.endTransmission();&lt;br /&gt;
           Serial.println(&amp;quot;cmd: 10&amp;quot;);&lt;br /&gt;
          }&lt;br /&gt;
          else if (command == 49) {        // If command = &amp;quot;1&amp;quot; &lt;br /&gt;
           Wire.beginTransmission(X9241_I2C_ADDRESS);&lt;br /&gt;
           Wire.send(0xd5); // Load WCR-01 with Reg-01&lt;br /&gt;
           Wire.endTransmission();&lt;br /&gt;
           Serial.println(&amp;quot;cmd: 11&amp;quot;);&lt;br /&gt;
          }&lt;br /&gt;
          else if (command == 50) {        // If command = &amp;quot;2&amp;quot; &lt;br /&gt;
           Wire.beginTransmission(X9241_I2C_ADDRESS);&lt;br /&gt;
           Wire.send(0xd6); // Load WCR-01 with Reg-10&lt;br /&gt;
           Wire.endTransmission();&lt;br /&gt;
           Serial.println(&amp;quot;cmd: 12&amp;quot;);&lt;br /&gt;
          }&lt;br /&gt;
          else if (command == 51) {        // If command = &amp;quot;3&amp;quot; &lt;br /&gt;
           Wire.beginTransmission(X9241_I2C_ADDRESS);&lt;br /&gt;
           Wire.send(0xd7); // Load WCR-01 with Reg-11&lt;br /&gt;
           Wire.endTransmission();&lt;br /&gt;
           Serial.println(&amp;quot;cmd: 13&amp;quot;);&lt;br /&gt;
          }&lt;br /&gt;
         }&lt;br /&gt;
        }&lt;br /&gt;
        else if (command == 50) {      //If command = &amp;quot;2&amp;quot; Transfer Register-10 Data to WCR 0-3&lt;br /&gt;
         if (Serial.available()) {&lt;br /&gt;
          command = Serial.read(); &lt;br /&gt;
          if (command == 48) {              // If command = &amp;quot;0&amp;quot; &lt;br /&gt;
           Wire.beginTransmission(X9241_I2C_ADDRESS);&lt;br /&gt;
           Wire.send(0xd8); // Load WCR-10 with Reg-00&lt;br /&gt;
           Wire.endTransmission();&lt;br /&gt;
           Serial.println(&amp;quot;cmd: 20&amp;quot;);&lt;br /&gt;
          }&lt;br /&gt;
         else if (command == 49) {        // If command = &amp;quot;1&amp;quot; &lt;br /&gt;
          Wire.beginTransmission(X9241_I2C_ADDRESS);&lt;br /&gt;
          Wire.send(0xd9); // Load WCR-10 with Reg-01&lt;br /&gt;
          Wire.endTransmission();&lt;br /&gt;
          Serial.println(&amp;quot;cmd: 21&amp;quot;);&lt;br /&gt;
         }&lt;br /&gt;
         else if (command == 50) {        // If command = &amp;quot;2&amp;quot; &lt;br /&gt;
          Wire.beginTransmission(X9241_I2C_ADDRESS);&lt;br /&gt;
          Wire.send(0xda); // Load WCR-10 with Reg-10&lt;br /&gt;
          Wire.endTransmission();&lt;br /&gt;
          Serial.println(&amp;quot;cmd: 22&amp;quot;);&lt;br /&gt;
         }&lt;br /&gt;
         else if (command == 51) {        // If command = &amp;quot;3&amp;quot; &lt;br /&gt;
          Wire.beginTransmission(X9241_I2C_ADDRESS);&lt;br /&gt;
          Wire.send(0xdb); // Load WCR-10 with Reg-11&lt;br /&gt;
          Wire.endTransmission();&lt;br /&gt;
          Serial.println(&amp;quot;cmd: 23&amp;quot;);&lt;br /&gt;
         }&lt;br /&gt;
        }&lt;br /&gt;
       }&lt;br /&gt;
       else if (command == 51) {      //If command = &amp;quot;3&amp;quot; Transfer Register-11 Data to WCR 0-3&lt;br /&gt;
        delay(100);&lt;br /&gt;
        if (Serial.available()) {&lt;br /&gt;
         command = Serial.read(); &lt;br /&gt;
        if (command == 48) {              // If command = &amp;quot;0&amp;quot; &lt;br /&gt;
          Wire.beginTransmission(X9241_I2C_ADDRESS);&lt;br /&gt;
          Wire.send(0xdc); // Load WCR-11 with Reg-00&lt;br /&gt;
          Wire.endTransmission();&lt;br /&gt;
          Serial.println(&amp;quot;cmd: 30&amp;quot;);&lt;br /&gt;
         }&lt;br /&gt;
         else if (command == 49) {        // If command = &amp;quot;1&amp;quot; &lt;br /&gt;
          Wire.beginTransmission(X9241_I2C_ADDRESS);&lt;br /&gt;
          Wire.send(0xdd); // Load WCR-11 with Reg-01&lt;br /&gt;
          Wire.endTransmission();&lt;br /&gt;
          Serial.println(&amp;quot;cmd: 31&amp;quot;);&lt;br /&gt;
         }&lt;br /&gt;
         else if (command == 50) {        // If command = &amp;quot;2&amp;quot; &lt;br /&gt;
          Wire.beginTransmission(X9241_I2C_ADDRESS);&lt;br /&gt;
          Wire.send(0xde); // Load WCR-11 with Reg-10&lt;br /&gt;
          Wire.endTransmission();&lt;br /&gt;
          Serial.println(&amp;quot;cmd: 32&amp;quot;);&lt;br /&gt;
         }&lt;br /&gt;
         else if (command == 51) {        // If command = &amp;quot;3&amp;quot; &lt;br /&gt;
          Wire.beginTransmission(X9241_I2C_ADDRESS);&lt;br /&gt;
          Wire.send(0xdf); // Load WCR-11 with Reg-11&lt;br /&gt;
          Wire.endTransmission();&lt;br /&gt;
          Serial.println(&amp;quot;cmd: 33&amp;quot;);&lt;br /&gt;
         }&lt;br /&gt;
        }&lt;br /&gt;
       }&lt;br /&gt;
       else if (command == 87) {      //If command = &amp;quot;W&amp;quot; write directly to WCR 0-3&lt;br /&gt;
        delay(100);&lt;br /&gt;
        if (Serial.available()) {&lt;br /&gt;
         command = Serial.read(); &lt;br /&gt;
        if (command == 48) {              // If command = &amp;quot;0&amp;quot; &lt;br /&gt;
          Wire.beginTransmission(X9241_I2C_ADDRESS);&lt;br /&gt;
          Wire.send(0xa0); //Instruction to write WCR-00&lt;br /&gt;
          Wire.send(0x10); //Send a D value of 16&lt;br /&gt;
          Wire.endTransmission();&lt;br /&gt;
          Serial.println(&amp;quot;cmd: W0&amp;quot;);&lt;br /&gt;
         }&lt;br /&gt;
         else if (command == 49) {        // If command = &amp;quot;1&amp;quot; &lt;br /&gt;
          Wire.beginTransmission(X9241_I2C_ADDRESS);&lt;br /&gt;
          Wire.send(0xa4); //Instruction to write WCR-01&lt;br /&gt;
          Wire.send(0x20); //Send a D value of 32&lt;br /&gt;
          Wire.endTransmission();&lt;br /&gt;
          Serial.println(&amp;quot;cmd: W1&amp;quot;);&lt;br /&gt;
         }&lt;br /&gt;
         else if (command == 50) {        // If command = &amp;quot;2&amp;quot; &lt;br /&gt;
          Wire.beginTransmission(X9241_I2C_ADDRESS);&lt;br /&gt;
          Wire.send(0xa8); //Instruction to write WCR-10&lt;br /&gt;
          Wire.send(0x2a); //Send a D value of 26&lt;br /&gt;
          Wire.endTransmission();&lt;br /&gt;
          Serial.println(&amp;quot;cmd: W2&amp;quot;);&lt;br /&gt;
         }&lt;br /&gt;
         else if (command == 51) {        // If command = &amp;quot;3&amp;quot; &lt;br /&gt;
          Wire.beginTransmission(X9241_I2C_ADDRESS);&lt;br /&gt;
          Wire.send(0xac); //Instruction to write WCR-11&lt;br /&gt;
          Wire.send(0x30); //Send a D value of 48&lt;br /&gt;
          Wire.endTransmission();&lt;br /&gt;
          Serial.println(&amp;quot;cmd: W3&amp;quot;);&lt;br /&gt;
         }&lt;br /&gt;
        }&lt;br /&gt;
       }&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
//*****************************************************The End***********************&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== x9241A_Digital_Potentiometer_v.01 User Guide ==&lt;br /&gt;
==== Commands ====&lt;br /&gt;
== Troubleshooting ==&lt;br /&gt;
=== Summary ===&lt;br /&gt;
=== Quick Test ===&lt;/div&gt;</summary>
		<author><name>Combustor</name></author>	</entry>

	<entry>
		<id>http://combustory.com/wiki/index.php/X9241A_-_Digital_Potentiometer</id>
		<title>X9241A - Digital Potentiometer</title>
		<link rel="alternate" type="text/html" href="http://combustory.com/wiki/index.php/X9241A_-_Digital_Potentiometer"/>
				<updated>2008-09-13T02:05:23Z</updated>
		
		<summary type="html">&lt;p&gt;Combustor: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{default}}&lt;br /&gt;
== Warning ==&lt;br /&gt;
'''This page is in progress and none of the code can be considered good or complete. I am just using this as an alternate storage of the code for right now.'''&lt;br /&gt;
&lt;br /&gt;
== Summary ==&lt;br /&gt;
&lt;br /&gt;
== Example of Method ==&lt;br /&gt;
=== I2C ===&lt;br /&gt;
&lt;br /&gt;
There are basically only two functions that I am after right now which are both three byte instructions: &lt;br /&gt;
&lt;br /&gt;
* Read WCR(Wiper Control Register) for the four potentiometers 0-3 (So far this is failing miserably)&lt;br /&gt;
** Send 1st byte - Address (my circuit - 01011010 or 0x2D)(binary - 0101 A3 A2 A1 A0) A values are actual pins set to high or low for an address.&lt;br /&gt;
** Send 2nd byte - Instruction (binary - 1001 (1/0)(1/0) 00) - The two bits are used to choose the potentiometer&lt;br /&gt;
** Read WCR requested Byte&lt;br /&gt;
* Write WCR for the four potentiometers 0-3 (This works)&lt;br /&gt;
** Send 1st byte - Address (my circuit - 01011010 or 0x2D)(binary - 0101 A3 A2 A1 A0) A values are actual pins set to high or low for an address.&lt;br /&gt;
** Send 2nd byte - Instruction (binary - 1010 (1/0)(1/0) 00) - The two bits are used to choose the potentiometer&lt;br /&gt;
** Send WCR Byte - Potentiometer value (binary - 00 D5 D4 D3 D2 D1 D0) - D values are the 0-63 potentiometer positions&lt;br /&gt;
&lt;br /&gt;
'''Sample Code'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
       Wire.beginTransmission(X9241_I2C_ADDRESS);&lt;br /&gt;
       Wire.send(0xa0); //Instruction to write WCR-00&lt;br /&gt;
       Wire.send(0x20); //Send a D value of 32&lt;br /&gt;
       Wire.endTransmission();&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== x9241A_Digital_Potentiometer_v.01 code ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
/*&lt;br /&gt;
 * x9241A Digital Potentiometer v.01&lt;br /&gt;
 * by &amp;lt;http://www.combustory.com&amp;gt; John Vaughters&lt;br /&gt;
 *&lt;br /&gt;
 * This Program illustrates the use of I2C to set up the x9241A Digital Potentiometer by setting and transferring the registers.&lt;br /&gt;
 * I attempted to read the register data through I2C, but was unable to get it to work.&lt;br /&gt;
 * Since the reading part was not so important to me I stopped trying.  &lt;br /&gt;
 * To set the registers up and transfer them to the Wiper registers met my goals and that is where I stopped.&lt;br /&gt;
 *&lt;br /&gt;
 * The x9142A has four Digital Pots and each pot has four static registers and one dynamic register the Wiper Control Register (WCR). &lt;br /&gt;
 * Therefore, there are 16 total bytes of storage and four WCR's.&lt;br /&gt;
 * This Program has the following commands:&lt;br /&gt;
 * S - Set the 16 registers.  Each pot has four registers and this command will set each register group with the same value. So register 00 for each pot will&lt;br /&gt;
 *     be the same value for each pot, and the same for register 01 through 11.&lt;br /&gt;
 * G(0-3) - Global Transfer of Registers to the WCR's.  This command will bulk load the values stored in registers into the WCR's.  &lt;br /&gt;
 *          For example, a G0 will load the 00 register for each pot into the WCR in one command. A G1 loads the 01 register for each pot, etc.&lt;br /&gt;
 * (0-3)(0-3) - This set of commands transfers a single register into a single WCR. The digits are arranged like this (WCR)(Reg). &lt;br /&gt;
 *              For example, a 00 command will load register 00 into WCR 00 or a 13 command will load register 11 into WCR 01, etc.&lt;br /&gt;
 * W(0-3) - This command writes directly to the WCR.  I have created four values that are just random, but the command shows how to write directly to the WCR for each pot.&lt;br /&gt;
 *          For example, a W0 command will write a value of decimal 16.  These commands are just for example purposes.&lt;br /&gt;
 *&lt;br /&gt;
 * Command Note: If you enter a command that is not recognized, then it is ignored and nothing happens and nothing is printed.&lt;br /&gt;
 */&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
#include &amp;quot;Wire.h&amp;quot;&lt;br /&gt;
#define X9241_I2C_ADDRESS 0x2D&lt;br /&gt;
&lt;br /&gt;
// Global Variables&lt;br /&gt;
long command;&lt;br /&gt;
  &lt;br /&gt;
&lt;br /&gt;
void setup() {&lt;br /&gt;
  Wire.begin();&lt;br /&gt;
  Serial.begin(57600);&lt;br /&gt;
  &lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
void loop() {&lt;br /&gt;
   if (Serial.available()) {      // Look for char in serial que and process if found&lt;br /&gt;
      command = Serial.read();&lt;br /&gt;
      if (command == 83) {      //If command = &amp;quot;S&amp;quot; Set Register Data&lt;br /&gt;
      // This sets the four registers of each Digital Pot&lt;br /&gt;
          Wire.beginTransmission(X9241_I2C_ADDRESS);&lt;br /&gt;
          Wire.send(0xc0);  // This is the set register command c and the 16 registers are 0-f&lt;br /&gt;
          Wire.send(0x0a);  // This line is the value to set the register: 0-63 is a valid setting&lt;br /&gt;
          Wire.endTransmission(); &lt;br /&gt;
          delay(100);&lt;br /&gt;
          Wire.beginTransmission(X9241_I2C_ADDRESS);&lt;br /&gt;
          Wire.send(0xc1);&lt;br /&gt;
          Wire.send(0x14);&lt;br /&gt;
          Wire.endTransmission();&lt;br /&gt;
          delay(100);&lt;br /&gt;
          Wire.beginTransmission(X9241_I2C_ADDRESS);&lt;br /&gt;
          Wire.send(0xc2);&lt;br /&gt;
          Wire.send(0x20);&lt;br /&gt;
          Wire.endTransmission();&lt;br /&gt;
          delay(100);&lt;br /&gt;
          Wire.beginTransmission(X9241_I2C_ADDRESS);&lt;br /&gt;
          Wire.send(0xc3);&lt;br /&gt;
          Wire.send(0x3c);&lt;br /&gt;
          Wire.endTransmission();&lt;br /&gt;
          delay(100);&lt;br /&gt;
          Wire.beginTransmission(X9241_I2C_ADDRESS);&lt;br /&gt;
          Wire.send(0xc4);&lt;br /&gt;
          Wire.send(0x0a);&lt;br /&gt;
          Wire.endTransmission(); &lt;br /&gt;
          delay(100);&lt;br /&gt;
          Wire.beginTransmission(X9241_I2C_ADDRESS);&lt;br /&gt;
          Wire.send(0xc5);&lt;br /&gt;
          Wire.send(0x14);&lt;br /&gt;
          Wire.endTransmission();&lt;br /&gt;
          delay(100);&lt;br /&gt;
          Wire.beginTransmission(X9241_I2C_ADDRESS);&lt;br /&gt;
          Wire.send(0xc6);&lt;br /&gt;
          Wire.send(0x20);&lt;br /&gt;
          Wire.endTransmission();&lt;br /&gt;
          delay(100);&lt;br /&gt;
          Wire.beginTransmission(X9241_I2C_ADDRESS);&lt;br /&gt;
          Wire.send(0xc7);&lt;br /&gt;
          Wire.send(0x3c);&lt;br /&gt;
          delay(100);          &lt;br /&gt;
          Wire.beginTransmission(X9241_I2C_ADDRESS);&lt;br /&gt;
          Wire.send(0xc8);&lt;br /&gt;
          Wire.send(0x0a);&lt;br /&gt;
          Wire.endTransmission(); &lt;br /&gt;
          delay(100);&lt;br /&gt;
          Wire.beginTransmission(X9241_I2C_ADDRESS);&lt;br /&gt;
          Wire.send(0xc9);&lt;br /&gt;
          Wire.send(0x14);&lt;br /&gt;
          Wire.endTransmission();&lt;br /&gt;
          delay(100);&lt;br /&gt;
          Wire.beginTransmission(X9241_I2C_ADDRESS);&lt;br /&gt;
          Wire.send(0xca);&lt;br /&gt;
          Wire.send(0x20);&lt;br /&gt;
          Wire.endTransmission();&lt;br /&gt;
          delay(100);&lt;br /&gt;
          Wire.beginTransmission(X9241_I2C_ADDRESS);&lt;br /&gt;
          Wire.send(0xcb);&lt;br /&gt;
          Wire.send(0x3c);&lt;br /&gt;
          Wire.endTransmission();&lt;br /&gt;
          delay(100);&lt;br /&gt;
          Wire.beginTransmission(X9241_I2C_ADDRESS);&lt;br /&gt;
          Wire.send(0xcc);&lt;br /&gt;
          Wire.send(0x0a);&lt;br /&gt;
          Wire.endTransmission(); &lt;br /&gt;
          delay(100);&lt;br /&gt;
          Wire.beginTransmission(X9241_I2C_ADDRESS);&lt;br /&gt;
          Wire.send(0xcd);&lt;br /&gt;
          Wire.send(0x14);&lt;br /&gt;
          Wire.endTransmission();&lt;br /&gt;
          delay(100);&lt;br /&gt;
          Wire.beginTransmission(X9241_I2C_ADDRESS);&lt;br /&gt;
          Wire.send(0xce);&lt;br /&gt;
          Wire.send(0x20);&lt;br /&gt;
          Wire.endTransmission();&lt;br /&gt;
          delay(100);&lt;br /&gt;
          Wire.beginTransmission(X9241_I2C_ADDRESS);&lt;br /&gt;
          Wire.send(0xcf);&lt;br /&gt;
          Wire.send(0x3c);&lt;br /&gt;
          Serial.println(&amp;quot;cmd: S&amp;quot;);&lt;br /&gt;
       }   &lt;br /&gt;
       else if (command == 71) {      //If command = &amp;quot;G&amp;quot; Transfer Global Register Data   &lt;br /&gt;
        delay(100);&lt;br /&gt;
        if (Serial.available()) {&lt;br /&gt;
         command = Serial.read(); &lt;br /&gt;
         if (command == 48) {        // If command = &amp;quot;0&amp;quot; &lt;br /&gt;
          Wire.beginTransmission(X9241_I2C_ADDRESS);&lt;br /&gt;
          Wire.send(0x10); // Global Load WCR's with Reg-00&lt;br /&gt;
          Wire.endTransmission();&lt;br /&gt;
          Serial.println(&amp;quot;cmd: G0&amp;quot;);&lt;br /&gt;
         }&lt;br /&gt;
         else if (command == 49) {        // If command = &amp;quot;1&amp;quot; &lt;br /&gt;
          Wire.beginTransmission(X9241_I2C_ADDRESS);&lt;br /&gt;
          Wire.send(0x11); // Global Load WCR's with Reg-01&lt;br /&gt;
          Wire.endTransmission();&lt;br /&gt;
          Serial.println(&amp;quot;cmd: G1&amp;quot;);&lt;br /&gt;
         }&lt;br /&gt;
         else if (command == 50) {        // If command = &amp;quot;2&amp;quot; &lt;br /&gt;
          Wire.beginTransmission(X9241_I2C_ADDRESS);&lt;br /&gt;
          Wire.send(0x12); // Global Load WCR's with Reg-10&lt;br /&gt;
          Wire.endTransmission();&lt;br /&gt;
          Serial.println(&amp;quot;cmd: G2&amp;quot;);&lt;br /&gt;
         }&lt;br /&gt;
         else if (command == 51) {        // If command = &amp;quot;3&amp;quot; &lt;br /&gt;
          Wire.beginTransmission(X9241_I2C_ADDRESS);&lt;br /&gt;
          Wire.send(0x13); // Global Load WCR's with Reg-11&lt;br /&gt;
          Wire.endTransmission();&lt;br /&gt;
          Serial.println(&amp;quot;cmd: G3&amp;quot;);&lt;br /&gt;
         }&lt;br /&gt;
        }&lt;br /&gt;
       }&lt;br /&gt;
       &lt;br /&gt;
       else if (command == 48) {      //If command = &amp;quot;0&amp;quot; Transfer Register-00 Data to WCR 0-3&lt;br /&gt;
         delay(100);&lt;br /&gt;
         if (Serial.available()) {&lt;br /&gt;
         command = Serial.read(); &lt;br /&gt;
         if (command == 48) {              // If command = &amp;quot;0&amp;quot; &lt;br /&gt;
          Wire.beginTransmission(X9241_I2C_ADDRESS);&lt;br /&gt;
          Wire.send(0xd0); // Load WCR-00 with Reg-00&lt;br /&gt;
          Wire.endTransmission();&lt;br /&gt;
          Serial.println(&amp;quot;cmd: 00&amp;quot;);&lt;br /&gt;
         }&lt;br /&gt;
         else if (command == 49) {        // If command = &amp;quot;1&amp;quot; &lt;br /&gt;
          Wire.beginTransmission(X9241_I2C_ADDRESS);&lt;br /&gt;
          Wire.send(0xd1); // Load WCR-00 with Reg-01&lt;br /&gt;
          Wire.endTransmission();&lt;br /&gt;
          Serial.println(&amp;quot;cmd: 01&amp;quot;);&lt;br /&gt;
         }&lt;br /&gt;
         else if (command == 50) {        // If command = &amp;quot;2&amp;quot; &lt;br /&gt;
          Wire.beginTransmission(X9241_I2C_ADDRESS);&lt;br /&gt;
          Wire.send(0xd2); // Load WCR-00 with Reg-10&lt;br /&gt;
          Wire.endTransmission();&lt;br /&gt;
          Serial.println(&amp;quot;cmd: 02&amp;quot;);&lt;br /&gt;
         }&lt;br /&gt;
         else if (command == 51) {        // If command = &amp;quot;3&amp;quot; &lt;br /&gt;
          Wire.beginTransmission(X9241_I2C_ADDRESS);&lt;br /&gt;
          Wire.send(0xd3); // Load WCR-00 with Reg-11&lt;br /&gt;
          Wire.endTransmission();&lt;br /&gt;
          Serial.println(&amp;quot;cmd: 03&amp;quot;);&lt;br /&gt;
         }&lt;br /&gt;
        }&lt;br /&gt;
       }&lt;br /&gt;
        else if (command == 49) {      //If command = &amp;quot;1&amp;quot; Transfer Register-01 Data to WCR 0-3&lt;br /&gt;
         delay(100);&lt;br /&gt;
         if (Serial.available()) {&lt;br /&gt;
         command = Serial.read(); &lt;br /&gt;
          if (command == 48) {              // If command = &amp;quot;0&amp;quot; &lt;br /&gt;
           Wire.beginTransmission(X9241_I2C_ADDRESS);&lt;br /&gt;
           Wire.send(0xd4); // Load WCR-01 with Reg-00&lt;br /&gt;
           Wire.endTransmission();&lt;br /&gt;
           Serial.println(&amp;quot;cmd: 10&amp;quot;);&lt;br /&gt;
          }&lt;br /&gt;
          else if (command == 49) {        // If command = &amp;quot;1&amp;quot; &lt;br /&gt;
           Wire.beginTransmission(X9241_I2C_ADDRESS);&lt;br /&gt;
           Wire.send(0xd5); // Load WCR-01 with Reg-01&lt;br /&gt;
           Wire.endTransmission();&lt;br /&gt;
           Serial.println(&amp;quot;cmd: 11&amp;quot;);&lt;br /&gt;
          }&lt;br /&gt;
          else if (command == 50) {        // If command = &amp;quot;2&amp;quot; &lt;br /&gt;
           Wire.beginTransmission(X9241_I2C_ADDRESS);&lt;br /&gt;
           Wire.send(0xd6); // Load WCR-01 with Reg-10&lt;br /&gt;
           Wire.endTransmission();&lt;br /&gt;
           Serial.println(&amp;quot;cmd: 12&amp;quot;);&lt;br /&gt;
          }&lt;br /&gt;
          else if (command == 51) {        // If command = &amp;quot;3&amp;quot; &lt;br /&gt;
           Wire.beginTransmission(X9241_I2C_ADDRESS);&lt;br /&gt;
           Wire.send(0xd7); // Load WCR-01 with Reg-11&lt;br /&gt;
           Wire.endTransmission();&lt;br /&gt;
           Serial.println(&amp;quot;cmd: 13&amp;quot;);&lt;br /&gt;
          }&lt;br /&gt;
         }&lt;br /&gt;
        }&lt;br /&gt;
        else if (command == 50) {      //If command = &amp;quot;2&amp;quot; Transfer Register-10 Data to WCR 0-3&lt;br /&gt;
         if (Serial.available()) {&lt;br /&gt;
          command = Serial.read(); &lt;br /&gt;
          if (command == 48) {              // If command = &amp;quot;0&amp;quot; &lt;br /&gt;
           Wire.beginTransmission(X9241_I2C_ADDRESS);&lt;br /&gt;
           Wire.send(0xd8); // Load WCR-10 with Reg-00&lt;br /&gt;
           Wire.endTransmission();&lt;br /&gt;
           Serial.println(&amp;quot;cmd: 20&amp;quot;);&lt;br /&gt;
          }&lt;br /&gt;
         else if (command == 49) {        // If command = &amp;quot;1&amp;quot; &lt;br /&gt;
          Wire.beginTransmission(X9241_I2C_ADDRESS);&lt;br /&gt;
          Wire.send(0xd9); // Load WCR-10 with Reg-01&lt;br /&gt;
          Wire.endTransmission();&lt;br /&gt;
          Serial.println(&amp;quot;cmd: 21&amp;quot;);&lt;br /&gt;
         }&lt;br /&gt;
         else if (command == 50) {        // If command = &amp;quot;2&amp;quot; &lt;br /&gt;
          Wire.beginTransmission(X9241_I2C_ADDRESS);&lt;br /&gt;
          Wire.send(0xda); // Load WCR-10 with Reg-10&lt;br /&gt;
          Wire.endTransmission();&lt;br /&gt;
          Serial.println(&amp;quot;cmd: 22&amp;quot;);&lt;br /&gt;
         }&lt;br /&gt;
         else if (command == 51) {        // If command = &amp;quot;3&amp;quot; &lt;br /&gt;
          Wire.beginTransmission(X9241_I2C_ADDRESS);&lt;br /&gt;
          Wire.send(0xdb); // Load WCR-10 with Reg-11&lt;br /&gt;
          Wire.endTransmission();&lt;br /&gt;
          Serial.println(&amp;quot;cmd: 23&amp;quot;);&lt;br /&gt;
         }&lt;br /&gt;
        }&lt;br /&gt;
       }&lt;br /&gt;
       else if (command == 51) {      //If command = &amp;quot;3&amp;quot; Transfer Register-11 Data to WCR 0-3&lt;br /&gt;
        delay(100);&lt;br /&gt;
        if (Serial.available()) {&lt;br /&gt;
         command = Serial.read(); &lt;br /&gt;
        if (command == 48) {              // If command = &amp;quot;0&amp;quot; &lt;br /&gt;
          Wire.beginTransmission(X9241_I2C_ADDRESS);&lt;br /&gt;
          Wire.send(0xdc); // Load WCR-11 with Reg-00&lt;br /&gt;
          Wire.endTransmission();&lt;br /&gt;
          Serial.println(&amp;quot;cmd: 30&amp;quot;);&lt;br /&gt;
         }&lt;br /&gt;
         else if (command == 49) {        // If command = &amp;quot;1&amp;quot; &lt;br /&gt;
          Wire.beginTransmission(X9241_I2C_ADDRESS);&lt;br /&gt;
          Wire.send(0xdd); // Load WCR-11 with Reg-01&lt;br /&gt;
          Wire.endTransmission();&lt;br /&gt;
          Serial.println(&amp;quot;cmd: 31&amp;quot;);&lt;br /&gt;
         }&lt;br /&gt;
         else if (command == 50) {        // If command = &amp;quot;2&amp;quot; &lt;br /&gt;
          Wire.beginTransmission(X9241_I2C_ADDRESS);&lt;br /&gt;
          Wire.send(0xde); // Load WCR-11 with Reg-10&lt;br /&gt;
          Wire.endTransmission();&lt;br /&gt;
          Serial.println(&amp;quot;cmd: 32&amp;quot;);&lt;br /&gt;
         }&lt;br /&gt;
         else if (command == 51) {        // If command = &amp;quot;3&amp;quot; &lt;br /&gt;
          Wire.beginTransmission(X9241_I2C_ADDRESS);&lt;br /&gt;
          Wire.send(0xdf); // Load WCR-11 with Reg-11&lt;br /&gt;
          Wire.endTransmission();&lt;br /&gt;
          Serial.println(&amp;quot;cmd: 33&amp;quot;);&lt;br /&gt;
         }&lt;br /&gt;
        }&lt;br /&gt;
       }&lt;br /&gt;
       else if (command == 87) {      //If command = &amp;quot;W&amp;quot; write directly to WCR 0-3&lt;br /&gt;
        delay(100);&lt;br /&gt;
        if (Serial.available()) {&lt;br /&gt;
         command = Serial.read(); &lt;br /&gt;
        if (command == 48) {              // If command = &amp;quot;0&amp;quot; &lt;br /&gt;
          Wire.beginTransmission(X9241_I2C_ADDRESS);&lt;br /&gt;
          Wire.send(0xa0); //Instruction to write WCR-00&lt;br /&gt;
          Wire.send(0x10); //Send a D value of 16&lt;br /&gt;
          Wire.endTransmission();&lt;br /&gt;
          Serial.println(&amp;quot;cmd: W0&amp;quot;);&lt;br /&gt;
         }&lt;br /&gt;
         else if (command == 49) {        // If command = &amp;quot;1&amp;quot; &lt;br /&gt;
          Wire.beginTransmission(X9241_I2C_ADDRESS);&lt;br /&gt;
          Wire.send(0xa4); //Instruction to write WCR-01&lt;br /&gt;
          Wire.send(0x20); //Send a D value of 32&lt;br /&gt;
          Wire.endTransmission();&lt;br /&gt;
          Serial.println(&amp;quot;cmd: W1&amp;quot;);&lt;br /&gt;
         }&lt;br /&gt;
         else if (command == 50) {        // If command = &amp;quot;2&amp;quot; &lt;br /&gt;
          Wire.beginTransmission(X9241_I2C_ADDRESS);&lt;br /&gt;
          Wire.send(0xa8); //Instruction to write WCR-10&lt;br /&gt;
          Wire.send(0x2a); //Send a D value of 26&lt;br /&gt;
          Wire.endTransmission();&lt;br /&gt;
          Serial.println(&amp;quot;cmd: W2&amp;quot;);&lt;br /&gt;
         }&lt;br /&gt;
         else if (command == 51) {        // If command = &amp;quot;3&amp;quot; &lt;br /&gt;
          Wire.beginTransmission(X9241_I2C_ADDRESS);&lt;br /&gt;
          Wire.send(0xac); //Instruction to write WCR-11&lt;br /&gt;
          Wire.send(0x30); //Send a D value of 48&lt;br /&gt;
          Wire.endTransmission();&lt;br /&gt;
          Serial.println(&amp;quot;cmd: W3&amp;quot;);&lt;br /&gt;
         }&lt;br /&gt;
        }&lt;br /&gt;
       }&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
//*****************************************************The End***********************&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== A/C_Control_v.01 User Guide ==&lt;br /&gt;
==== Commands ====&lt;br /&gt;
== Troubleshooting ==&lt;br /&gt;
=== Summary ===&lt;br /&gt;
When Troubleshooting a multi-functional issue, it is best practice to break down the issue into pieces and test each piece as a separate system.  However, we will first run through a quick test to see if we can find any obvious issues first.&lt;br /&gt;
=== Quick Test ===&lt;/div&gt;</summary>
		<author><name>Combustor</name></author>	</entry>

	<entry>
		<id>http://combustory.com/wiki/index.php/X9241A_-_Digital_Potentiometer</id>
		<title>X9241A - Digital Potentiometer</title>
		<link rel="alternate" type="text/html" href="http://combustory.com/wiki/index.php/X9241A_-_Digital_Potentiometer"/>
				<updated>2008-09-13T02:04:50Z</updated>
		
		<summary type="html">&lt;p&gt;Combustor: New page: {{default}} == Warning == '''This page is in progress and none of the code can be considered good or complete. I am just using this as an alternate storage of the code for right now.'''  =...&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{default}}&lt;br /&gt;
== Warning ==&lt;br /&gt;
'''This page is in progress and none of the code can be considered good or complete. I am just using this as an alternate storage of the code for right now.'''&lt;br /&gt;
&lt;br /&gt;
== Summary ==&lt;br /&gt;
&lt;br /&gt;
== Example of Method ==&lt;br /&gt;
=== I2C ===&lt;br /&gt;
&lt;br /&gt;
There are basically only two functions that I am after right now which are both three byte instructions: &lt;br /&gt;
&lt;br /&gt;
* Read WCR(Wiper Control Register) for the four potentiometers 0-3 (So far this is failing miserably)&lt;br /&gt;
** Send 1st byte - Address (my circuit - 01011010 or 0x2D)(binary - 0101 A3 A2 A1 A0) A values are actual pins set to high or low for an address.&lt;br /&gt;
** Send 2nd byte - Instruction (binary - 1001 (1/0)(1/0) 00) - The two bits are used to choose the potentiometer&lt;br /&gt;
** Read WCR requested Byte&lt;br /&gt;
* Write WCR for the four potentiometers 0-3 (This works)&lt;br /&gt;
** Send 1st byte - Address (my circuit - 01011010 or 0x2D)(binary - 0101 A3 A2 A1 A0) A values are actual pins set to high or low for an address.&lt;br /&gt;
** Send 2nd byte - Instruction (binary - 1010 (1/0)(1/0) 00) - The two bits are used to choose the potentiometer&lt;br /&gt;
** Send WCR Byte - Potentiometer value (binary - 00 D5 D4 D3 D2 D1 D0) - D values are the 0-63 potentiometer positions&lt;br /&gt;
&lt;br /&gt;
'''Sample Code'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
       Wire.beginTransmission(X9241_I2C_ADDRESS);&lt;br /&gt;
       Wire.send(0xa0); //Instruction to write WCR-00&lt;br /&gt;
       Wire.send(0x20); //Send a D value of 32&lt;br /&gt;
       Wire.endTransmission();&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
==== DS1307 - Real Time Clock ====&lt;br /&gt;
&lt;br /&gt;
The code for this very useful chip came from the [[http://www.glacialwanderer.com/hobbyrobotics/?p=12 Glacial Wanderer]]&lt;br /&gt;
&lt;br /&gt;
==== x9241A_Digital_Potentiometer_v.01 code ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
/*&lt;br /&gt;
 * x9241A Digital Potentiometer v.01&lt;br /&gt;
 * by &amp;lt;http://www.combustory.com&amp;gt; John Vaughters&lt;br /&gt;
 *&lt;br /&gt;
 * This Program illustrates the use of I2C to set up the x9241A Digital Potentiometer by setting and transferring the registers.&lt;br /&gt;
 * I attempted to read the register data through I2C, but was unable to get it to work.&lt;br /&gt;
 * Since the reading part was not so important to me I stopped trying.  &lt;br /&gt;
 * To set the registers up and transfer them to the Wiper registers met my goals and that is where I stopped.&lt;br /&gt;
 *&lt;br /&gt;
 * The x9142A has four Digital Pots and each pot has four static registers and one dynamic register the Wiper Control Register (WCR). &lt;br /&gt;
 * Therefore, there are 16 total bytes of storage and four WCR's.&lt;br /&gt;
 * This Program has the following commands:&lt;br /&gt;
 * S - Set the 16 registers.  Each pot has four registers and this command will set each register group with the same value. So register 00 for each pot will&lt;br /&gt;
 *     be the same value for each pot, and the same for register 01 through 11.&lt;br /&gt;
 * G(0-3) - Global Transfer of Registers to the WCR's.  This command will bulk load the values stored in registers into the WCR's.  &lt;br /&gt;
 *          For example, a G0 will load the 00 register for each pot into the WCR in one command. A G1 loads the 01 register for each pot, etc.&lt;br /&gt;
 * (0-3)(0-3) - This set of commands transfers a single register into a single WCR. The digits are arranged like this (WCR)(Reg). &lt;br /&gt;
 *              For example, a 00 command will load register 00 into WCR 00 or a 13 command will load register 11 into WCR 01, etc.&lt;br /&gt;
 * W(0-3) - This command writes directly to the WCR.  I have created four values that are just random, but the command shows how to write directly to the WCR for each pot.&lt;br /&gt;
 *          For example, a W0 command will write a value of decimal 16.  These commands are just for example purposes.&lt;br /&gt;
 *&lt;br /&gt;
 * Command Note: If you enter a command that is not recognized, then it is ignored and nothing happens and nothing is printed.&lt;br /&gt;
 */&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
#include &amp;quot;Wire.h&amp;quot;&lt;br /&gt;
#define X9241_I2C_ADDRESS 0x2D&lt;br /&gt;
&lt;br /&gt;
// Global Variables&lt;br /&gt;
long command;&lt;br /&gt;
  &lt;br /&gt;
&lt;br /&gt;
void setup() {&lt;br /&gt;
  Wire.begin();&lt;br /&gt;
  Serial.begin(57600);&lt;br /&gt;
  &lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
void loop() {&lt;br /&gt;
   if (Serial.available()) {      // Look for char in serial que and process if found&lt;br /&gt;
      command = Serial.read();&lt;br /&gt;
      if (command == 83) {      //If command = &amp;quot;S&amp;quot; Set Register Data&lt;br /&gt;
      // This sets the four registers of each Digital Pot&lt;br /&gt;
          Wire.beginTransmission(X9241_I2C_ADDRESS);&lt;br /&gt;
          Wire.send(0xc0);  // This is the set register command c and the 16 registers are 0-f&lt;br /&gt;
          Wire.send(0x0a);  // This line is the value to set the register: 0-63 is a valid setting&lt;br /&gt;
          Wire.endTransmission(); &lt;br /&gt;
          delay(100);&lt;br /&gt;
          Wire.beginTransmission(X9241_I2C_ADDRESS);&lt;br /&gt;
          Wire.send(0xc1);&lt;br /&gt;
          Wire.send(0x14);&lt;br /&gt;
          Wire.endTransmission();&lt;br /&gt;
          delay(100);&lt;br /&gt;
          Wire.beginTransmission(X9241_I2C_ADDRESS);&lt;br /&gt;
          Wire.send(0xc2);&lt;br /&gt;
          Wire.send(0x20);&lt;br /&gt;
          Wire.endTransmission();&lt;br /&gt;
          delay(100);&lt;br /&gt;
          Wire.beginTransmission(X9241_I2C_ADDRESS);&lt;br /&gt;
          Wire.send(0xc3);&lt;br /&gt;
          Wire.send(0x3c);&lt;br /&gt;
          Wire.endTransmission();&lt;br /&gt;
          delay(100);&lt;br /&gt;
          Wire.beginTransmission(X9241_I2C_ADDRESS);&lt;br /&gt;
          Wire.send(0xc4);&lt;br /&gt;
          Wire.send(0x0a);&lt;br /&gt;
          Wire.endTransmission(); &lt;br /&gt;
          delay(100);&lt;br /&gt;
          Wire.beginTransmission(X9241_I2C_ADDRESS);&lt;br /&gt;
          Wire.send(0xc5);&lt;br /&gt;
          Wire.send(0x14);&lt;br /&gt;
          Wire.endTransmission();&lt;br /&gt;
          delay(100);&lt;br /&gt;
          Wire.beginTransmission(X9241_I2C_ADDRESS);&lt;br /&gt;
          Wire.send(0xc6);&lt;br /&gt;
          Wire.send(0x20);&lt;br /&gt;
          Wire.endTransmission();&lt;br /&gt;
          delay(100);&lt;br /&gt;
          Wire.beginTransmission(X9241_I2C_ADDRESS);&lt;br /&gt;
          Wire.send(0xc7);&lt;br /&gt;
          Wire.send(0x3c);&lt;br /&gt;
          delay(100);          &lt;br /&gt;
          Wire.beginTransmission(X9241_I2C_ADDRESS);&lt;br /&gt;
          Wire.send(0xc8);&lt;br /&gt;
          Wire.send(0x0a);&lt;br /&gt;
          Wire.endTransmission(); &lt;br /&gt;
          delay(100);&lt;br /&gt;
          Wire.beginTransmission(X9241_I2C_ADDRESS);&lt;br /&gt;
          Wire.send(0xc9);&lt;br /&gt;
          Wire.send(0x14);&lt;br /&gt;
          Wire.endTransmission();&lt;br /&gt;
          delay(100);&lt;br /&gt;
          Wire.beginTransmission(X9241_I2C_ADDRESS);&lt;br /&gt;
          Wire.send(0xca);&lt;br /&gt;
          Wire.send(0x20);&lt;br /&gt;
          Wire.endTransmission();&lt;br /&gt;
          delay(100);&lt;br /&gt;
          Wire.beginTransmission(X9241_I2C_ADDRESS);&lt;br /&gt;
          Wire.send(0xcb);&lt;br /&gt;
          Wire.send(0x3c);&lt;br /&gt;
          Wire.endTransmission();&lt;br /&gt;
          delay(100);&lt;br /&gt;
          Wire.beginTransmission(X9241_I2C_ADDRESS);&lt;br /&gt;
          Wire.send(0xcc);&lt;br /&gt;
          Wire.send(0x0a);&lt;br /&gt;
          Wire.endTransmission(); &lt;br /&gt;
          delay(100);&lt;br /&gt;
          Wire.beginTransmission(X9241_I2C_ADDRESS);&lt;br /&gt;
          Wire.send(0xcd);&lt;br /&gt;
          Wire.send(0x14);&lt;br /&gt;
          Wire.endTransmission();&lt;br /&gt;
          delay(100);&lt;br /&gt;
          Wire.beginTransmission(X9241_I2C_ADDRESS);&lt;br /&gt;
          Wire.send(0xce);&lt;br /&gt;
          Wire.send(0x20);&lt;br /&gt;
          Wire.endTransmission();&lt;br /&gt;
          delay(100);&lt;br /&gt;
          Wire.beginTransmission(X9241_I2C_ADDRESS);&lt;br /&gt;
          Wire.send(0xcf);&lt;br /&gt;
          Wire.send(0x3c);&lt;br /&gt;
          Serial.println(&amp;quot;cmd: S&amp;quot;);&lt;br /&gt;
       }   &lt;br /&gt;
       else if (command == 71) {      //If command = &amp;quot;G&amp;quot; Transfer Global Register Data   &lt;br /&gt;
        delay(100);&lt;br /&gt;
        if (Serial.available()) {&lt;br /&gt;
         command = Serial.read(); &lt;br /&gt;
         if (command == 48) {        // If command = &amp;quot;0&amp;quot; &lt;br /&gt;
          Wire.beginTransmission(X9241_I2C_ADDRESS);&lt;br /&gt;
          Wire.send(0x10); // Global Load WCR's with Reg-00&lt;br /&gt;
          Wire.endTransmission();&lt;br /&gt;
          Serial.println(&amp;quot;cmd: G0&amp;quot;);&lt;br /&gt;
         }&lt;br /&gt;
         else if (command == 49) {        // If command = &amp;quot;1&amp;quot; &lt;br /&gt;
          Wire.beginTransmission(X9241_I2C_ADDRESS);&lt;br /&gt;
          Wire.send(0x11); // Global Load WCR's with Reg-01&lt;br /&gt;
          Wire.endTransmission();&lt;br /&gt;
          Serial.println(&amp;quot;cmd: G1&amp;quot;);&lt;br /&gt;
         }&lt;br /&gt;
         else if (command == 50) {        // If command = &amp;quot;2&amp;quot; &lt;br /&gt;
          Wire.beginTransmission(X9241_I2C_ADDRESS);&lt;br /&gt;
          Wire.send(0x12); // Global Load WCR's with Reg-10&lt;br /&gt;
          Wire.endTransmission();&lt;br /&gt;
          Serial.println(&amp;quot;cmd: G2&amp;quot;);&lt;br /&gt;
         }&lt;br /&gt;
         else if (command == 51) {        // If command = &amp;quot;3&amp;quot; &lt;br /&gt;
          Wire.beginTransmission(X9241_I2C_ADDRESS);&lt;br /&gt;
          Wire.send(0x13); // Global Load WCR's with Reg-11&lt;br /&gt;
          Wire.endTransmission();&lt;br /&gt;
          Serial.println(&amp;quot;cmd: G3&amp;quot;);&lt;br /&gt;
         }&lt;br /&gt;
        }&lt;br /&gt;
       }&lt;br /&gt;
       &lt;br /&gt;
       else if (command == 48) {      //If command = &amp;quot;0&amp;quot; Transfer Register-00 Data to WCR 0-3&lt;br /&gt;
         delay(100);&lt;br /&gt;
         if (Serial.available()) {&lt;br /&gt;
         command = Serial.read(); &lt;br /&gt;
         if (command == 48) {              // If command = &amp;quot;0&amp;quot; &lt;br /&gt;
          Wire.beginTransmission(X9241_I2C_ADDRESS);&lt;br /&gt;
          Wire.send(0xd0); // Load WCR-00 with Reg-00&lt;br /&gt;
          Wire.endTransmission();&lt;br /&gt;
          Serial.println(&amp;quot;cmd: 00&amp;quot;);&lt;br /&gt;
         }&lt;br /&gt;
         else if (command == 49) {        // If command = &amp;quot;1&amp;quot; &lt;br /&gt;
          Wire.beginTransmission(X9241_I2C_ADDRESS);&lt;br /&gt;
          Wire.send(0xd1); // Load WCR-00 with Reg-01&lt;br /&gt;
          Wire.endTransmission();&lt;br /&gt;
          Serial.println(&amp;quot;cmd: 01&amp;quot;);&lt;br /&gt;
         }&lt;br /&gt;
         else if (command == 50) {        // If command = &amp;quot;2&amp;quot; &lt;br /&gt;
          Wire.beginTransmission(X9241_I2C_ADDRESS);&lt;br /&gt;
          Wire.send(0xd2); // Load WCR-00 with Reg-10&lt;br /&gt;
          Wire.endTransmission();&lt;br /&gt;
          Serial.println(&amp;quot;cmd: 02&amp;quot;);&lt;br /&gt;
         }&lt;br /&gt;
         else if (command == 51) {        // If command = &amp;quot;3&amp;quot; &lt;br /&gt;
          Wire.beginTransmission(X9241_I2C_ADDRESS);&lt;br /&gt;
          Wire.send(0xd3); // Load WCR-00 with Reg-11&lt;br /&gt;
          Wire.endTransmission();&lt;br /&gt;
          Serial.println(&amp;quot;cmd: 03&amp;quot;);&lt;br /&gt;
         }&lt;br /&gt;
        }&lt;br /&gt;
       }&lt;br /&gt;
        else if (command == 49) {      //If command = &amp;quot;1&amp;quot; Transfer Register-01 Data to WCR 0-3&lt;br /&gt;
         delay(100);&lt;br /&gt;
         if (Serial.available()) {&lt;br /&gt;
         command = Serial.read(); &lt;br /&gt;
          if (command == 48) {              // If command = &amp;quot;0&amp;quot; &lt;br /&gt;
           Wire.beginTransmission(X9241_I2C_ADDRESS);&lt;br /&gt;
           Wire.send(0xd4); // Load WCR-01 with Reg-00&lt;br /&gt;
           Wire.endTransmission();&lt;br /&gt;
           Serial.println(&amp;quot;cmd: 10&amp;quot;);&lt;br /&gt;
          }&lt;br /&gt;
          else if (command == 49) {        // If command = &amp;quot;1&amp;quot; &lt;br /&gt;
           Wire.beginTransmission(X9241_I2C_ADDRESS);&lt;br /&gt;
           Wire.send(0xd5); // Load WCR-01 with Reg-01&lt;br /&gt;
           Wire.endTransmission();&lt;br /&gt;
           Serial.println(&amp;quot;cmd: 11&amp;quot;);&lt;br /&gt;
          }&lt;br /&gt;
          else if (command == 50) {        // If command = &amp;quot;2&amp;quot; &lt;br /&gt;
           Wire.beginTransmission(X9241_I2C_ADDRESS);&lt;br /&gt;
           Wire.send(0xd6); // Load WCR-01 with Reg-10&lt;br /&gt;
           Wire.endTransmission();&lt;br /&gt;
           Serial.println(&amp;quot;cmd: 12&amp;quot;);&lt;br /&gt;
          }&lt;br /&gt;
          else if (command == 51) {        // If command = &amp;quot;3&amp;quot; &lt;br /&gt;
           Wire.beginTransmission(X9241_I2C_ADDRESS);&lt;br /&gt;
           Wire.send(0xd7); // Load WCR-01 with Reg-11&lt;br /&gt;
           Wire.endTransmission();&lt;br /&gt;
           Serial.println(&amp;quot;cmd: 13&amp;quot;);&lt;br /&gt;
          }&lt;br /&gt;
         }&lt;br /&gt;
        }&lt;br /&gt;
        else if (command == 50) {      //If command = &amp;quot;2&amp;quot; Transfer Register-10 Data to WCR 0-3&lt;br /&gt;
         if (Serial.available()) {&lt;br /&gt;
          command = Serial.read(); &lt;br /&gt;
          if (command == 48) {              // If command = &amp;quot;0&amp;quot; &lt;br /&gt;
           Wire.beginTransmission(X9241_I2C_ADDRESS);&lt;br /&gt;
           Wire.send(0xd8); // Load WCR-10 with Reg-00&lt;br /&gt;
           Wire.endTransmission();&lt;br /&gt;
           Serial.println(&amp;quot;cmd: 20&amp;quot;);&lt;br /&gt;
          }&lt;br /&gt;
         else if (command == 49) {        // If command = &amp;quot;1&amp;quot; &lt;br /&gt;
          Wire.beginTransmission(X9241_I2C_ADDRESS);&lt;br /&gt;
          Wire.send(0xd9); // Load WCR-10 with Reg-01&lt;br /&gt;
          Wire.endTransmission();&lt;br /&gt;
          Serial.println(&amp;quot;cmd: 21&amp;quot;);&lt;br /&gt;
         }&lt;br /&gt;
         else if (command == 50) {        // If command = &amp;quot;2&amp;quot; &lt;br /&gt;
          Wire.beginTransmission(X9241_I2C_ADDRESS);&lt;br /&gt;
          Wire.send(0xda); // Load WCR-10 with Reg-10&lt;br /&gt;
          Wire.endTransmission();&lt;br /&gt;
          Serial.println(&amp;quot;cmd: 22&amp;quot;);&lt;br /&gt;
         }&lt;br /&gt;
         else if (command == 51) {        // If command = &amp;quot;3&amp;quot; &lt;br /&gt;
          Wire.beginTransmission(X9241_I2C_ADDRESS);&lt;br /&gt;
          Wire.send(0xdb); // Load WCR-10 with Reg-11&lt;br /&gt;
          Wire.endTransmission();&lt;br /&gt;
          Serial.println(&amp;quot;cmd: 23&amp;quot;);&lt;br /&gt;
         }&lt;br /&gt;
        }&lt;br /&gt;
       }&lt;br /&gt;
       else if (command == 51) {      //If command = &amp;quot;3&amp;quot; Transfer Register-11 Data to WCR 0-3&lt;br /&gt;
        delay(100);&lt;br /&gt;
        if (Serial.available()) {&lt;br /&gt;
         command = Serial.read(); &lt;br /&gt;
        if (command == 48) {              // If command = &amp;quot;0&amp;quot; &lt;br /&gt;
          Wire.beginTransmission(X9241_I2C_ADDRESS);&lt;br /&gt;
          Wire.send(0xdc); // Load WCR-11 with Reg-00&lt;br /&gt;
          Wire.endTransmission();&lt;br /&gt;
          Serial.println(&amp;quot;cmd: 30&amp;quot;);&lt;br /&gt;
         }&lt;br /&gt;
         else if (command == 49) {        // If command = &amp;quot;1&amp;quot; &lt;br /&gt;
          Wire.beginTransmission(X9241_I2C_ADDRESS);&lt;br /&gt;
          Wire.send(0xdd); // Load WCR-11 with Reg-01&lt;br /&gt;
          Wire.endTransmission();&lt;br /&gt;
          Serial.println(&amp;quot;cmd: 31&amp;quot;);&lt;br /&gt;
         }&lt;br /&gt;
         else if (command == 50) {        // If command = &amp;quot;2&amp;quot; &lt;br /&gt;
          Wire.beginTransmission(X9241_I2C_ADDRESS);&lt;br /&gt;
          Wire.send(0xde); // Load WCR-11 with Reg-10&lt;br /&gt;
          Wire.endTransmission();&lt;br /&gt;
          Serial.println(&amp;quot;cmd: 32&amp;quot;);&lt;br /&gt;
         }&lt;br /&gt;
         else if (command == 51) {        // If command = &amp;quot;3&amp;quot; &lt;br /&gt;
          Wire.beginTransmission(X9241_I2C_ADDRESS);&lt;br /&gt;
          Wire.send(0xdf); // Load WCR-11 with Reg-11&lt;br /&gt;
          Wire.endTransmission();&lt;br /&gt;
          Serial.println(&amp;quot;cmd: 33&amp;quot;);&lt;br /&gt;
         }&lt;br /&gt;
        }&lt;br /&gt;
       }&lt;br /&gt;
       else if (command == 87) {      //If command = &amp;quot;W&amp;quot; write directly to WCR 0-3&lt;br /&gt;
        delay(100);&lt;br /&gt;
        if (Serial.available()) {&lt;br /&gt;
         command = Serial.read(); &lt;br /&gt;
        if (command == 48) {              // If command = &amp;quot;0&amp;quot; &lt;br /&gt;
          Wire.beginTransmission(X9241_I2C_ADDRESS);&lt;br /&gt;
          Wire.send(0xa0); //Instruction to write WCR-00&lt;br /&gt;
          Wire.send(0x10); //Send a D value of 16&lt;br /&gt;
          Wire.endTransmission();&lt;br /&gt;
          Serial.println(&amp;quot;cmd: W0&amp;quot;);&lt;br /&gt;
         }&lt;br /&gt;
         else if (command == 49) {        // If command = &amp;quot;1&amp;quot; &lt;br /&gt;
          Wire.beginTransmission(X9241_I2C_ADDRESS);&lt;br /&gt;
          Wire.send(0xa4); //Instruction to write WCR-01&lt;br /&gt;
          Wire.send(0x20); //Send a D value of 32&lt;br /&gt;
          Wire.endTransmission();&lt;br /&gt;
          Serial.println(&amp;quot;cmd: W1&amp;quot;);&lt;br /&gt;
         }&lt;br /&gt;
         else if (command == 50) {        // If command = &amp;quot;2&amp;quot; &lt;br /&gt;
          Wire.beginTransmission(X9241_I2C_ADDRESS);&lt;br /&gt;
          Wire.send(0xa8); //Instruction to write WCR-10&lt;br /&gt;
          Wire.send(0x2a); //Send a D value of 26&lt;br /&gt;
          Wire.endTransmission();&lt;br /&gt;
          Serial.println(&amp;quot;cmd: W2&amp;quot;);&lt;br /&gt;
         }&lt;br /&gt;
         else if (command == 51) {        // If command = &amp;quot;3&amp;quot; &lt;br /&gt;
          Wire.beginTransmission(X9241_I2C_ADDRESS);&lt;br /&gt;
          Wire.send(0xac); //Instruction to write WCR-11&lt;br /&gt;
          Wire.send(0x30); //Send a D value of 48&lt;br /&gt;
          Wire.endTransmission();&lt;br /&gt;
          Serial.println(&amp;quot;cmd: W3&amp;quot;);&lt;br /&gt;
         }&lt;br /&gt;
        }&lt;br /&gt;
       }&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
//*****************************************************The End***********************&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== A/C_Control_v.01 User Guide ==&lt;br /&gt;
==== Commands ====&lt;br /&gt;
== Troubleshooting ==&lt;br /&gt;
=== Summary ===&lt;br /&gt;
When Troubleshooting a multi-functional issue, it is best practice to break down the issue into pieces and test each piece as a separate system.  However, we will first run through a quick test to see if we can find any obvious issues first.&lt;br /&gt;
=== Quick Test ===&lt;/div&gt;</summary>
		<author><name>Combustor</name></author>	</entry>

	<entry>
		<id>http://combustory.com/wiki/index.php/Temperature_Controller</id>
		<title>Temperature Controller</title>
		<link rel="alternate" type="text/html" href="http://combustory.com/wiki/index.php/Temperature_Controller"/>
				<updated>2008-09-13T01:59:30Z</updated>
		
		<summary type="html">&lt;p&gt;Combustor: /* Example of Method */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{default}}&lt;br /&gt;
== Warning ==&lt;br /&gt;
'''This page is in progress and none of the code can be considered good or complete. I am just using this as an alternate storage of the code for right now.'''&lt;br /&gt;
&lt;br /&gt;
== Summary ==&lt;br /&gt;
== Functional Description of the Method ==&lt;br /&gt;
== Requirements ==&lt;br /&gt;
== Example of Method ==&lt;br /&gt;
=== Quick Guide: ===&lt;br /&gt;
=== Detailed Guide: ===&lt;br /&gt;
=== I2C ===&lt;br /&gt;
==== X9241A - Digital Potentiometer ====&lt;br /&gt;
&lt;br /&gt;
Detail on this page [[X9241A - Digital Potentiometer]]&lt;br /&gt;
&lt;br /&gt;
There are basically only two functions that I am after right now which are both three byte instructions: &lt;br /&gt;
&lt;br /&gt;
* Read WCR(Wiper Control Register) for the four potentiometers 0-3 (So far this is failing miserably)&lt;br /&gt;
** Send 1st byte - Address (my circuit - 01011010 or 0x2D)(binary - 0101 A3 A2 A1 A0) A values are actual pins set to high or low for an address.&lt;br /&gt;
** Send 2nd byte - Instruction (binary - 1001 (1/0)(1/0) 00) - The two bits are used to choose the potentiometer&lt;br /&gt;
** Read WCR requested Byte&lt;br /&gt;
* Write WCR for the four potentiometers 0-3 (This works)&lt;br /&gt;
** Send 1st byte - Address (my circuit - 01011010 or 0x2D)(binary - 0101 A3 A2 A1 A0) A values are actual pins set to high or low for an address.&lt;br /&gt;
** Send 2nd byte - Instruction (binary - 1010 (1/0)(1/0) 00) - The two bits are used to choose the potentiometer&lt;br /&gt;
** Send WCR Byte - Potentiometer value (binary - 00 D5 D4 D3 D2 D1 D0) - D values are the 0-63 potentiometer positions&lt;br /&gt;
&lt;br /&gt;
'''Sample Code'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
       Wire.beginTransmission(X9241_I2C_ADDRESS);&lt;br /&gt;
       Wire.send(0xa0); //Instruction to write WCR-00&lt;br /&gt;
       Wire.send(0x20); //Send a D value of 32&lt;br /&gt;
       Wire.endTransmission();&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
==== DS1307 - Real Time Clock ====&lt;br /&gt;
&lt;br /&gt;
The code for this very useful chip came from the [[http://www.glacialwanderer.com/hobbyrobotics/?p=12 Glacial Wanderer]]&lt;br /&gt;
&lt;br /&gt;
==== A/C_Control_v.01 code ====&lt;br /&gt;
&lt;br /&gt;
''' While this says v.01, don't count on it being a released v.01, I am still working on v.01, this is a back up '''&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
/*&lt;br /&gt;
 * A/C Control v.01&lt;br /&gt;
 * by &amp;lt;http://www.combustory.com&amp;gt; John Vaughters&lt;br /&gt;
 * Credit to:&lt;br /&gt;
 * Maurice Ribble - http://www.glacialwanderer.com/hobbyrobotics for RTC DS1307 code&lt;br /&gt;
 *&lt;br /&gt;
 * Turns on an LED for temperatures from analog pins 1-5 on&lt;br /&gt;
 * digital pins 2-6 when the temperature rises above the THRESHOLDS 1-5.&lt;br /&gt;
 * The program also implements a &lt;br /&gt;
 * Serial Communication method that utilizes a leading CHAR for each command Described below. &lt;br /&gt;
 * Commands:&lt;br /&gt;
 * T(1-4) - Temp1-5 Status ex. T1, T2, etc&lt;br /&gt;
 * C(1-4)(0-9) - Increment THRESHOLD1-4 by (1-9) ex. C15 increments THRESHOLD1 BY 5 (Note: C40 will give you a status of THRESHOLD4)&lt;br /&gt;
 * D(1-4)(0-9) - Decrement THRESHOLD1-4 by (1-9) ex. D59 decrements THRESHOLD5 BY 9 (Note: D10 will give you a status of THRESHOLD1)&lt;br /&gt;
 * A(0-1) - Manual AC on command A1 is AC on, A0 is AC off&lt;br /&gt;
 * F(0-1) - Manual AC on command A1 is FAN on, A0 is FAN off &lt;br /&gt;
 * Q - Q Sets the date of the RTC DS1307 Chip&lt;br /&gt;
 */&lt;br /&gt;
&lt;br /&gt;
#include &amp;quot;Wire.h&amp;quot;&lt;br /&gt;
#define DS1307_I2C_ADDRESS 0x68&lt;br /&gt;
&lt;br /&gt;
// Global Variables&lt;br /&gt;
int val_cnt = 0;               // counter for the temp_val                   &lt;br /&gt;
int temp1Pin = 0;    // select the input pin for the Thermistor&lt;br /&gt;
int temp2Pin = 1;    // select the input pin for the Thermistor&lt;br /&gt;
int temp3Pin = 2;    // select the input pin for the Thermistor&lt;br /&gt;
int temp4Pin = 3;    // select the input pin for the Thermistor&lt;br /&gt;
int temp1_val[5] = {0,0,0,0,0};       // variable to store the value coming from the sensor&lt;br /&gt;
int temp2_val[5] = {0,0,0,0,0};       //           &lt;br /&gt;
int temp3_val[5] = {0,0,0,0,0};       //&lt;br /&gt;
int temp4_val[5] = {0,0,0,0,0};       //&lt;br /&gt;
int temp1_avg;                   // average over poll time of the temp values&lt;br /&gt;
int temp2_avg;&lt;br /&gt;
int temp3_avg;&lt;br /&gt;
int temp4_avg;&lt;br /&gt;
int duct1 = 2;                   // Ducts open or close using a digital output&lt;br /&gt;
int duct2 = 3;&lt;br /&gt;
int duct3 = 4;&lt;br /&gt;
int duct4 = 5;&lt;br /&gt;
int THRESHOLD1 = 580;    // Default theshold values&lt;br /&gt;
int THRESHOLD2 = 580;&lt;br /&gt;
int THRESHOLD3 = 580;&lt;br /&gt;
int THRESHOLD4 = 580;&lt;br /&gt;
int ac_on = 13;&lt;br /&gt;
int fan_on = 12;&lt;br /&gt;
int command = 0;       // This is the command char, in ascii form, sent from the serial port     &lt;br /&gt;
long polltime = 1000;  // The time to Poll the tempPins&lt;br /&gt;
long previousMillis = 0;        // will store last time Temp was updated&lt;br /&gt;
long ac_on_start = 0;     // Start A/C delay timer&lt;br /&gt;
long ac_on_delay = 10000;   // Time to wait before checking the ducts again&lt;br /&gt;
byte second, minute, hour, dayOfWeek, dayOfMonth, month, year;&lt;br /&gt;
&lt;br /&gt;
  &lt;br /&gt;
// Convert normal decimal numbers to binary coded decimal&lt;br /&gt;
byte decToBcd(byte val)&lt;br /&gt;
{&lt;br /&gt;
  return ( (val/10*16) + (val%10) );&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
// Convert binary coded decimal to normal decimal numbers&lt;br /&gt;
byte bcdToDec(byte val)&lt;br /&gt;
{&lt;br /&gt;
  return ( (val/16*10) + (val%16) );&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
// 1) Sets the date and time on the ds1307&lt;br /&gt;
// 2) Starts the clock&lt;br /&gt;
// 3) Sets hour mode to 24 hour clock&lt;br /&gt;
// Assumes you're passing in valid numbers&lt;br /&gt;
// Watch for scope issues with Global Variables&lt;br /&gt;
/*void setDateDs1307(byte second,        // 0-59&lt;br /&gt;
                   byte minute,        // 0-59&lt;br /&gt;
                   byte hour,          // 1-23&lt;br /&gt;
                   byte dayOfWeek,     // 1-7&lt;br /&gt;
                   byte dayOfMonth,    // 1-28/29/30/31&lt;br /&gt;
                   byte month,         // 1-12&lt;br /&gt;
                   byte year)          // 0-99*/&lt;br /&gt;
void setDateDs1307()                &lt;br /&gt;
{&lt;br /&gt;
   Wire.beginTransmission(DS1307_I2C_ADDRESS);&lt;br /&gt;
   Wire.send(0);&lt;br /&gt;
   Wire.send(decToBcd(second));    // 0 to bit 7 starts the clock&lt;br /&gt;
   Wire.send(decToBcd(minute));&lt;br /&gt;
   Wire.send(decToBcd(hour));      // If you want 12 hour am/pm you need to set&lt;br /&gt;
                                   // bit 6 (also need to change readDateDs1307)&lt;br /&gt;
   Wire.send(decToBcd(dayOfWeek));&lt;br /&gt;
   Wire.send(decToBcd(dayOfMonth));&lt;br /&gt;
   Wire.send(decToBcd(month));&lt;br /&gt;
   Wire.send(decToBcd(year));&lt;br /&gt;
   Wire.endTransmission();&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
// Gets the date and time from the ds1307 and prints result&lt;br /&gt;
// Watch for scope issues with Global Variables&lt;br /&gt;
void getDateDs1307()&lt;br /&gt;
{&lt;br /&gt;
  // Reset the register pointer&lt;br /&gt;
  Wire.beginTransmission(DS1307_I2C_ADDRESS);&lt;br /&gt;
  Wire.send(0);&lt;br /&gt;
  Wire.endTransmission();&lt;br /&gt;
&lt;br /&gt;
  Wire.requestFrom(DS1307_I2C_ADDRESS, 7);&lt;br /&gt;
&lt;br /&gt;
  // A few of these need masks because certain bits are control bits&lt;br /&gt;
  second     = bcdToDec(Wire.receive() &amp;amp; 0x7f);&lt;br /&gt;
  minute     = bcdToDec(Wire.receive());&lt;br /&gt;
  hour       = bcdToDec(Wire.receive() &amp;amp; 0x3f);  // Need to change this if 12 hour am/pm&lt;br /&gt;
  dayOfWeek  = bcdToDec(Wire.receive());&lt;br /&gt;
  dayOfMonth = bcdToDec(Wire.receive());&lt;br /&gt;
  month      = bcdToDec(Wire.receive());&lt;br /&gt;
  year       = bcdToDec(Wire.receive());&lt;br /&gt;
  &lt;br /&gt;
  Serial.print(hour, DEC);&lt;br /&gt;
  Serial.print(&amp;quot;:&amp;quot;);&lt;br /&gt;
  Serial.print(minute, DEC);&lt;br /&gt;
  Serial.print(&amp;quot;:&amp;quot;);&lt;br /&gt;
  Serial.print(second, DEC);&lt;br /&gt;
  Serial.print(&amp;quot;  &amp;quot;);&lt;br /&gt;
  Serial.print(month, DEC);&lt;br /&gt;
  Serial.print(&amp;quot;/&amp;quot;);&lt;br /&gt;
  Serial.print(dayOfMonth, DEC);&lt;br /&gt;
  Serial.print(&amp;quot;/&amp;quot;);&lt;br /&gt;
  Serial.print(year, DEC);&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
void setup() {&lt;br /&gt;
  Wire.begin();&lt;br /&gt;
  Serial.begin(57600);&lt;br /&gt;
  pinMode(duct1, OUTPUT);&lt;br /&gt;
  pinMode(duct2, OUTPUT);&lt;br /&gt;
  pinMode(duct3, OUTPUT);&lt;br /&gt;
  pinMode(duct4, OUTPUT);&lt;br /&gt;
  pinMode(ac_on, OUTPUT);&lt;br /&gt;
  pinMode(fan_on, OUTPUT);&lt;br /&gt;
  // Initialize Date/Time to update RTC DS1307 - You need to run the Q command right after you download this program&lt;br /&gt;
  // This is temporary until a more complex date time command is finished&lt;br /&gt;
  second = 15;&lt;br /&gt;
  minute = 41;&lt;br /&gt;
  hour = 12;&lt;br /&gt;
  dayOfWeek = 5;&lt;br /&gt;
  dayOfMonth = 5;&lt;br /&gt;
  month = 9;&lt;br /&gt;
  year = 8;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
void loop() {&lt;br /&gt;
  if (millis() - previousMillis &amp;gt; polltime) {&lt;br /&gt;
    previousMillis = millis();   // remember the last time&lt;br /&gt;
    if (millis() - ac_on_start &amp;gt; ac_on_delay) { &lt;br /&gt;
      if (digitalRead(duct1) || digitalRead(duct2) || digitalRead(duct3) || digitalRead(duct4)){  // If any ducts are turned on turn on the A/C&lt;br /&gt;
       if (digitalRead(ac_on) != HIGH) { // Check ac_on state&lt;br /&gt;
        digitalWrite(ac_on,HIGH);&lt;br /&gt;
        getDateDs1307();&lt;br /&gt;
        Serial.println(&amp;quot; - AC ON&amp;quot;);&lt;br /&gt;
       }&lt;br /&gt;
       ac_on_start = millis();&lt;br /&gt;
      } &lt;br /&gt;
      else if (digitalRead(ac_on) != LOW){ //Check ac_on state&lt;br /&gt;
       digitalWrite(ac_on,LOW);&lt;br /&gt;
       getDateDs1307();&lt;br /&gt;
       Serial.println(&amp;quot; - AC OFF&amp;quot;);&lt;br /&gt;
      }&lt;br /&gt;
    }&lt;br /&gt;
    temp1_val[val_cnt] = analogRead(temp1Pin);    // read the value from the sensors&lt;br /&gt;
    temp2_val[val_cnt] = analogRead(temp2Pin);&lt;br /&gt;
    temp3_val[val_cnt] = analogRead(temp3Pin);&lt;br /&gt;
    temp4_val[val_cnt] = analogRead(temp4Pin);&lt;br /&gt;
    val_cnt ++;&lt;br /&gt;
    if (val_cnt == 5) {&lt;br /&gt;
      val_cnt = 0;&lt;br /&gt;
    }&lt;br /&gt;
    temp1_avg = (temp1_val[0] + temp1_val[1] + temp1_val[2] + temp1_val[3] + temp1_val[4])/5;&lt;br /&gt;
    temp2_avg = (temp2_val[0] + temp2_val[1] + temp2_val[2] + temp2_val[3] + temp2_val[4])/5;&lt;br /&gt;
    temp3_avg = (temp3_val[0] + temp3_val[1] + temp3_val[2] + temp3_val[3] + temp3_val[4])/5;&lt;br /&gt;
    temp4_avg = (temp4_val[0] + temp4_val[1] + temp4_val[2] + temp4_val[3] + temp4_val[4])/5;&lt;br /&gt;
// Check Thresholds against the Temperatures and set the ducts HIGH or LOW    &lt;br /&gt;
    if (temp1_avg &amp;gt;= THRESHOLD1) {digitalWrite(duct1, HIGH);}&lt;br /&gt;
    else {digitalWrite(duct1, LOW);}&lt;br /&gt;
    if (temp2_avg &amp;gt;= THRESHOLD2) {digitalWrite(duct2, HIGH);}&lt;br /&gt;
    else {digitalWrite(duct2, LOW);}&lt;br /&gt;
    if (temp3_avg &amp;gt;= THRESHOLD3) {digitalWrite(duct3, HIGH);}&lt;br /&gt;
    else {digitalWrite(duct3, LOW);}&lt;br /&gt;
    if (temp4_avg &amp;gt;= THRESHOLD4) {digitalWrite(duct4, HIGH);}&lt;br /&gt;
    else {digitalWrite(duct4, LOW);}&lt;br /&gt;
    if (Serial.available()) {      // Look for char in serial que and process if found&lt;br /&gt;
      command = Serial.read();&lt;br /&gt;
      if (command == 84) {          // If command = &amp;quot;T&amp;quot; &lt;br /&gt;
        command = Serial.read();&lt;br /&gt;
        if (command == 49) {          // If command = &amp;quot;1&amp;quot; print the Temp1&lt;br /&gt;
         Serial.print(&amp;quot;Temp1 = &amp;quot;);&lt;br /&gt;
         Serial.print(temp1_avg);           // &lt;br /&gt;
         Serial.print(&amp;quot; &amp;quot;);&lt;br /&gt;
        }&lt;br /&gt;
        else if (command == 50) {      // If command = &amp;quot;2&amp;quot; print the Temp2&lt;br /&gt;
         Serial.print(&amp;quot;Temp2 = &amp;quot;);&lt;br /&gt;
         Serial.print(temp2_avg);           // &lt;br /&gt;
         Serial.print(&amp;quot; &amp;quot;);&lt;br /&gt;
        }&lt;br /&gt;
        else if (command == 51) {      // If command = &amp;quot;3&amp;quot; print the Temp3&lt;br /&gt;
         Serial.print(&amp;quot;Temp3 = &amp;quot;);&lt;br /&gt;
         Serial.print(temp3_avg);           // &lt;br /&gt;
         Serial.print(&amp;quot; &amp;quot;);&lt;br /&gt;
        }&lt;br /&gt;
        else if (command == 52) {      // If command = &amp;quot;4&amp;quot; print the Temp4&lt;br /&gt;
         Serial.print(&amp;quot;Temp4 = &amp;quot;);&lt;br /&gt;
         Serial.print(temp4_avg);           // &lt;br /&gt;
         Serial.print(&amp;quot; &amp;quot;);&lt;br /&gt;
         }&lt;br /&gt;
       }&lt;br /&gt;
      else if (command == 67) {      //If command = &amp;quot;C&amp;quot; Change Temp Threshhold&lt;br /&gt;
        if (Serial.available()) {&lt;br /&gt;
         command = Serial.read();&lt;br /&gt;
         if (command == 49) {        // If command = &amp;quot;1&amp;quot; print the THRESHOLD1&lt;br /&gt;
           command = Serial.read();&lt;br /&gt;
           if (command &amp;gt; 47 &amp;amp;&amp;amp; command &amp;lt; 58) {          // If command is between 0-9 Increment the Threshold by number sent&lt;br /&gt;
             THRESHOLD1 += command - 48;                 // ASCII math to get value sent   &lt;br /&gt;
                  Serial.print(&amp;quot;THRESHOLD1 = &amp;quot;);&lt;br /&gt;
                  Serial.print(THRESHOLD1);           // &lt;br /&gt;
                  Serial.print(&amp;quot; &amp;quot;);&lt;br /&gt;
           }&lt;br /&gt;
         }  &lt;br /&gt;
         else if (command == 50) {     // If command = &amp;quot;2&amp;quot; print the THRESHOLD2&lt;br /&gt;
           command = Serial.read();&lt;br /&gt;
           if (command &amp;gt; 47 &amp;amp;&amp;amp; command &amp;lt; 58) {          // If command is between 0-9 Increment the Threshold by number sent&lt;br /&gt;
             THRESHOLD2 += command - 48;                 // ASCII math to get value sent   &lt;br /&gt;
                  Serial.print(&amp;quot;THRESHOLD2 = &amp;quot;);&lt;br /&gt;
                  Serial.print(THRESHOLD2);           // &lt;br /&gt;
                  Serial.print(&amp;quot; &amp;quot;);&lt;br /&gt;
           }&lt;br /&gt;
         }&lt;br /&gt;
         else if (command == 51) {             // If command = &amp;quot;3&amp;quot; print the THRESHOLD3&lt;br /&gt;
           command = Serial.read();&lt;br /&gt;
           if (command &amp;gt; 47 &amp;amp;&amp;amp; command &amp;lt; 58) {          // If command is between 0-9 Increment the Threshold by number sent&lt;br /&gt;
             THRESHOLD3 += command - 48;                 // ASCII math to get value sent   &lt;br /&gt;
                  Serial.print(&amp;quot;THRESHOLD3 = &amp;quot;);&lt;br /&gt;
                  Serial.print(THRESHOLD3);           // &lt;br /&gt;
                  Serial.print(&amp;quot; &amp;quot;);&lt;br /&gt;
           }&lt;br /&gt;
         }&lt;br /&gt;
         else if (command == 52) {             // If command = &amp;quot;4&amp;quot; print the THRESHOLD4&lt;br /&gt;
           command = Serial.read();&lt;br /&gt;
           if (command &amp;gt; 47 &amp;amp;&amp;amp; command &amp;lt; 58) {          // If command is between 0-9 Increment the Threshold by number sent&lt;br /&gt;
             THRESHOLD4 += command - 48;                 // ASCII math to get value sent   &lt;br /&gt;
                  Serial.print(&amp;quot;THRESHOLD4 = &amp;quot;);&lt;br /&gt;
                  Serial.print(THRESHOLD4);           // &lt;br /&gt;
                  Serial.print(&amp;quot; &amp;quot;);&lt;br /&gt;
           }&lt;br /&gt;
         }          &lt;br /&gt;
        }  &lt;br /&gt;
      }&lt;br /&gt;
      else if (command == 68) {      //If command = &amp;quot;D&amp;quot; Change Temp Threshhold&lt;br /&gt;
        if (Serial.available()) {&lt;br /&gt;
         command = Serial.read();&lt;br /&gt;
         if (command == 49) {           // If command = &amp;quot;1&amp;quot; print the THRESHOLD1&lt;br /&gt;
           command = Serial.read();&lt;br /&gt;
           if (command &amp;gt; 47 &amp;amp;&amp;amp; command &amp;lt; 58) {          // If command is between 0-9 Decrement the Threshold by number sent&lt;br /&gt;
             THRESHOLD1 -= command - 48;                 // ASCII math to get value sent   &lt;br /&gt;
                  Serial.print(&amp;quot;THRESHOLD1 = &amp;quot;);&lt;br /&gt;
                  Serial.print(THRESHOLD1);           // &lt;br /&gt;
                  Serial.print(&amp;quot; &amp;quot;);&lt;br /&gt;
           }&lt;br /&gt;
         }  &lt;br /&gt;
         else if (command == 50) {               // If command = &amp;quot;2&amp;quot; print the THRESHOLD2&lt;br /&gt;
           command = Serial.read();&lt;br /&gt;
           if (command &amp;gt; 47 &amp;amp;&amp;amp; command &amp;lt; 58) {          // If command is between 0-9 Decrement the Threshold by number sent&lt;br /&gt;
             THRESHOLD2 -= command - 48;                 // ASCII math to get value sent   &lt;br /&gt;
                  Serial.print(&amp;quot;THRESHOLD2 = &amp;quot;);&lt;br /&gt;
                  Serial.print(THRESHOLD2);           // &lt;br /&gt;
                  Serial.print(&amp;quot; &amp;quot;);&lt;br /&gt;
           }&lt;br /&gt;
         }&lt;br /&gt;
         else if (command == 51) {              // If command = &amp;quot;3&amp;quot; print the THRESHOLD3&lt;br /&gt;
           command = Serial.read();&lt;br /&gt;
           if (command &amp;gt; 47 &amp;amp;&amp;amp; command &amp;lt; 58) {          // If command is between 0-9 Decrement the Threshold by number sent&lt;br /&gt;
             THRESHOLD3 -= command - 48;                 // ASCII math to get value sent   &lt;br /&gt;
                  Serial.print(&amp;quot;THRESHOLD3 = &amp;quot;);&lt;br /&gt;
                  Serial.print(THRESHOLD3);           // &lt;br /&gt;
                  Serial.print(&amp;quot; &amp;quot;);&lt;br /&gt;
           }&lt;br /&gt;
         }&lt;br /&gt;
         else if (command == 52) {                    // If command = &amp;quot;4&amp;quot; print the THRESHOLD4&lt;br /&gt;
           command = Serial.read();&lt;br /&gt;
           if (command &amp;gt; 47 &amp;amp;&amp;amp; command &amp;lt; 58) {          // If command is between 0-9 Decrement the Threshold by number sent&lt;br /&gt;
             THRESHOLD4 -= command - 48;                 // ASCII math to get value sent   &lt;br /&gt;
                  Serial.print(&amp;quot;THRESHOLD4 = &amp;quot;);&lt;br /&gt;
                  Serial.print(THRESHOLD4);           // &lt;br /&gt;
                  Serial.print(&amp;quot; &amp;quot;);&lt;br /&gt;
           }&lt;br /&gt;
         }           &lt;br /&gt;
        }  &lt;br /&gt;
      }&lt;br /&gt;
//****************  Warning - This is a potential for problem - Consider a manual lock out feature to lock out manual commands &lt;br /&gt;
//****************  Possibly create a command to open up manual commands for a certian time period then shut them off again automatically&lt;br /&gt;
      else if (command == 65) {      //If command = &amp;quot;A&amp;quot; Change Temp Threshhold&lt;br /&gt;
       if (Serial.available()) {&lt;br /&gt;
        command = Serial.read();&lt;br /&gt;
        if (command == 49) {        // If command = &amp;quot;1&amp;quot; print the AC ON message&lt;br /&gt;
         getDateDs1307();&lt;br /&gt;
         Serial.print(&amp;quot; - Manual AC ON &amp;quot;);&lt;br /&gt;
         ac_on_start = millis();   // Set the AC to a delay before it can be turned off again&lt;br /&gt;
         digitalWrite(ac_on,HIGH);&lt;br /&gt;
        }&lt;br /&gt;
        else if (command == 48) {        // If command = &amp;quot;0&amp;quot; print the AC OFF message&lt;br /&gt;
         getDateDs1307();&lt;br /&gt;
         Serial.print(&amp;quot; - Manual AC OFF &amp;quot;);&lt;br /&gt;
         digitalWrite(ac_on,LOW);&lt;br /&gt;
        }&lt;br /&gt;
       } &lt;br /&gt;
      } &lt;br /&gt;
      else if (command == 70) {      //If command = &amp;quot;F&amp;quot; Change Temp Threshhold&lt;br /&gt;
       if (Serial.available()) {&lt;br /&gt;
        command = Serial.read();&lt;br /&gt;
        if (command == 49) {        // If command = &amp;quot;1&amp;quot; print the FAN ON message&lt;br /&gt;
         getDateDs1307();&lt;br /&gt;
         Serial.print(&amp;quot; - Manual FAN ON &amp;quot;);&lt;br /&gt;
         ac_on_start = millis();&lt;br /&gt;
         digitalWrite(fan_on,HIGH);&lt;br /&gt;
        }&lt;br /&gt;
        else if (command == 48) {        // If command = &amp;quot;0&amp;quot; print the FAN OFF message&lt;br /&gt;
         getDateDs1307();&lt;br /&gt;
         Serial.print(&amp;quot; - Manual FAN OFF &amp;quot;);&lt;br /&gt;
         digitalWrite(fan_on,LOW);&lt;br /&gt;
        }&lt;br /&gt;
       } &lt;br /&gt;
      }&lt;br /&gt;
//********************** End of Warning Zone *******************************&lt;br /&gt;
&lt;br /&gt;
// ***************  This Section Will list the Staus of the Controller&lt;br /&gt;
      else if (command == 83) {      //If command = &amp;quot;S&amp;quot; Print Controller Status&lt;br /&gt;
        getDateDs1307();&lt;br /&gt;
        Serial.println(&amp;quot; &amp;quot;);&lt;br /&gt;
        Serial.println(&amp;quot; &amp;quot;);&lt;br /&gt;
        Serial.print(&amp;quot;Temp1 = &amp;quot;);&lt;br /&gt;
        Serial.println(temp1_avg);   &lt;br /&gt;
        Serial.print(&amp;quot;Temp2 = &amp;quot;);&lt;br /&gt;
        Serial.println(temp2_avg);&lt;br /&gt;
        Serial.print(&amp;quot;Temp3 = &amp;quot;);&lt;br /&gt;
        Serial.println(temp3_avg);   &lt;br /&gt;
        Serial.print(&amp;quot;Temp4 = &amp;quot;);&lt;br /&gt;
        Serial.println(temp4_avg);   &lt;br /&gt;
        Serial.println(&amp;quot; &amp;quot;);&lt;br /&gt;
        Serial.print(&amp;quot;THRESHOLD1 = &amp;quot;);&lt;br /&gt;
        Serial.println(THRESHOLD1);   &lt;br /&gt;
        Serial.print(&amp;quot;THRESHOLD2 = &amp;quot;);&lt;br /&gt;
        Serial.println(THRESHOLD2); &lt;br /&gt;
        Serial.print(&amp;quot;THRESHOLD3 = &amp;quot;);&lt;br /&gt;
        Serial.println(THRESHOLD3); &lt;br /&gt;
        Serial.print(&amp;quot;THRESHOLD4 = &amp;quot;);&lt;br /&gt;
        Serial.println(THRESHOLD4);&lt;br /&gt;
        Serial.println(&amp;quot; &amp;quot;);&lt;br /&gt;
        if (digitalRead(duct1) == HIGH) {Serial.println(&amp;quot;duct1 ON&amp;quot;);}&lt;br /&gt;
        else{Serial.println(&amp;quot;duct1 OFF&amp;quot;);}&lt;br /&gt;
        if (digitalRead(duct2) == HIGH) {Serial.println(&amp;quot;duct2 ON&amp;quot;);}&lt;br /&gt;
        else{Serial.println(&amp;quot;duct2 OFF&amp;quot;);}&lt;br /&gt;
        if (digitalRead(duct3) == HIGH) {Serial.println(&amp;quot;duct3 ON&amp;quot;);}&lt;br /&gt;
        else{Serial.println(&amp;quot;duct3 OFF&amp;quot;);}&lt;br /&gt;
        if (digitalRead(duct4) == HIGH) {Serial.println(&amp;quot;duct4 ON&amp;quot;);}&lt;br /&gt;
        else{Serial.println(&amp;quot;duct4 OFF&amp;quot;);}&lt;br /&gt;
        Serial.println(&amp;quot; &amp;quot;);&lt;br /&gt;
        if (digitalRead(fan_on) == HIGH) {Serial.println(&amp;quot;Fan ON&amp;quot;);}&lt;br /&gt;
        else{Serial.println(&amp;quot;Fan OFF&amp;quot;);}&lt;br /&gt;
        if (digitalRead(ac_on) == HIGH) {Serial.println(&amp;quot;AC  ON&amp;quot;);}&lt;br /&gt;
        else{Serial.println(&amp;quot;AC  OFF&amp;quot;);}&lt;br /&gt;
        Serial.print(&amp;quot;A/C Delay (millisec) = &amp;quot;);&lt;br /&gt;
        Serial.println(ac_on_delay);&lt;br /&gt;
        Serial.print(&amp;quot;Temp Polling (millisec) = &amp;quot;);&lt;br /&gt;
        Serial.println(polltime);          &lt;br /&gt;
        Serial.println(&amp;quot; &amp;quot;);&lt;br /&gt;
        &lt;br /&gt;
      }&lt;br /&gt;
      else if (command == 81) {      //If command = &amp;quot;Q&amp;quot; Set Date&lt;br /&gt;
       setDateDs1307();&lt;br /&gt;
       getDateDs1307();&lt;br /&gt;
       Serial.println(&amp;quot; &amp;quot;);&lt;br /&gt;
      }&lt;br /&gt;
      Serial.println(command);     // Echo command char found in serial que&lt;br /&gt;
      command = 0;                 // reset command &lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
//*****************************************************The End***********************&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== A/C_Control_v.01 User Guide ==&lt;br /&gt;
==== Commands ====&lt;br /&gt;
== Troubleshooting ==&lt;br /&gt;
=== Summary ===&lt;br /&gt;
When Troubleshooting a multi-functional issue, it is best practice to break down the issue into pieces and test each piece as a separate system.  However, we will first run through a quick test to see if we can find any obvious issues first.&lt;br /&gt;
=== Quick Test ===&lt;/div&gt;</summary>
		<author><name>Combustor</name></author>	</entry>

	<entry>
		<id>http://combustory.com/wiki/index.php/Temperature_Controller</id>
		<title>Temperature Controller</title>
		<link rel="alternate" type="text/html" href="http://combustory.com/wiki/index.php/Temperature_Controller"/>
				<updated>2008-09-12T18:13:13Z</updated>
		
		<summary type="html">&lt;p&gt;Combustor: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{default}}&lt;br /&gt;
== Warning ==&lt;br /&gt;
'''This page is in progress and none of the code can be considered good or complete. I am just using this as an alternate storage of the code for right now.'''&lt;br /&gt;
&lt;br /&gt;
== Summary ==&lt;br /&gt;
== Functional Description of the Method ==&lt;br /&gt;
== Requirements ==&lt;br /&gt;
== Example of Method ==&lt;br /&gt;
=== Quick Guide: ===&lt;br /&gt;
=== Detailed Guide: ===&lt;br /&gt;
=== I2C ===&lt;br /&gt;
==== X9241A - Digital Potentiometer ====&lt;br /&gt;
&lt;br /&gt;
There are basically only two functions that I am after right now which are both three byte instructions: &lt;br /&gt;
&lt;br /&gt;
* Read WCR(Wiper Control Register) for the four potentiometers 0-3 (So far this is failing miserably)&lt;br /&gt;
** Send 1st byte - Address (my circuit - 01011010 or 0x2D)(binary - 0101 A3 A2 A1 A0) A values are actual pins set to high or low for an address.&lt;br /&gt;
** Send 2nd byte - Instruction (binary - 1001 (1/0)(1/0) 00) - The two bits are used to choose the potentiometer&lt;br /&gt;
** Read WCR requested Byte&lt;br /&gt;
* Write WCR for the four potentiometers 0-3 (This works)&lt;br /&gt;
** Send 1st byte - Address (my circuit - 01011010 or 0x2D)(binary - 0101 A3 A2 A1 A0) A values are actual pins set to high or low for an address.&lt;br /&gt;
** Send 2nd byte - Instruction (binary - 1010 (1/0)(1/0) 00) - The two bits are used to choose the potentiometer&lt;br /&gt;
** Send WCR Byte - Potentiometer value (binary - 00 D5 D4 D3 D2 D1 D0) - D values are the 0-63 potentiometer positions&lt;br /&gt;
&lt;br /&gt;
'''Sample Code'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
       Wire.beginTransmission(X9241_I2C_ADDRESS);&lt;br /&gt;
       Wire.send(0xa0); //Instruction to write WCR-00&lt;br /&gt;
       Wire.send(0x20); //Send a D value of 32&lt;br /&gt;
       Wire.endTransmission();&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
==== DS1307 - Real Time Clock ====&lt;br /&gt;
&lt;br /&gt;
The code for this very useful chip came from the [[http://www.glacialwanderer.com/hobbyrobotics/?p=12 Glacial Wanderer]]&lt;br /&gt;
&lt;br /&gt;
==== A/C_Control_v.01 code ====&lt;br /&gt;
&lt;br /&gt;
''' While this says v.01, don't count on it being a released v.01, I am still working on v.01, this is a back up '''&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
/*&lt;br /&gt;
 * A/C Control v.01&lt;br /&gt;
 * by &amp;lt;http://www.combustory.com&amp;gt; John Vaughters&lt;br /&gt;
 * Credit to:&lt;br /&gt;
 * Maurice Ribble - http://www.glacialwanderer.com/hobbyrobotics for RTC DS1307 code&lt;br /&gt;
 *&lt;br /&gt;
 * Turns on an LED for temperatures from analog pins 1-5 on&lt;br /&gt;
 * digital pins 2-6 when the temperature rises above the THRESHOLDS 1-5.&lt;br /&gt;
 * The program also implements a &lt;br /&gt;
 * Serial Communication method that utilizes a leading CHAR for each command Described below. &lt;br /&gt;
 * Commands:&lt;br /&gt;
 * T(1-4) - Temp1-5 Status ex. T1, T2, etc&lt;br /&gt;
 * C(1-4)(0-9) - Increment THRESHOLD1-4 by (1-9) ex. C15 increments THRESHOLD1 BY 5 (Note: C40 will give you a status of THRESHOLD4)&lt;br /&gt;
 * D(1-4)(0-9) - Decrement THRESHOLD1-4 by (1-9) ex. D59 decrements THRESHOLD5 BY 9 (Note: D10 will give you a status of THRESHOLD1)&lt;br /&gt;
 * A(0-1) - Manual AC on command A1 is AC on, A0 is AC off&lt;br /&gt;
 * F(0-1) - Manual AC on command A1 is FAN on, A0 is FAN off &lt;br /&gt;
 * Q - Q Sets the date of the RTC DS1307 Chip&lt;br /&gt;
 */&lt;br /&gt;
&lt;br /&gt;
#include &amp;quot;Wire.h&amp;quot;&lt;br /&gt;
#define DS1307_I2C_ADDRESS 0x68&lt;br /&gt;
&lt;br /&gt;
// Global Variables&lt;br /&gt;
int val_cnt = 0;               // counter for the temp_val                   &lt;br /&gt;
int temp1Pin = 0;    // select the input pin for the Thermistor&lt;br /&gt;
int temp2Pin = 1;    // select the input pin for the Thermistor&lt;br /&gt;
int temp3Pin = 2;    // select the input pin for the Thermistor&lt;br /&gt;
int temp4Pin = 3;    // select the input pin for the Thermistor&lt;br /&gt;
int temp1_val[5] = {0,0,0,0,0};       // variable to store the value coming from the sensor&lt;br /&gt;
int temp2_val[5] = {0,0,0,0,0};       //           &lt;br /&gt;
int temp3_val[5] = {0,0,0,0,0};       //&lt;br /&gt;
int temp4_val[5] = {0,0,0,0,0};       //&lt;br /&gt;
int temp1_avg;                   // average over poll time of the temp values&lt;br /&gt;
int temp2_avg;&lt;br /&gt;
int temp3_avg;&lt;br /&gt;
int temp4_avg;&lt;br /&gt;
int duct1 = 2;                   // Ducts open or close using a digital output&lt;br /&gt;
int duct2 = 3;&lt;br /&gt;
int duct3 = 4;&lt;br /&gt;
int duct4 = 5;&lt;br /&gt;
int THRESHOLD1 = 580;    // Default theshold values&lt;br /&gt;
int THRESHOLD2 = 580;&lt;br /&gt;
int THRESHOLD3 = 580;&lt;br /&gt;
int THRESHOLD4 = 580;&lt;br /&gt;
int ac_on = 13;&lt;br /&gt;
int fan_on = 12;&lt;br /&gt;
int command = 0;       // This is the command char, in ascii form, sent from the serial port     &lt;br /&gt;
long polltime = 1000;  // The time to Poll the tempPins&lt;br /&gt;
long previousMillis = 0;        // will store last time Temp was updated&lt;br /&gt;
long ac_on_start = 0;     // Start A/C delay timer&lt;br /&gt;
long ac_on_delay = 10000;   // Time to wait before checking the ducts again&lt;br /&gt;
byte second, minute, hour, dayOfWeek, dayOfMonth, month, year;&lt;br /&gt;
&lt;br /&gt;
  &lt;br /&gt;
// Convert normal decimal numbers to binary coded decimal&lt;br /&gt;
byte decToBcd(byte val)&lt;br /&gt;
{&lt;br /&gt;
  return ( (val/10*16) + (val%10) );&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
// Convert binary coded decimal to normal decimal numbers&lt;br /&gt;
byte bcdToDec(byte val)&lt;br /&gt;
{&lt;br /&gt;
  return ( (val/16*10) + (val%16) );&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
// 1) Sets the date and time on the ds1307&lt;br /&gt;
// 2) Starts the clock&lt;br /&gt;
// 3) Sets hour mode to 24 hour clock&lt;br /&gt;
// Assumes you're passing in valid numbers&lt;br /&gt;
// Watch for scope issues with Global Variables&lt;br /&gt;
/*void setDateDs1307(byte second,        // 0-59&lt;br /&gt;
                   byte minute,        // 0-59&lt;br /&gt;
                   byte hour,          // 1-23&lt;br /&gt;
                   byte dayOfWeek,     // 1-7&lt;br /&gt;
                   byte dayOfMonth,    // 1-28/29/30/31&lt;br /&gt;
                   byte month,         // 1-12&lt;br /&gt;
                   byte year)          // 0-99*/&lt;br /&gt;
void setDateDs1307()                &lt;br /&gt;
{&lt;br /&gt;
   Wire.beginTransmission(DS1307_I2C_ADDRESS);&lt;br /&gt;
   Wire.send(0);&lt;br /&gt;
   Wire.send(decToBcd(second));    // 0 to bit 7 starts the clock&lt;br /&gt;
   Wire.send(decToBcd(minute));&lt;br /&gt;
   Wire.send(decToBcd(hour));      // If you want 12 hour am/pm you need to set&lt;br /&gt;
                                   // bit 6 (also need to change readDateDs1307)&lt;br /&gt;
   Wire.send(decToBcd(dayOfWeek));&lt;br /&gt;
   Wire.send(decToBcd(dayOfMonth));&lt;br /&gt;
   Wire.send(decToBcd(month));&lt;br /&gt;
   Wire.send(decToBcd(year));&lt;br /&gt;
   Wire.endTransmission();&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
// Gets the date and time from the ds1307 and prints result&lt;br /&gt;
// Watch for scope issues with Global Variables&lt;br /&gt;
void getDateDs1307()&lt;br /&gt;
{&lt;br /&gt;
  // Reset the register pointer&lt;br /&gt;
  Wire.beginTransmission(DS1307_I2C_ADDRESS);&lt;br /&gt;
  Wire.send(0);&lt;br /&gt;
  Wire.endTransmission();&lt;br /&gt;
&lt;br /&gt;
  Wire.requestFrom(DS1307_I2C_ADDRESS, 7);&lt;br /&gt;
&lt;br /&gt;
  // A few of these need masks because certain bits are control bits&lt;br /&gt;
  second     = bcdToDec(Wire.receive() &amp;amp; 0x7f);&lt;br /&gt;
  minute     = bcdToDec(Wire.receive());&lt;br /&gt;
  hour       = bcdToDec(Wire.receive() &amp;amp; 0x3f);  // Need to change this if 12 hour am/pm&lt;br /&gt;
  dayOfWeek  = bcdToDec(Wire.receive());&lt;br /&gt;
  dayOfMonth = bcdToDec(Wire.receive());&lt;br /&gt;
  month      = bcdToDec(Wire.receive());&lt;br /&gt;
  year       = bcdToDec(Wire.receive());&lt;br /&gt;
  &lt;br /&gt;
  Serial.print(hour, DEC);&lt;br /&gt;
  Serial.print(&amp;quot;:&amp;quot;);&lt;br /&gt;
  Serial.print(minute, DEC);&lt;br /&gt;
  Serial.print(&amp;quot;:&amp;quot;);&lt;br /&gt;
  Serial.print(second, DEC);&lt;br /&gt;
  Serial.print(&amp;quot;  &amp;quot;);&lt;br /&gt;
  Serial.print(month, DEC);&lt;br /&gt;
  Serial.print(&amp;quot;/&amp;quot;);&lt;br /&gt;
  Serial.print(dayOfMonth, DEC);&lt;br /&gt;
  Serial.print(&amp;quot;/&amp;quot;);&lt;br /&gt;
  Serial.print(year, DEC);&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
void setup() {&lt;br /&gt;
  Wire.begin();&lt;br /&gt;
  Serial.begin(57600);&lt;br /&gt;
  pinMode(duct1, OUTPUT);&lt;br /&gt;
  pinMode(duct2, OUTPUT);&lt;br /&gt;
  pinMode(duct3, OUTPUT);&lt;br /&gt;
  pinMode(duct4, OUTPUT);&lt;br /&gt;
  pinMode(ac_on, OUTPUT);&lt;br /&gt;
  pinMode(fan_on, OUTPUT);&lt;br /&gt;
  // Initialize Date/Time to update RTC DS1307 - You need to run the Q command right after you download this program&lt;br /&gt;
  // This is temporary until a more complex date time command is finished&lt;br /&gt;
  second = 15;&lt;br /&gt;
  minute = 41;&lt;br /&gt;
  hour = 12;&lt;br /&gt;
  dayOfWeek = 5;&lt;br /&gt;
  dayOfMonth = 5;&lt;br /&gt;
  month = 9;&lt;br /&gt;
  year = 8;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
void loop() {&lt;br /&gt;
  if (millis() - previousMillis &amp;gt; polltime) {&lt;br /&gt;
    previousMillis = millis();   // remember the last time&lt;br /&gt;
    if (millis() - ac_on_start &amp;gt; ac_on_delay) { &lt;br /&gt;
      if (digitalRead(duct1) || digitalRead(duct2) || digitalRead(duct3) || digitalRead(duct4)){  // If any ducts are turned on turn on the A/C&lt;br /&gt;
       if (digitalRead(ac_on) != HIGH) { // Check ac_on state&lt;br /&gt;
        digitalWrite(ac_on,HIGH);&lt;br /&gt;
        getDateDs1307();&lt;br /&gt;
        Serial.println(&amp;quot; - AC ON&amp;quot;);&lt;br /&gt;
       }&lt;br /&gt;
       ac_on_start = millis();&lt;br /&gt;
      } &lt;br /&gt;
      else if (digitalRead(ac_on) != LOW){ //Check ac_on state&lt;br /&gt;
       digitalWrite(ac_on,LOW);&lt;br /&gt;
       getDateDs1307();&lt;br /&gt;
       Serial.println(&amp;quot; - AC OFF&amp;quot;);&lt;br /&gt;
      }&lt;br /&gt;
    }&lt;br /&gt;
    temp1_val[val_cnt] = analogRead(temp1Pin);    // read the value from the sensors&lt;br /&gt;
    temp2_val[val_cnt] = analogRead(temp2Pin);&lt;br /&gt;
    temp3_val[val_cnt] = analogRead(temp3Pin);&lt;br /&gt;
    temp4_val[val_cnt] = analogRead(temp4Pin);&lt;br /&gt;
    val_cnt ++;&lt;br /&gt;
    if (val_cnt == 5) {&lt;br /&gt;
      val_cnt = 0;&lt;br /&gt;
    }&lt;br /&gt;
    temp1_avg = (temp1_val[0] + temp1_val[1] + temp1_val[2] + temp1_val[3] + temp1_val[4])/5;&lt;br /&gt;
    temp2_avg = (temp2_val[0] + temp2_val[1] + temp2_val[2] + temp2_val[3] + temp2_val[4])/5;&lt;br /&gt;
    temp3_avg = (temp3_val[0] + temp3_val[1] + temp3_val[2] + temp3_val[3] + temp3_val[4])/5;&lt;br /&gt;
    temp4_avg = (temp4_val[0] + temp4_val[1] + temp4_val[2] + temp4_val[3] + temp4_val[4])/5;&lt;br /&gt;
// Check Thresholds against the Temperatures and set the ducts HIGH or LOW    &lt;br /&gt;
    if (temp1_avg &amp;gt;= THRESHOLD1) {digitalWrite(duct1, HIGH);}&lt;br /&gt;
    else {digitalWrite(duct1, LOW);}&lt;br /&gt;
    if (temp2_avg &amp;gt;= THRESHOLD2) {digitalWrite(duct2, HIGH);}&lt;br /&gt;
    else {digitalWrite(duct2, LOW);}&lt;br /&gt;
    if (temp3_avg &amp;gt;= THRESHOLD3) {digitalWrite(duct3, HIGH);}&lt;br /&gt;
    else {digitalWrite(duct3, LOW);}&lt;br /&gt;
    if (temp4_avg &amp;gt;= THRESHOLD4) {digitalWrite(duct4, HIGH);}&lt;br /&gt;
    else {digitalWrite(duct4, LOW);}&lt;br /&gt;
    if (Serial.available()) {      // Look for char in serial que and process if found&lt;br /&gt;
      command = Serial.read();&lt;br /&gt;
      if (command == 84) {          // If command = &amp;quot;T&amp;quot; &lt;br /&gt;
        command = Serial.read();&lt;br /&gt;
        if (command == 49) {          // If command = &amp;quot;1&amp;quot; print the Temp1&lt;br /&gt;
         Serial.print(&amp;quot;Temp1 = &amp;quot;);&lt;br /&gt;
         Serial.print(temp1_avg);           // &lt;br /&gt;
         Serial.print(&amp;quot; &amp;quot;);&lt;br /&gt;
        }&lt;br /&gt;
        else if (command == 50) {      // If command = &amp;quot;2&amp;quot; print the Temp2&lt;br /&gt;
         Serial.print(&amp;quot;Temp2 = &amp;quot;);&lt;br /&gt;
         Serial.print(temp2_avg);           // &lt;br /&gt;
         Serial.print(&amp;quot; &amp;quot;);&lt;br /&gt;
        }&lt;br /&gt;
        else if (command == 51) {      // If command = &amp;quot;3&amp;quot; print the Temp3&lt;br /&gt;
         Serial.print(&amp;quot;Temp3 = &amp;quot;);&lt;br /&gt;
         Serial.print(temp3_avg);           // &lt;br /&gt;
         Serial.print(&amp;quot; &amp;quot;);&lt;br /&gt;
        }&lt;br /&gt;
        else if (command == 52) {      // If command = &amp;quot;4&amp;quot; print the Temp4&lt;br /&gt;
         Serial.print(&amp;quot;Temp4 = &amp;quot;);&lt;br /&gt;
         Serial.print(temp4_avg);           // &lt;br /&gt;
         Serial.print(&amp;quot; &amp;quot;);&lt;br /&gt;
         }&lt;br /&gt;
       }&lt;br /&gt;
      else if (command == 67) {      //If command = &amp;quot;C&amp;quot; Change Temp Threshhold&lt;br /&gt;
        if (Serial.available()) {&lt;br /&gt;
         command = Serial.read();&lt;br /&gt;
         if (command == 49) {        // If command = &amp;quot;1&amp;quot; print the THRESHOLD1&lt;br /&gt;
           command = Serial.read();&lt;br /&gt;
           if (command &amp;gt; 47 &amp;amp;&amp;amp; command &amp;lt; 58) {          // If command is between 0-9 Increment the Threshold by number sent&lt;br /&gt;
             THRESHOLD1 += command - 48;                 // ASCII math to get value sent   &lt;br /&gt;
                  Serial.print(&amp;quot;THRESHOLD1 = &amp;quot;);&lt;br /&gt;
                  Serial.print(THRESHOLD1);           // &lt;br /&gt;
                  Serial.print(&amp;quot; &amp;quot;);&lt;br /&gt;
           }&lt;br /&gt;
         }  &lt;br /&gt;
         else if (command == 50) {     // If command = &amp;quot;2&amp;quot; print the THRESHOLD2&lt;br /&gt;
           command = Serial.read();&lt;br /&gt;
           if (command &amp;gt; 47 &amp;amp;&amp;amp; command &amp;lt; 58) {          // If command is between 0-9 Increment the Threshold by number sent&lt;br /&gt;
             THRESHOLD2 += command - 48;                 // ASCII math to get value sent   &lt;br /&gt;
                  Serial.print(&amp;quot;THRESHOLD2 = &amp;quot;);&lt;br /&gt;
                  Serial.print(THRESHOLD2);           // &lt;br /&gt;
                  Serial.print(&amp;quot; &amp;quot;);&lt;br /&gt;
           }&lt;br /&gt;
         }&lt;br /&gt;
         else if (command == 51) {             // If command = &amp;quot;3&amp;quot; print the THRESHOLD3&lt;br /&gt;
           command = Serial.read();&lt;br /&gt;
           if (command &amp;gt; 47 &amp;amp;&amp;amp; command &amp;lt; 58) {          // If command is between 0-9 Increment the Threshold by number sent&lt;br /&gt;
             THRESHOLD3 += command - 48;                 // ASCII math to get value sent   &lt;br /&gt;
                  Serial.print(&amp;quot;THRESHOLD3 = &amp;quot;);&lt;br /&gt;
                  Serial.print(THRESHOLD3);           // &lt;br /&gt;
                  Serial.print(&amp;quot; &amp;quot;);&lt;br /&gt;
           }&lt;br /&gt;
         }&lt;br /&gt;
         else if (command == 52) {             // If command = &amp;quot;4&amp;quot; print the THRESHOLD4&lt;br /&gt;
           command = Serial.read();&lt;br /&gt;
           if (command &amp;gt; 47 &amp;amp;&amp;amp; command &amp;lt; 58) {          // If command is between 0-9 Increment the Threshold by number sent&lt;br /&gt;
             THRESHOLD4 += command - 48;                 // ASCII math to get value sent   &lt;br /&gt;
                  Serial.print(&amp;quot;THRESHOLD4 = &amp;quot;);&lt;br /&gt;
                  Serial.print(THRESHOLD4);           // &lt;br /&gt;
                  Serial.print(&amp;quot; &amp;quot;);&lt;br /&gt;
           }&lt;br /&gt;
         }          &lt;br /&gt;
        }  &lt;br /&gt;
      }&lt;br /&gt;
      else if (command == 68) {      //If command = &amp;quot;D&amp;quot; Change Temp Threshhold&lt;br /&gt;
        if (Serial.available()) {&lt;br /&gt;
         command = Serial.read();&lt;br /&gt;
         if (command == 49) {           // If command = &amp;quot;1&amp;quot; print the THRESHOLD1&lt;br /&gt;
           command = Serial.read();&lt;br /&gt;
           if (command &amp;gt; 47 &amp;amp;&amp;amp; command &amp;lt; 58) {          // If command is between 0-9 Decrement the Threshold by number sent&lt;br /&gt;
             THRESHOLD1 -= command - 48;                 // ASCII math to get value sent   &lt;br /&gt;
                  Serial.print(&amp;quot;THRESHOLD1 = &amp;quot;);&lt;br /&gt;
                  Serial.print(THRESHOLD1);           // &lt;br /&gt;
                  Serial.print(&amp;quot; &amp;quot;);&lt;br /&gt;
           }&lt;br /&gt;
         }  &lt;br /&gt;
         else if (command == 50) {               // If command = &amp;quot;2&amp;quot; print the THRESHOLD2&lt;br /&gt;
           command = Serial.read();&lt;br /&gt;
           if (command &amp;gt; 47 &amp;amp;&amp;amp; command &amp;lt; 58) {          // If command is between 0-9 Decrement the Threshold by number sent&lt;br /&gt;
             THRESHOLD2 -= command - 48;                 // ASCII math to get value sent   &lt;br /&gt;
                  Serial.print(&amp;quot;THRESHOLD2 = &amp;quot;);&lt;br /&gt;
                  Serial.print(THRESHOLD2);           // &lt;br /&gt;
                  Serial.print(&amp;quot; &amp;quot;);&lt;br /&gt;
           }&lt;br /&gt;
         }&lt;br /&gt;
         else if (command == 51) {              // If command = &amp;quot;3&amp;quot; print the THRESHOLD3&lt;br /&gt;
           command = Serial.read();&lt;br /&gt;
           if (command &amp;gt; 47 &amp;amp;&amp;amp; command &amp;lt; 58) {          // If command is between 0-9 Decrement the Threshold by number sent&lt;br /&gt;
             THRESHOLD3 -= command - 48;                 // ASCII math to get value sent   &lt;br /&gt;
                  Serial.print(&amp;quot;THRESHOLD3 = &amp;quot;);&lt;br /&gt;
                  Serial.print(THRESHOLD3);           // &lt;br /&gt;
                  Serial.print(&amp;quot; &amp;quot;);&lt;br /&gt;
           }&lt;br /&gt;
         }&lt;br /&gt;
         else if (command == 52) {                    // If command = &amp;quot;4&amp;quot; print the THRESHOLD4&lt;br /&gt;
           command = Serial.read();&lt;br /&gt;
           if (command &amp;gt; 47 &amp;amp;&amp;amp; command &amp;lt; 58) {          // If command is between 0-9 Decrement the Threshold by number sent&lt;br /&gt;
             THRESHOLD4 -= command - 48;                 // ASCII math to get value sent   &lt;br /&gt;
                  Serial.print(&amp;quot;THRESHOLD4 = &amp;quot;);&lt;br /&gt;
                  Serial.print(THRESHOLD4);           // &lt;br /&gt;
                  Serial.print(&amp;quot; &amp;quot;);&lt;br /&gt;
           }&lt;br /&gt;
         }           &lt;br /&gt;
        }  &lt;br /&gt;
      }&lt;br /&gt;
//****************  Warning - This is a potential for problem - Consider a manual lock out feature to lock out manual commands &lt;br /&gt;
//****************  Possibly create a command to open up manual commands for a certian time period then shut them off again automatically&lt;br /&gt;
      else if (command == 65) {      //If command = &amp;quot;A&amp;quot; Change Temp Threshhold&lt;br /&gt;
       if (Serial.available()) {&lt;br /&gt;
        command = Serial.read();&lt;br /&gt;
        if (command == 49) {        // If command = &amp;quot;1&amp;quot; print the AC ON message&lt;br /&gt;
         getDateDs1307();&lt;br /&gt;
         Serial.print(&amp;quot; - Manual AC ON &amp;quot;);&lt;br /&gt;
         ac_on_start = millis();   // Set the AC to a delay before it can be turned off again&lt;br /&gt;
         digitalWrite(ac_on,HIGH);&lt;br /&gt;
        }&lt;br /&gt;
        else if (command == 48) {        // If command = &amp;quot;0&amp;quot; print the AC OFF message&lt;br /&gt;
         getDateDs1307();&lt;br /&gt;
         Serial.print(&amp;quot; - Manual AC OFF &amp;quot;);&lt;br /&gt;
         digitalWrite(ac_on,LOW);&lt;br /&gt;
        }&lt;br /&gt;
       } &lt;br /&gt;
      } &lt;br /&gt;
      else if (command == 70) {      //If command = &amp;quot;F&amp;quot; Change Temp Threshhold&lt;br /&gt;
       if (Serial.available()) {&lt;br /&gt;
        command = Serial.read();&lt;br /&gt;
        if (command == 49) {        // If command = &amp;quot;1&amp;quot; print the FAN ON message&lt;br /&gt;
         getDateDs1307();&lt;br /&gt;
         Serial.print(&amp;quot; - Manual FAN ON &amp;quot;);&lt;br /&gt;
         ac_on_start = millis();&lt;br /&gt;
         digitalWrite(fan_on,HIGH);&lt;br /&gt;
        }&lt;br /&gt;
        else if (command == 48) {        // If command = &amp;quot;0&amp;quot; print the FAN OFF message&lt;br /&gt;
         getDateDs1307();&lt;br /&gt;
         Serial.print(&amp;quot; - Manual FAN OFF &amp;quot;);&lt;br /&gt;
         digitalWrite(fan_on,LOW);&lt;br /&gt;
        }&lt;br /&gt;
       } &lt;br /&gt;
      }&lt;br /&gt;
//********************** End of Warning Zone *******************************&lt;br /&gt;
&lt;br /&gt;
// ***************  This Section Will list the Staus of the Controller&lt;br /&gt;
      else if (command == 83) {      //If command = &amp;quot;S&amp;quot; Print Controller Status&lt;br /&gt;
        getDateDs1307();&lt;br /&gt;
        Serial.println(&amp;quot; &amp;quot;);&lt;br /&gt;
        Serial.println(&amp;quot; &amp;quot;);&lt;br /&gt;
        Serial.print(&amp;quot;Temp1 = &amp;quot;);&lt;br /&gt;
        Serial.println(temp1_avg);   &lt;br /&gt;
        Serial.print(&amp;quot;Temp2 = &amp;quot;);&lt;br /&gt;
        Serial.println(temp2_avg);&lt;br /&gt;
        Serial.print(&amp;quot;Temp3 = &amp;quot;);&lt;br /&gt;
        Serial.println(temp3_avg);   &lt;br /&gt;
        Serial.print(&amp;quot;Temp4 = &amp;quot;);&lt;br /&gt;
        Serial.println(temp4_avg);   &lt;br /&gt;
        Serial.println(&amp;quot; &amp;quot;);&lt;br /&gt;
        Serial.print(&amp;quot;THRESHOLD1 = &amp;quot;);&lt;br /&gt;
        Serial.println(THRESHOLD1);   &lt;br /&gt;
        Serial.print(&amp;quot;THRESHOLD2 = &amp;quot;);&lt;br /&gt;
        Serial.println(THRESHOLD2); &lt;br /&gt;
        Serial.print(&amp;quot;THRESHOLD3 = &amp;quot;);&lt;br /&gt;
        Serial.println(THRESHOLD3); &lt;br /&gt;
        Serial.print(&amp;quot;THRESHOLD4 = &amp;quot;);&lt;br /&gt;
        Serial.println(THRESHOLD4);&lt;br /&gt;
        Serial.println(&amp;quot; &amp;quot;);&lt;br /&gt;
        if (digitalRead(duct1) == HIGH) {Serial.println(&amp;quot;duct1 ON&amp;quot;);}&lt;br /&gt;
        else{Serial.println(&amp;quot;duct1 OFF&amp;quot;);}&lt;br /&gt;
        if (digitalRead(duct2) == HIGH) {Serial.println(&amp;quot;duct2 ON&amp;quot;);}&lt;br /&gt;
        else{Serial.println(&amp;quot;duct2 OFF&amp;quot;);}&lt;br /&gt;
        if (digitalRead(duct3) == HIGH) {Serial.println(&amp;quot;duct3 ON&amp;quot;);}&lt;br /&gt;
        else{Serial.println(&amp;quot;duct3 OFF&amp;quot;);}&lt;br /&gt;
        if (digitalRead(duct4) == HIGH) {Serial.println(&amp;quot;duct4 ON&amp;quot;);}&lt;br /&gt;
        else{Serial.println(&amp;quot;duct4 OFF&amp;quot;);}&lt;br /&gt;
        Serial.println(&amp;quot; &amp;quot;);&lt;br /&gt;
        if (digitalRead(fan_on) == HIGH) {Serial.println(&amp;quot;Fan ON&amp;quot;);}&lt;br /&gt;
        else{Serial.println(&amp;quot;Fan OFF&amp;quot;);}&lt;br /&gt;
        if (digitalRead(ac_on) == HIGH) {Serial.println(&amp;quot;AC  ON&amp;quot;);}&lt;br /&gt;
        else{Serial.println(&amp;quot;AC  OFF&amp;quot;);}&lt;br /&gt;
        Serial.print(&amp;quot;A/C Delay (millisec) = &amp;quot;);&lt;br /&gt;
        Serial.println(ac_on_delay);&lt;br /&gt;
        Serial.print(&amp;quot;Temp Polling (millisec) = &amp;quot;);&lt;br /&gt;
        Serial.println(polltime);          &lt;br /&gt;
        Serial.println(&amp;quot; &amp;quot;);&lt;br /&gt;
        &lt;br /&gt;
      }&lt;br /&gt;
      else if (command == 81) {      //If command = &amp;quot;Q&amp;quot; Set Date&lt;br /&gt;
       setDateDs1307();&lt;br /&gt;
       getDateDs1307();&lt;br /&gt;
       Serial.println(&amp;quot; &amp;quot;);&lt;br /&gt;
      }&lt;br /&gt;
      Serial.println(command);     // Echo command char found in serial que&lt;br /&gt;
      command = 0;                 // reset command &lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
//*****************************************************The End***********************&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== A/C_Control_v.01 User Guide ==&lt;br /&gt;
==== Commands ====&lt;br /&gt;
== Troubleshooting ==&lt;br /&gt;
=== Summary ===&lt;br /&gt;
When Troubleshooting a multi-functional issue, it is best practice to break down the issue into pieces and test each piece as a separate system.  However, we will first run through a quick test to see if we can find any obvious issues first.&lt;br /&gt;
=== Quick Test ===&lt;/div&gt;</summary>
		<author><name>Combustor</name></author>	</entry>

	<entry>
		<id>http://combustory.com/wiki/index.php/Temperature_Controller</id>
		<title>Temperature Controller</title>
		<link rel="alternate" type="text/html" href="http://combustory.com/wiki/index.php/Temperature_Controller"/>
				<updated>2008-09-10T23:20:20Z</updated>
		
		<summary type="html">&lt;p&gt;Combustor: /* Example of Method */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{default}}&lt;br /&gt;
== Warning ==&lt;br /&gt;
'''This page is in progress and none of the code can be considered good or complete. I am just using this as an alternate storage of the code for right now.'''&lt;br /&gt;
&lt;br /&gt;
== Summary ==&lt;br /&gt;
== Functional Description of the Method ==&lt;br /&gt;
== Requirements ==&lt;br /&gt;
== Example of Method ==&lt;br /&gt;
=== Quick Guide: ===&lt;br /&gt;
=== Detailed Guide: ===&lt;br /&gt;
=== I2C ===&lt;br /&gt;
==== X9241A - Digital Potentiometer ====&lt;br /&gt;
&lt;br /&gt;
There are basically only two functions that I am after right now which are both three byte instructions: &lt;br /&gt;
&lt;br /&gt;
* Read WCR(Wiper Control Register) for the four potentiometers 0-3 (So far this is failing miserably)&lt;br /&gt;
** Send 1st byte - Address (my circuit - 01011010 or 0x2D)(binary - 0101 A3 A2 A1 A0) A values are actual pins set to high or low for an address.&lt;br /&gt;
** Send 2nd byte - Instruction (binary - 1001 (1/0)(1/0) 00) - The two bits are used to choose the potentiometer&lt;br /&gt;
** Read WCR requested Byte&lt;br /&gt;
* Write WCR for the four potentiometers 0-3 (This works)&lt;br /&gt;
** Send 1st byte - Address (my circuit - 01011010 or 0x2D)(binary - 0101 A3 A2 A1 A0) A values are actual pins set to high or low for an address.&lt;br /&gt;
** Send 2nd byte - Instruction (binary - 1010 (1/0)(1/0) 00) - The two bits are used to choose the potentiometer&lt;br /&gt;
** Send WCR Byte - Potentiometer value (binary - 00 D5 D4 D3 D2 D1 D0) - D values are the 0-63 potentiometer positions&lt;br /&gt;
&lt;br /&gt;
==== DS1307 - Real Time Clock ====&lt;br /&gt;
&lt;br /&gt;
The code for this very useful chip came from the [[http://www.glacialwanderer.com/hobbyrobotics/?p=12 Glacial Wanderer]]&lt;br /&gt;
&lt;br /&gt;
==== A/C_Control_v.01 code ====&lt;br /&gt;
&lt;br /&gt;
''' While this says v.01, don't count on it being a released v.01, I am still working on v.01, this is a back up '''&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
/*&lt;br /&gt;
 * A/C Control v.01&lt;br /&gt;
 * by &amp;lt;http://www.combustory.com&amp;gt; John Vaughters&lt;br /&gt;
 * Credit to:&lt;br /&gt;
 * Maurice Ribble - http://www.glacialwanderer.com/hobbyrobotics for RTC DS1307 code&lt;br /&gt;
 *&lt;br /&gt;
 * Turns on an LED for temperatures from analog pins 1-5 on&lt;br /&gt;
 * digital pins 2-6 when the temperature rises above the THRESHOLDS 1-5.&lt;br /&gt;
 * The program also implements a &lt;br /&gt;
 * Serial Communication method that utilizes a leading CHAR for each command Described below. &lt;br /&gt;
 * Commands:&lt;br /&gt;
 * T(1-4) - Temp1-5 Status ex. T1, T2, etc&lt;br /&gt;
 * C(1-4)(0-9) - Increment THRESHOLD1-4 by (1-9) ex. C15 increments THRESHOLD1 BY 5 (Note: C40 will give you a status of THRESHOLD4)&lt;br /&gt;
 * D(1-4)(0-9) - Decrement THRESHOLD1-4 by (1-9) ex. D59 decrements THRESHOLD5 BY 9 (Note: D10 will give you a status of THRESHOLD1)&lt;br /&gt;
 * A(0-1) - Manual AC on command A1 is AC on, A0 is AC off&lt;br /&gt;
 * F(0-1) - Manual AC on command A1 is FAN on, A0 is FAN off &lt;br /&gt;
 * Q - Q Sets the date of the RTC DS1307 Chip&lt;br /&gt;
 */&lt;br /&gt;
&lt;br /&gt;
#include &amp;quot;Wire.h&amp;quot;&lt;br /&gt;
#define DS1307_I2C_ADDRESS 0x68&lt;br /&gt;
&lt;br /&gt;
// Global Variables&lt;br /&gt;
int val_cnt = 0;               // counter for the temp_val                   &lt;br /&gt;
int temp1Pin = 0;    // select the input pin for the Thermistor&lt;br /&gt;
int temp2Pin = 1;    // select the input pin for the Thermistor&lt;br /&gt;
int temp3Pin = 2;    // select the input pin for the Thermistor&lt;br /&gt;
int temp4Pin = 3;    // select the input pin for the Thermistor&lt;br /&gt;
int temp1_val[5] = {0,0,0,0,0};       // variable to store the value coming from the sensor&lt;br /&gt;
int temp2_val[5] = {0,0,0,0,0};       //           &lt;br /&gt;
int temp3_val[5] = {0,0,0,0,0};       //&lt;br /&gt;
int temp4_val[5] = {0,0,0,0,0};       //&lt;br /&gt;
int temp1_avg;                   // average over poll time of the temp values&lt;br /&gt;
int temp2_avg;&lt;br /&gt;
int temp3_avg;&lt;br /&gt;
int temp4_avg;&lt;br /&gt;
int duct1 = 2;                   // Ducts open or close using a digital output&lt;br /&gt;
int duct2 = 3;&lt;br /&gt;
int duct3 = 4;&lt;br /&gt;
int duct4 = 5;&lt;br /&gt;
int THRESHOLD1 = 580;    // Default theshold values&lt;br /&gt;
int THRESHOLD2 = 580;&lt;br /&gt;
int THRESHOLD3 = 580;&lt;br /&gt;
int THRESHOLD4 = 580;&lt;br /&gt;
int ac_on = 13;&lt;br /&gt;
int fan_on = 12;&lt;br /&gt;
int command = 0;       // This is the command char, in ascii form, sent from the serial port     &lt;br /&gt;
long polltime = 1000;  // The time to Poll the tempPins&lt;br /&gt;
long previousMillis = 0;        // will store last time Temp was updated&lt;br /&gt;
long ac_on_start = 0;     // Start A/C delay timer&lt;br /&gt;
long ac_on_delay = 10000;   // Time to wait before checking the ducts again&lt;br /&gt;
byte second, minute, hour, dayOfWeek, dayOfMonth, month, year;&lt;br /&gt;
&lt;br /&gt;
  &lt;br /&gt;
// Convert normal decimal numbers to binary coded decimal&lt;br /&gt;
byte decToBcd(byte val)&lt;br /&gt;
{&lt;br /&gt;
  return ( (val/10*16) + (val%10) );&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
// Convert binary coded decimal to normal decimal numbers&lt;br /&gt;
byte bcdToDec(byte val)&lt;br /&gt;
{&lt;br /&gt;
  return ( (val/16*10) + (val%16) );&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
// 1) Sets the date and time on the ds1307&lt;br /&gt;
// 2) Starts the clock&lt;br /&gt;
// 3) Sets hour mode to 24 hour clock&lt;br /&gt;
// Assumes you're passing in valid numbers&lt;br /&gt;
// Watch for scope issues with Global Variables&lt;br /&gt;
/*void setDateDs1307(byte second,        // 0-59&lt;br /&gt;
                   byte minute,        // 0-59&lt;br /&gt;
                   byte hour,          // 1-23&lt;br /&gt;
                   byte dayOfWeek,     // 1-7&lt;br /&gt;
                   byte dayOfMonth,    // 1-28/29/30/31&lt;br /&gt;
                   byte month,         // 1-12&lt;br /&gt;
                   byte year)          // 0-99*/&lt;br /&gt;
void setDateDs1307()                &lt;br /&gt;
{&lt;br /&gt;
   Wire.beginTransmission(DS1307_I2C_ADDRESS);&lt;br /&gt;
   Wire.send(0);&lt;br /&gt;
   Wire.send(decToBcd(second));    // 0 to bit 7 starts the clock&lt;br /&gt;
   Wire.send(decToBcd(minute));&lt;br /&gt;
   Wire.send(decToBcd(hour));      // If you want 12 hour am/pm you need to set&lt;br /&gt;
                                   // bit 6 (also need to change readDateDs1307)&lt;br /&gt;
   Wire.send(decToBcd(dayOfWeek));&lt;br /&gt;
   Wire.send(decToBcd(dayOfMonth));&lt;br /&gt;
   Wire.send(decToBcd(month));&lt;br /&gt;
   Wire.send(decToBcd(year));&lt;br /&gt;
   Wire.endTransmission();&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
// Gets the date and time from the ds1307 and prints result&lt;br /&gt;
// Watch for scope issues with Global Variables&lt;br /&gt;
void getDateDs1307()&lt;br /&gt;
{&lt;br /&gt;
  // Reset the register pointer&lt;br /&gt;
  Wire.beginTransmission(DS1307_I2C_ADDRESS);&lt;br /&gt;
  Wire.send(0);&lt;br /&gt;
  Wire.endTransmission();&lt;br /&gt;
&lt;br /&gt;
  Wire.requestFrom(DS1307_I2C_ADDRESS, 7);&lt;br /&gt;
&lt;br /&gt;
  // A few of these need masks because certain bits are control bits&lt;br /&gt;
  second     = bcdToDec(Wire.receive() &amp;amp; 0x7f);&lt;br /&gt;
  minute     = bcdToDec(Wire.receive());&lt;br /&gt;
  hour       = bcdToDec(Wire.receive() &amp;amp; 0x3f);  // Need to change this if 12 hour am/pm&lt;br /&gt;
  dayOfWeek  = bcdToDec(Wire.receive());&lt;br /&gt;
  dayOfMonth = bcdToDec(Wire.receive());&lt;br /&gt;
  month      = bcdToDec(Wire.receive());&lt;br /&gt;
  year       = bcdToDec(Wire.receive());&lt;br /&gt;
  &lt;br /&gt;
  Serial.print(hour, DEC);&lt;br /&gt;
  Serial.print(&amp;quot;:&amp;quot;);&lt;br /&gt;
  Serial.print(minute, DEC);&lt;br /&gt;
  Serial.print(&amp;quot;:&amp;quot;);&lt;br /&gt;
  Serial.print(second, DEC);&lt;br /&gt;
  Serial.print(&amp;quot;  &amp;quot;);&lt;br /&gt;
  Serial.print(month, DEC);&lt;br /&gt;
  Serial.print(&amp;quot;/&amp;quot;);&lt;br /&gt;
  Serial.print(dayOfMonth, DEC);&lt;br /&gt;
  Serial.print(&amp;quot;/&amp;quot;);&lt;br /&gt;
  Serial.print(year, DEC);&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
void setup() {&lt;br /&gt;
  Wire.begin();&lt;br /&gt;
  Serial.begin(57600);&lt;br /&gt;
  pinMode(duct1, OUTPUT);&lt;br /&gt;
  pinMode(duct2, OUTPUT);&lt;br /&gt;
  pinMode(duct3, OUTPUT);&lt;br /&gt;
  pinMode(duct4, OUTPUT);&lt;br /&gt;
  pinMode(ac_on, OUTPUT);&lt;br /&gt;
  pinMode(fan_on, OUTPUT);&lt;br /&gt;
  // Initialize Date/Time to update RTC DS1307 - You need to run the Q command right after you download this program&lt;br /&gt;
  // This is temporary until a more complex date time command is finished&lt;br /&gt;
  second = 15;&lt;br /&gt;
  minute = 41;&lt;br /&gt;
  hour = 12;&lt;br /&gt;
  dayOfWeek = 5;&lt;br /&gt;
  dayOfMonth = 5;&lt;br /&gt;
  month = 9;&lt;br /&gt;
  year = 8;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
void loop() {&lt;br /&gt;
  if (millis() - previousMillis &amp;gt; polltime) {&lt;br /&gt;
    previousMillis = millis();   // remember the last time&lt;br /&gt;
    if (millis() - ac_on_start &amp;gt; ac_on_delay) { &lt;br /&gt;
      if (digitalRead(duct1) || digitalRead(duct2) || digitalRead(duct3) || digitalRead(duct4)){  // If any ducts are turned on turn on the A/C&lt;br /&gt;
       if (digitalRead(ac_on) != HIGH) { // Check ac_on state&lt;br /&gt;
        digitalWrite(ac_on,HIGH);&lt;br /&gt;
        getDateDs1307();&lt;br /&gt;
        Serial.println(&amp;quot; - AC ON&amp;quot;);&lt;br /&gt;
       }&lt;br /&gt;
       ac_on_start = millis();&lt;br /&gt;
      } &lt;br /&gt;
      else if (digitalRead(ac_on) != LOW){ //Check ac_on state&lt;br /&gt;
       digitalWrite(ac_on,LOW);&lt;br /&gt;
       getDateDs1307();&lt;br /&gt;
       Serial.println(&amp;quot; - AC OFF&amp;quot;);&lt;br /&gt;
      }&lt;br /&gt;
    }&lt;br /&gt;
    temp1_val[val_cnt] = analogRead(temp1Pin);    // read the value from the sensors&lt;br /&gt;
    temp2_val[val_cnt] = analogRead(temp2Pin);&lt;br /&gt;
    temp3_val[val_cnt] = analogRead(temp3Pin);&lt;br /&gt;
    temp4_val[val_cnt] = analogRead(temp4Pin);&lt;br /&gt;
    val_cnt ++;&lt;br /&gt;
    if (val_cnt == 5) {&lt;br /&gt;
      val_cnt = 0;&lt;br /&gt;
    }&lt;br /&gt;
    temp1_avg = (temp1_val[0] + temp1_val[1] + temp1_val[2] + temp1_val[3] + temp1_val[4])/5;&lt;br /&gt;
    temp2_avg = (temp2_val[0] + temp2_val[1] + temp2_val[2] + temp2_val[3] + temp2_val[4])/5;&lt;br /&gt;
    temp3_avg = (temp3_val[0] + temp3_val[1] + temp3_val[2] + temp3_val[3] + temp3_val[4])/5;&lt;br /&gt;
    temp4_avg = (temp4_val[0] + temp4_val[1] + temp4_val[2] + temp4_val[3] + temp4_val[4])/5;&lt;br /&gt;
// Check Thresholds against the Temperatures and set the ducts HIGH or LOW    &lt;br /&gt;
    if (temp1_avg &amp;gt;= THRESHOLD1) {digitalWrite(duct1, HIGH);}&lt;br /&gt;
    else {digitalWrite(duct1, LOW);}&lt;br /&gt;
    if (temp2_avg &amp;gt;= THRESHOLD2) {digitalWrite(duct2, HIGH);}&lt;br /&gt;
    else {digitalWrite(duct2, LOW);}&lt;br /&gt;
    if (temp3_avg &amp;gt;= THRESHOLD3) {digitalWrite(duct3, HIGH);}&lt;br /&gt;
    else {digitalWrite(duct3, LOW);}&lt;br /&gt;
    if (temp4_avg &amp;gt;= THRESHOLD4) {digitalWrite(duct4, HIGH);}&lt;br /&gt;
    else {digitalWrite(duct4, LOW);}&lt;br /&gt;
    if (Serial.available()) {      // Look for char in serial que and process if found&lt;br /&gt;
      command = Serial.read();&lt;br /&gt;
      if (command == 84) {          // If command = &amp;quot;T&amp;quot; &lt;br /&gt;
        command = Serial.read();&lt;br /&gt;
        if (command == 49) {          // If command = &amp;quot;1&amp;quot; print the Temp1&lt;br /&gt;
         Serial.print(&amp;quot;Temp1 = &amp;quot;);&lt;br /&gt;
         Serial.print(temp1_avg);           // &lt;br /&gt;
         Serial.print(&amp;quot; &amp;quot;);&lt;br /&gt;
        }&lt;br /&gt;
        else if (command == 50) {      // If command = &amp;quot;2&amp;quot; print the Temp2&lt;br /&gt;
         Serial.print(&amp;quot;Temp2 = &amp;quot;);&lt;br /&gt;
         Serial.print(temp2_avg);           // &lt;br /&gt;
         Serial.print(&amp;quot; &amp;quot;);&lt;br /&gt;
        }&lt;br /&gt;
        else if (command == 51) {      // If command = &amp;quot;3&amp;quot; print the Temp3&lt;br /&gt;
         Serial.print(&amp;quot;Temp3 = &amp;quot;);&lt;br /&gt;
         Serial.print(temp3_avg);           // &lt;br /&gt;
         Serial.print(&amp;quot; &amp;quot;);&lt;br /&gt;
        }&lt;br /&gt;
        else if (command == 52) {      // If command = &amp;quot;4&amp;quot; print the Temp4&lt;br /&gt;
         Serial.print(&amp;quot;Temp4 = &amp;quot;);&lt;br /&gt;
         Serial.print(temp4_avg);           // &lt;br /&gt;
         Serial.print(&amp;quot; &amp;quot;);&lt;br /&gt;
         }&lt;br /&gt;
       }&lt;br /&gt;
      else if (command == 67) {      //If command = &amp;quot;C&amp;quot; Change Temp Threshhold&lt;br /&gt;
        if (Serial.available()) {&lt;br /&gt;
         command = Serial.read();&lt;br /&gt;
         if (command == 49) {        // If command = &amp;quot;1&amp;quot; print the THRESHOLD1&lt;br /&gt;
           command = Serial.read();&lt;br /&gt;
           if (command &amp;gt; 47 &amp;amp;&amp;amp; command &amp;lt; 58) {          // If command is between 0-9 Increment the Threshold by number sent&lt;br /&gt;
             THRESHOLD1 += command - 48;                 // ASCII math to get value sent   &lt;br /&gt;
                  Serial.print(&amp;quot;THRESHOLD1 = &amp;quot;);&lt;br /&gt;
                  Serial.print(THRESHOLD1);           // &lt;br /&gt;
                  Serial.print(&amp;quot; &amp;quot;);&lt;br /&gt;
           }&lt;br /&gt;
         }  &lt;br /&gt;
         else if (command == 50) {     // If command = &amp;quot;2&amp;quot; print the THRESHOLD2&lt;br /&gt;
           command = Serial.read();&lt;br /&gt;
           if (command &amp;gt; 47 &amp;amp;&amp;amp; command &amp;lt; 58) {          // If command is between 0-9 Increment the Threshold by number sent&lt;br /&gt;
             THRESHOLD2 += command - 48;                 // ASCII math to get value sent   &lt;br /&gt;
                  Serial.print(&amp;quot;THRESHOLD2 = &amp;quot;);&lt;br /&gt;
                  Serial.print(THRESHOLD2);           // &lt;br /&gt;
                  Serial.print(&amp;quot; &amp;quot;);&lt;br /&gt;
           }&lt;br /&gt;
         }&lt;br /&gt;
         else if (command == 51) {             // If command = &amp;quot;3&amp;quot; print the THRESHOLD3&lt;br /&gt;
           command = Serial.read();&lt;br /&gt;
           if (command &amp;gt; 47 &amp;amp;&amp;amp; command &amp;lt; 58) {          // If command is between 0-9 Increment the Threshold by number sent&lt;br /&gt;
             THRESHOLD3 += command - 48;                 // ASCII math to get value sent   &lt;br /&gt;
                  Serial.print(&amp;quot;THRESHOLD3 = &amp;quot;);&lt;br /&gt;
                  Serial.print(THRESHOLD3);           // &lt;br /&gt;
                  Serial.print(&amp;quot; &amp;quot;);&lt;br /&gt;
           }&lt;br /&gt;
         }&lt;br /&gt;
         else if (command == 52) {             // If command = &amp;quot;4&amp;quot; print the THRESHOLD4&lt;br /&gt;
           command = Serial.read();&lt;br /&gt;
           if (command &amp;gt; 47 &amp;amp;&amp;amp; command &amp;lt; 58) {          // If command is between 0-9 Increment the Threshold by number sent&lt;br /&gt;
             THRESHOLD4 += command - 48;                 // ASCII math to get value sent   &lt;br /&gt;
                  Serial.print(&amp;quot;THRESHOLD4 = &amp;quot;);&lt;br /&gt;
                  Serial.print(THRESHOLD4);           // &lt;br /&gt;
                  Serial.print(&amp;quot; &amp;quot;);&lt;br /&gt;
           }&lt;br /&gt;
         }          &lt;br /&gt;
        }  &lt;br /&gt;
      }&lt;br /&gt;
      else if (command == 68) {      //If command = &amp;quot;D&amp;quot; Change Temp Threshhold&lt;br /&gt;
        if (Serial.available()) {&lt;br /&gt;
         command = Serial.read();&lt;br /&gt;
         if (command == 49) {           // If command = &amp;quot;1&amp;quot; print the THRESHOLD1&lt;br /&gt;
           command = Serial.read();&lt;br /&gt;
           if (command &amp;gt; 47 &amp;amp;&amp;amp; command &amp;lt; 58) {          // If command is between 0-9 Decrement the Threshold by number sent&lt;br /&gt;
             THRESHOLD1 -= command - 48;                 // ASCII math to get value sent   &lt;br /&gt;
                  Serial.print(&amp;quot;THRESHOLD1 = &amp;quot;);&lt;br /&gt;
                  Serial.print(THRESHOLD1);           // &lt;br /&gt;
                  Serial.print(&amp;quot; &amp;quot;);&lt;br /&gt;
           }&lt;br /&gt;
         }  &lt;br /&gt;
         else if (command == 50) {               // If command = &amp;quot;2&amp;quot; print the THRESHOLD2&lt;br /&gt;
           command = Serial.read();&lt;br /&gt;
           if (command &amp;gt; 47 &amp;amp;&amp;amp; command &amp;lt; 58) {          // If command is between 0-9 Decrement the Threshold by number sent&lt;br /&gt;
             THRESHOLD2 -= command - 48;                 // ASCII math to get value sent   &lt;br /&gt;
                  Serial.print(&amp;quot;THRESHOLD2 = &amp;quot;);&lt;br /&gt;
                  Serial.print(THRESHOLD2);           // &lt;br /&gt;
                  Serial.print(&amp;quot; &amp;quot;);&lt;br /&gt;
           }&lt;br /&gt;
         }&lt;br /&gt;
         else if (command == 51) {              // If command = &amp;quot;3&amp;quot; print the THRESHOLD3&lt;br /&gt;
           command = Serial.read();&lt;br /&gt;
           if (command &amp;gt; 47 &amp;amp;&amp;amp; command &amp;lt; 58) {          // If command is between 0-9 Decrement the Threshold by number sent&lt;br /&gt;
             THRESHOLD3 -= command - 48;                 // ASCII math to get value sent   &lt;br /&gt;
                  Serial.print(&amp;quot;THRESHOLD3 = &amp;quot;);&lt;br /&gt;
                  Serial.print(THRESHOLD3);           // &lt;br /&gt;
                  Serial.print(&amp;quot; &amp;quot;);&lt;br /&gt;
           }&lt;br /&gt;
         }&lt;br /&gt;
         else if (command == 52) {                    // If command = &amp;quot;4&amp;quot; print the THRESHOLD4&lt;br /&gt;
           command = Serial.read();&lt;br /&gt;
           if (command &amp;gt; 47 &amp;amp;&amp;amp; command &amp;lt; 58) {          // If command is between 0-9 Decrement the Threshold by number sent&lt;br /&gt;
             THRESHOLD4 -= command - 48;                 // ASCII math to get value sent   &lt;br /&gt;
                  Serial.print(&amp;quot;THRESHOLD4 = &amp;quot;);&lt;br /&gt;
                  Serial.print(THRESHOLD4);           // &lt;br /&gt;
                  Serial.print(&amp;quot; &amp;quot;);&lt;br /&gt;
           }&lt;br /&gt;
         }           &lt;br /&gt;
        }  &lt;br /&gt;
      }&lt;br /&gt;
//****************  Warning - This is a potential for problem - Consider a manual lock out feature to lock out manual commands &lt;br /&gt;
//****************  Possibly create a command to open up manual commands for a certian time period then shut them off again automatically&lt;br /&gt;
      else if (command == 65) {      //If command = &amp;quot;A&amp;quot; Change Temp Threshhold&lt;br /&gt;
       if (Serial.available()) {&lt;br /&gt;
        command = Serial.read();&lt;br /&gt;
        if (command == 49) {        // If command = &amp;quot;1&amp;quot; print the AC ON message&lt;br /&gt;
         getDateDs1307();&lt;br /&gt;
         Serial.print(&amp;quot; - Manual AC ON &amp;quot;);&lt;br /&gt;
         ac_on_start = millis();   // Set the AC to a delay before it can be turned off again&lt;br /&gt;
         digitalWrite(ac_on,HIGH);&lt;br /&gt;
        }&lt;br /&gt;
        else if (command == 48) {        // If command = &amp;quot;0&amp;quot; print the AC OFF message&lt;br /&gt;
         getDateDs1307();&lt;br /&gt;
         Serial.print(&amp;quot; - Manual AC OFF &amp;quot;);&lt;br /&gt;
         digitalWrite(ac_on,LOW);&lt;br /&gt;
        }&lt;br /&gt;
       } &lt;br /&gt;
      } &lt;br /&gt;
      else if (command == 70) {      //If command = &amp;quot;F&amp;quot; Change Temp Threshhold&lt;br /&gt;
       if (Serial.available()) {&lt;br /&gt;
        command = Serial.read();&lt;br /&gt;
        if (command == 49) {        // If command = &amp;quot;1&amp;quot; print the FAN ON message&lt;br /&gt;
         getDateDs1307();&lt;br /&gt;
         Serial.print(&amp;quot; - Manual FAN ON &amp;quot;);&lt;br /&gt;
         ac_on_start = millis();&lt;br /&gt;
         digitalWrite(fan_on,HIGH);&lt;br /&gt;
        }&lt;br /&gt;
        else if (command == 48) {        // If command = &amp;quot;0&amp;quot; print the FAN OFF message&lt;br /&gt;
         getDateDs1307();&lt;br /&gt;
         Serial.print(&amp;quot; - Manual FAN OFF &amp;quot;);&lt;br /&gt;
         digitalWrite(fan_on,LOW);&lt;br /&gt;
        }&lt;br /&gt;
       } &lt;br /&gt;
      }&lt;br /&gt;
//********************** End of Warning Zone *******************************&lt;br /&gt;
&lt;br /&gt;
// ***************  This Section Will list the Staus of the Controller&lt;br /&gt;
      else if (command == 83) {      //If command = &amp;quot;S&amp;quot; Print Controller Status&lt;br /&gt;
        getDateDs1307();&lt;br /&gt;
        Serial.println(&amp;quot; &amp;quot;);&lt;br /&gt;
        Serial.println(&amp;quot; &amp;quot;);&lt;br /&gt;
        Serial.print(&amp;quot;Temp1 = &amp;quot;);&lt;br /&gt;
        Serial.println(temp1_avg);   &lt;br /&gt;
        Serial.print(&amp;quot;Temp2 = &amp;quot;);&lt;br /&gt;
        Serial.println(temp2_avg);&lt;br /&gt;
        Serial.print(&amp;quot;Temp3 = &amp;quot;);&lt;br /&gt;
        Serial.println(temp3_avg);   &lt;br /&gt;
        Serial.print(&amp;quot;Temp4 = &amp;quot;);&lt;br /&gt;
        Serial.println(temp4_avg);   &lt;br /&gt;
        Serial.println(&amp;quot; &amp;quot;);&lt;br /&gt;
        Serial.print(&amp;quot;THRESHOLD1 = &amp;quot;);&lt;br /&gt;
        Serial.println(THRESHOLD1);   &lt;br /&gt;
        Serial.print(&amp;quot;THRESHOLD2 = &amp;quot;);&lt;br /&gt;
        Serial.println(THRESHOLD2); &lt;br /&gt;
        Serial.print(&amp;quot;THRESHOLD3 = &amp;quot;);&lt;br /&gt;
        Serial.println(THRESHOLD3); &lt;br /&gt;
        Serial.print(&amp;quot;THRESHOLD4 = &amp;quot;);&lt;br /&gt;
        Serial.println(THRESHOLD4);&lt;br /&gt;
        Serial.println(&amp;quot; &amp;quot;);&lt;br /&gt;
        if (digitalRead(duct1) == HIGH) {Serial.println(&amp;quot;duct1 ON&amp;quot;);}&lt;br /&gt;
        else{Serial.println(&amp;quot;duct1 OFF&amp;quot;);}&lt;br /&gt;
        if (digitalRead(duct2) == HIGH) {Serial.println(&amp;quot;duct2 ON&amp;quot;);}&lt;br /&gt;
        else{Serial.println(&amp;quot;duct2 OFF&amp;quot;);}&lt;br /&gt;
        if (digitalRead(duct3) == HIGH) {Serial.println(&amp;quot;duct3 ON&amp;quot;);}&lt;br /&gt;
        else{Serial.println(&amp;quot;duct3 OFF&amp;quot;);}&lt;br /&gt;
        if (digitalRead(duct4) == HIGH) {Serial.println(&amp;quot;duct4 ON&amp;quot;);}&lt;br /&gt;
        else{Serial.println(&amp;quot;duct4 OFF&amp;quot;);}&lt;br /&gt;
        Serial.println(&amp;quot; &amp;quot;);&lt;br /&gt;
        if (digitalRead(fan_on) == HIGH) {Serial.println(&amp;quot;Fan ON&amp;quot;);}&lt;br /&gt;
        else{Serial.println(&amp;quot;Fan OFF&amp;quot;);}&lt;br /&gt;
        if (digitalRead(ac_on) == HIGH) {Serial.println(&amp;quot;AC  ON&amp;quot;);}&lt;br /&gt;
        else{Serial.println(&amp;quot;AC  OFF&amp;quot;);}&lt;br /&gt;
        Serial.print(&amp;quot;A/C Delay (millisec) = &amp;quot;);&lt;br /&gt;
        Serial.println(ac_on_delay);&lt;br /&gt;
        Serial.print(&amp;quot;Temp Polling (millisec) = &amp;quot;);&lt;br /&gt;
        Serial.println(polltime);          &lt;br /&gt;
        Serial.println(&amp;quot; &amp;quot;);&lt;br /&gt;
        &lt;br /&gt;
      }&lt;br /&gt;
      else if (command == 81) {      //If command = &amp;quot;Q&amp;quot; Set Date&lt;br /&gt;
       setDateDs1307();&lt;br /&gt;
       getDateDs1307();&lt;br /&gt;
       Serial.println(&amp;quot; &amp;quot;);&lt;br /&gt;
      }&lt;br /&gt;
      Serial.println(command);     // Echo command char found in serial que&lt;br /&gt;
      command = 0;                 // reset command &lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
//*****************************************************The End***********************&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== A/C_Control_v.01 User Guide ==&lt;br /&gt;
==== Commands ====&lt;br /&gt;
== Troubleshooting ==&lt;br /&gt;
=== Summary ===&lt;br /&gt;
When Troubleshooting a multi-functional issue, it is best practice to break down the issue into pieces and test each piece as a separate system.  However, we will first run through a quick test to see if we can find any obvious issues first.&lt;br /&gt;
=== Quick Test ===&lt;/div&gt;</summary>
		<author><name>Combustor</name></author>	</entry>

	<entry>
		<id>http://combustory.com/wiki/index.php/Temperature_Controller</id>
		<title>Temperature Controller</title>
		<link rel="alternate" type="text/html" href="http://combustory.com/wiki/index.php/Temperature_Controller"/>
				<updated>2008-09-10T19:03:28Z</updated>
		
		<summary type="html">&lt;p&gt;Combustor: /* Example of Method */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{default}}&lt;br /&gt;
== Warning ==&lt;br /&gt;
'''This page is in progress and none of the code can be considered good or complete. I am just using this as an alternate storage of the code for right now.'''&lt;br /&gt;
&lt;br /&gt;
== Summary ==&lt;br /&gt;
== Functional Description of the Method ==&lt;br /&gt;
== Requirements ==&lt;br /&gt;
== Example of Method ==&lt;br /&gt;
=== Quick Guide: ===&lt;br /&gt;
=== Detailed Guide: ===&lt;br /&gt;
=== I2C ===&lt;br /&gt;
==== X9241A - Digital Potentiometer ====&lt;br /&gt;
&lt;br /&gt;
There are basically only two functions that I am after right now which are both three byte instructions: (So far this is failing miserably)&lt;br /&gt;
&lt;br /&gt;
* Read WCR(Wiper Control Register) for the four potentiometers 0-3 &lt;br /&gt;
** Send 1st byte - Address (my circuit - 01011010 or 0x2D)(binary - 0101 A3 A2 A1 A0) A values are actual pins set to high or low for an address.&lt;br /&gt;
** Send 2nd byte - Instruction (binary - 1001 (1/0)(1/0) 00) - The two bits are used to choose the potentiometer&lt;br /&gt;
** Read WCR requested Byte&lt;br /&gt;
* Write WCR for the four potentiometers 0-3&lt;br /&gt;
** Send 1st byte - Address (my circuit - 01011010 or 0x2D)(binary - 0101 A3 A2 A1 A0) A values are actual pins set to high or low for an address.&lt;br /&gt;
** Send 2nd byte - Instruction (binary - 1010 (1/0)(1/0) 00) - The two bits are used to choose the potentiometer&lt;br /&gt;
** Send WCR Byte - Potentiometer value (binary - 00 D5 D4 D3 D2 D1 D0) - D values are the 0-63 potentiometer positions&lt;br /&gt;
&lt;br /&gt;
==== DS1307 - Real Time Clock ====&lt;br /&gt;
&lt;br /&gt;
The code for this very useful chip came from the [[http://www.glacialwanderer.com/hobbyrobotics/?p=12 Glacial Wanderer]]&lt;br /&gt;
&lt;br /&gt;
==== A/C_Control_v.01 code ====&lt;br /&gt;
&lt;br /&gt;
''' While this says v.01, don't count on it being a released v.01, I am still working on v.01, this is a back up '''&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
/*&lt;br /&gt;
 * A/C Control v.01&lt;br /&gt;
 * by &amp;lt;http://www.combustory.com&amp;gt; John Vaughters&lt;br /&gt;
 * Credit to:&lt;br /&gt;
 * Maurice Ribble - http://www.glacialwanderer.com/hobbyrobotics for RTC DS1307 code&lt;br /&gt;
 *&lt;br /&gt;
 * Turns on an LED for temperatures from analog pins 1-5 on&lt;br /&gt;
 * digital pins 2-6 when the temperature rises above the THRESHOLDS 1-5.&lt;br /&gt;
 * The program also implements a &lt;br /&gt;
 * Serial Communication method that utilizes a leading CHAR for each command Described below. &lt;br /&gt;
 * Commands:&lt;br /&gt;
 * T(1-4) - Temp1-5 Status ex. T1, T2, etc&lt;br /&gt;
 * C(1-4)(0-9) - Increment THRESHOLD1-4 by (1-9) ex. C15 increments THRESHOLD1 BY 5 (Note: C40 will give you a status of THRESHOLD4)&lt;br /&gt;
 * D(1-4)(0-9) - Decrement THRESHOLD1-4 by (1-9) ex. D59 decrements THRESHOLD5 BY 9 (Note: D10 will give you a status of THRESHOLD1)&lt;br /&gt;
 * A(0-1) - Manual AC on command A1 is AC on, A0 is AC off&lt;br /&gt;
 * F(0-1) - Manual AC on command A1 is FAN on, A0 is FAN off &lt;br /&gt;
 * Q - Q Sets the date of the RTC DS1307 Chip&lt;br /&gt;
 */&lt;br /&gt;
&lt;br /&gt;
#include &amp;quot;Wire.h&amp;quot;&lt;br /&gt;
#define DS1307_I2C_ADDRESS 0x68&lt;br /&gt;
&lt;br /&gt;
// Global Variables&lt;br /&gt;
int val_cnt = 0;               // counter for the temp_val                   &lt;br /&gt;
int temp1Pin = 0;    // select the input pin for the Thermistor&lt;br /&gt;
int temp2Pin = 1;    // select the input pin for the Thermistor&lt;br /&gt;
int temp3Pin = 2;    // select the input pin for the Thermistor&lt;br /&gt;
int temp4Pin = 3;    // select the input pin for the Thermistor&lt;br /&gt;
int temp1_val[5] = {0,0,0,0,0};       // variable to store the value coming from the sensor&lt;br /&gt;
int temp2_val[5] = {0,0,0,0,0};       //           &lt;br /&gt;
int temp3_val[5] = {0,0,0,0,0};       //&lt;br /&gt;
int temp4_val[5] = {0,0,0,0,0};       //&lt;br /&gt;
int temp1_avg;                   // average over poll time of the temp values&lt;br /&gt;
int temp2_avg;&lt;br /&gt;
int temp3_avg;&lt;br /&gt;
int temp4_avg;&lt;br /&gt;
int duct1 = 2;                   // Ducts open or close using a digital output&lt;br /&gt;
int duct2 = 3;&lt;br /&gt;
int duct3 = 4;&lt;br /&gt;
int duct4 = 5;&lt;br /&gt;
int THRESHOLD1 = 580;    // Default theshold values&lt;br /&gt;
int THRESHOLD2 = 580;&lt;br /&gt;
int THRESHOLD3 = 580;&lt;br /&gt;
int THRESHOLD4 = 580;&lt;br /&gt;
int ac_on = 13;&lt;br /&gt;
int fan_on = 12;&lt;br /&gt;
int command = 0;       // This is the command char, in ascii form, sent from the serial port     &lt;br /&gt;
long polltime = 1000;  // The time to Poll the tempPins&lt;br /&gt;
long previousMillis = 0;        // will store last time Temp was updated&lt;br /&gt;
long ac_on_start = 0;     // Start A/C delay timer&lt;br /&gt;
long ac_on_delay = 10000;   // Time to wait before checking the ducts again&lt;br /&gt;
byte second, minute, hour, dayOfWeek, dayOfMonth, month, year;&lt;br /&gt;
&lt;br /&gt;
  &lt;br /&gt;
// Convert normal decimal numbers to binary coded decimal&lt;br /&gt;
byte decToBcd(byte val)&lt;br /&gt;
{&lt;br /&gt;
  return ( (val/10*16) + (val%10) );&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
// Convert binary coded decimal to normal decimal numbers&lt;br /&gt;
byte bcdToDec(byte val)&lt;br /&gt;
{&lt;br /&gt;
  return ( (val/16*10) + (val%16) );&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
// 1) Sets the date and time on the ds1307&lt;br /&gt;
// 2) Starts the clock&lt;br /&gt;
// 3) Sets hour mode to 24 hour clock&lt;br /&gt;
// Assumes you're passing in valid numbers&lt;br /&gt;
// Watch for scope issues with Global Variables&lt;br /&gt;
/*void setDateDs1307(byte second,        // 0-59&lt;br /&gt;
                   byte minute,        // 0-59&lt;br /&gt;
                   byte hour,          // 1-23&lt;br /&gt;
                   byte dayOfWeek,     // 1-7&lt;br /&gt;
                   byte dayOfMonth,    // 1-28/29/30/31&lt;br /&gt;
                   byte month,         // 1-12&lt;br /&gt;
                   byte year)          // 0-99*/&lt;br /&gt;
void setDateDs1307()                &lt;br /&gt;
{&lt;br /&gt;
   Wire.beginTransmission(DS1307_I2C_ADDRESS);&lt;br /&gt;
   Wire.send(0);&lt;br /&gt;
   Wire.send(decToBcd(second));    // 0 to bit 7 starts the clock&lt;br /&gt;
   Wire.send(decToBcd(minute));&lt;br /&gt;
   Wire.send(decToBcd(hour));      // If you want 12 hour am/pm you need to set&lt;br /&gt;
                                   // bit 6 (also need to change readDateDs1307)&lt;br /&gt;
   Wire.send(decToBcd(dayOfWeek));&lt;br /&gt;
   Wire.send(decToBcd(dayOfMonth));&lt;br /&gt;
   Wire.send(decToBcd(month));&lt;br /&gt;
   Wire.send(decToBcd(year));&lt;br /&gt;
   Wire.endTransmission();&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
// Gets the date and time from the ds1307 and prints result&lt;br /&gt;
// Watch for scope issues with Global Variables&lt;br /&gt;
void getDateDs1307()&lt;br /&gt;
{&lt;br /&gt;
  // Reset the register pointer&lt;br /&gt;
  Wire.beginTransmission(DS1307_I2C_ADDRESS);&lt;br /&gt;
  Wire.send(0);&lt;br /&gt;
  Wire.endTransmission();&lt;br /&gt;
&lt;br /&gt;
  Wire.requestFrom(DS1307_I2C_ADDRESS, 7);&lt;br /&gt;
&lt;br /&gt;
  // A few of these need masks because certain bits are control bits&lt;br /&gt;
  second     = bcdToDec(Wire.receive() &amp;amp; 0x7f);&lt;br /&gt;
  minute     = bcdToDec(Wire.receive());&lt;br /&gt;
  hour       = bcdToDec(Wire.receive() &amp;amp; 0x3f);  // Need to change this if 12 hour am/pm&lt;br /&gt;
  dayOfWeek  = bcdToDec(Wire.receive());&lt;br /&gt;
  dayOfMonth = bcdToDec(Wire.receive());&lt;br /&gt;
  month      = bcdToDec(Wire.receive());&lt;br /&gt;
  year       = bcdToDec(Wire.receive());&lt;br /&gt;
  &lt;br /&gt;
  Serial.print(hour, DEC);&lt;br /&gt;
  Serial.print(&amp;quot;:&amp;quot;);&lt;br /&gt;
  Serial.print(minute, DEC);&lt;br /&gt;
  Serial.print(&amp;quot;:&amp;quot;);&lt;br /&gt;
  Serial.print(second, DEC);&lt;br /&gt;
  Serial.print(&amp;quot;  &amp;quot;);&lt;br /&gt;
  Serial.print(month, DEC);&lt;br /&gt;
  Serial.print(&amp;quot;/&amp;quot;);&lt;br /&gt;
  Serial.print(dayOfMonth, DEC);&lt;br /&gt;
  Serial.print(&amp;quot;/&amp;quot;);&lt;br /&gt;
  Serial.print(year, DEC);&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
void setup() {&lt;br /&gt;
  Wire.begin();&lt;br /&gt;
  Serial.begin(57600);&lt;br /&gt;
  pinMode(duct1, OUTPUT);&lt;br /&gt;
  pinMode(duct2, OUTPUT);&lt;br /&gt;
  pinMode(duct3, OUTPUT);&lt;br /&gt;
  pinMode(duct4, OUTPUT);&lt;br /&gt;
  pinMode(ac_on, OUTPUT);&lt;br /&gt;
  pinMode(fan_on, OUTPUT);&lt;br /&gt;
  // Initialize Date/Time to update RTC DS1307 - You need to run the Q command right after you download this program&lt;br /&gt;
  // This is temporary until a more complex date time command is finished&lt;br /&gt;
  second = 15;&lt;br /&gt;
  minute = 41;&lt;br /&gt;
  hour = 12;&lt;br /&gt;
  dayOfWeek = 5;&lt;br /&gt;
  dayOfMonth = 5;&lt;br /&gt;
  month = 9;&lt;br /&gt;
  year = 8;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
void loop() {&lt;br /&gt;
  if (millis() - previousMillis &amp;gt; polltime) {&lt;br /&gt;
    previousMillis = millis();   // remember the last time&lt;br /&gt;
    if (millis() - ac_on_start &amp;gt; ac_on_delay) { &lt;br /&gt;
      if (digitalRead(duct1) || digitalRead(duct2) || digitalRead(duct3) || digitalRead(duct4)){  // If any ducts are turned on turn on the A/C&lt;br /&gt;
       if (digitalRead(ac_on) != HIGH) { // Check ac_on state&lt;br /&gt;
        digitalWrite(ac_on,HIGH);&lt;br /&gt;
        getDateDs1307();&lt;br /&gt;
        Serial.println(&amp;quot; - AC ON&amp;quot;);&lt;br /&gt;
       }&lt;br /&gt;
       ac_on_start = millis();&lt;br /&gt;
      } &lt;br /&gt;
      else if (digitalRead(ac_on) != LOW){ //Check ac_on state&lt;br /&gt;
       digitalWrite(ac_on,LOW);&lt;br /&gt;
       getDateDs1307();&lt;br /&gt;
       Serial.println(&amp;quot; - AC OFF&amp;quot;);&lt;br /&gt;
      }&lt;br /&gt;
    }&lt;br /&gt;
    temp1_val[val_cnt] = analogRead(temp1Pin);    // read the value from the sensors&lt;br /&gt;
    temp2_val[val_cnt] = analogRead(temp2Pin);&lt;br /&gt;
    temp3_val[val_cnt] = analogRead(temp3Pin);&lt;br /&gt;
    temp4_val[val_cnt] = analogRead(temp4Pin);&lt;br /&gt;
    val_cnt ++;&lt;br /&gt;
    if (val_cnt == 5) {&lt;br /&gt;
      val_cnt = 0;&lt;br /&gt;
    }&lt;br /&gt;
    temp1_avg = (temp1_val[0] + temp1_val[1] + temp1_val[2] + temp1_val[3] + temp1_val[4])/5;&lt;br /&gt;
    temp2_avg = (temp2_val[0] + temp2_val[1] + temp2_val[2] + temp2_val[3] + temp2_val[4])/5;&lt;br /&gt;
    temp3_avg = (temp3_val[0] + temp3_val[1] + temp3_val[2] + temp3_val[3] + temp3_val[4])/5;&lt;br /&gt;
    temp4_avg = (temp4_val[0] + temp4_val[1] + temp4_val[2] + temp4_val[3] + temp4_val[4])/5;&lt;br /&gt;
// Check Thresholds against the Temperatures and set the ducts HIGH or LOW    &lt;br /&gt;
    if (temp1_avg &amp;gt;= THRESHOLD1) {digitalWrite(duct1, HIGH);}&lt;br /&gt;
    else {digitalWrite(duct1, LOW);}&lt;br /&gt;
    if (temp2_avg &amp;gt;= THRESHOLD2) {digitalWrite(duct2, HIGH);}&lt;br /&gt;
    else {digitalWrite(duct2, LOW);}&lt;br /&gt;
    if (temp3_avg &amp;gt;= THRESHOLD3) {digitalWrite(duct3, HIGH);}&lt;br /&gt;
    else {digitalWrite(duct3, LOW);}&lt;br /&gt;
    if (temp4_avg &amp;gt;= THRESHOLD4) {digitalWrite(duct4, HIGH);}&lt;br /&gt;
    else {digitalWrite(duct4, LOW);}&lt;br /&gt;
    if (Serial.available()) {      // Look for char in serial que and process if found&lt;br /&gt;
      command = Serial.read();&lt;br /&gt;
      if (command == 84) {          // If command = &amp;quot;T&amp;quot; &lt;br /&gt;
        command = Serial.read();&lt;br /&gt;
        if (command == 49) {          // If command = &amp;quot;1&amp;quot; print the Temp1&lt;br /&gt;
         Serial.print(&amp;quot;Temp1 = &amp;quot;);&lt;br /&gt;
         Serial.print(temp1_avg);           // &lt;br /&gt;
         Serial.print(&amp;quot; &amp;quot;);&lt;br /&gt;
        }&lt;br /&gt;
        else if (command == 50) {      // If command = &amp;quot;2&amp;quot; print the Temp2&lt;br /&gt;
         Serial.print(&amp;quot;Temp2 = &amp;quot;);&lt;br /&gt;
         Serial.print(temp2_avg);           // &lt;br /&gt;
         Serial.print(&amp;quot; &amp;quot;);&lt;br /&gt;
        }&lt;br /&gt;
        else if (command == 51) {      // If command = &amp;quot;3&amp;quot; print the Temp3&lt;br /&gt;
         Serial.print(&amp;quot;Temp3 = &amp;quot;);&lt;br /&gt;
         Serial.print(temp3_avg);           // &lt;br /&gt;
         Serial.print(&amp;quot; &amp;quot;);&lt;br /&gt;
        }&lt;br /&gt;
        else if (command == 52) {      // If command = &amp;quot;4&amp;quot; print the Temp4&lt;br /&gt;
         Serial.print(&amp;quot;Temp4 = &amp;quot;);&lt;br /&gt;
         Serial.print(temp4_avg);           // &lt;br /&gt;
         Serial.print(&amp;quot; &amp;quot;);&lt;br /&gt;
         }&lt;br /&gt;
       }&lt;br /&gt;
      else if (command == 67) {      //If command = &amp;quot;C&amp;quot; Change Temp Threshhold&lt;br /&gt;
        if (Serial.available()) {&lt;br /&gt;
         command = Serial.read();&lt;br /&gt;
         if (command == 49) {        // If command = &amp;quot;1&amp;quot; print the THRESHOLD1&lt;br /&gt;
           command = Serial.read();&lt;br /&gt;
           if (command &amp;gt; 47 &amp;amp;&amp;amp; command &amp;lt; 58) {          // If command is between 0-9 Increment the Threshold by number sent&lt;br /&gt;
             THRESHOLD1 += command - 48;                 // ASCII math to get value sent   &lt;br /&gt;
                  Serial.print(&amp;quot;THRESHOLD1 = &amp;quot;);&lt;br /&gt;
                  Serial.print(THRESHOLD1);           // &lt;br /&gt;
                  Serial.print(&amp;quot; &amp;quot;);&lt;br /&gt;
           }&lt;br /&gt;
         }  &lt;br /&gt;
         else if (command == 50) {     // If command = &amp;quot;2&amp;quot; print the THRESHOLD2&lt;br /&gt;
           command = Serial.read();&lt;br /&gt;
           if (command &amp;gt; 47 &amp;amp;&amp;amp; command &amp;lt; 58) {          // If command is between 0-9 Increment the Threshold by number sent&lt;br /&gt;
             THRESHOLD2 += command - 48;                 // ASCII math to get value sent   &lt;br /&gt;
                  Serial.print(&amp;quot;THRESHOLD2 = &amp;quot;);&lt;br /&gt;
                  Serial.print(THRESHOLD2);           // &lt;br /&gt;
                  Serial.print(&amp;quot; &amp;quot;);&lt;br /&gt;
           }&lt;br /&gt;
         }&lt;br /&gt;
         else if (command == 51) {             // If command = &amp;quot;3&amp;quot; print the THRESHOLD3&lt;br /&gt;
           command = Serial.read();&lt;br /&gt;
           if (command &amp;gt; 47 &amp;amp;&amp;amp; command &amp;lt; 58) {          // If command is between 0-9 Increment the Threshold by number sent&lt;br /&gt;
             THRESHOLD3 += command - 48;                 // ASCII math to get value sent   &lt;br /&gt;
                  Serial.print(&amp;quot;THRESHOLD3 = &amp;quot;);&lt;br /&gt;
                  Serial.print(THRESHOLD3);           // &lt;br /&gt;
                  Serial.print(&amp;quot; &amp;quot;);&lt;br /&gt;
           }&lt;br /&gt;
         }&lt;br /&gt;
         else if (command == 52) {             // If command = &amp;quot;4&amp;quot; print the THRESHOLD4&lt;br /&gt;
           command = Serial.read();&lt;br /&gt;
           if (command &amp;gt; 47 &amp;amp;&amp;amp; command &amp;lt; 58) {          // If command is between 0-9 Increment the Threshold by number sent&lt;br /&gt;
             THRESHOLD4 += command - 48;                 // ASCII math to get value sent   &lt;br /&gt;
                  Serial.print(&amp;quot;THRESHOLD4 = &amp;quot;);&lt;br /&gt;
                  Serial.print(THRESHOLD4);           // &lt;br /&gt;
                  Serial.print(&amp;quot; &amp;quot;);&lt;br /&gt;
           }&lt;br /&gt;
         }          &lt;br /&gt;
        }  &lt;br /&gt;
      }&lt;br /&gt;
      else if (command == 68) {      //If command = &amp;quot;D&amp;quot; Change Temp Threshhold&lt;br /&gt;
        if (Serial.available()) {&lt;br /&gt;
         command = Serial.read();&lt;br /&gt;
         if (command == 49) {           // If command = &amp;quot;1&amp;quot; print the THRESHOLD1&lt;br /&gt;
           command = Serial.read();&lt;br /&gt;
           if (command &amp;gt; 47 &amp;amp;&amp;amp; command &amp;lt; 58) {          // If command is between 0-9 Decrement the Threshold by number sent&lt;br /&gt;
             THRESHOLD1 -= command - 48;                 // ASCII math to get value sent   &lt;br /&gt;
                  Serial.print(&amp;quot;THRESHOLD1 = &amp;quot;);&lt;br /&gt;
                  Serial.print(THRESHOLD1);           // &lt;br /&gt;
                  Serial.print(&amp;quot; &amp;quot;);&lt;br /&gt;
           }&lt;br /&gt;
         }  &lt;br /&gt;
         else if (command == 50) {               // If command = &amp;quot;2&amp;quot; print the THRESHOLD2&lt;br /&gt;
           command = Serial.read();&lt;br /&gt;
           if (command &amp;gt; 47 &amp;amp;&amp;amp; command &amp;lt; 58) {          // If command is between 0-9 Decrement the Threshold by number sent&lt;br /&gt;
             THRESHOLD2 -= command - 48;                 // ASCII math to get value sent   &lt;br /&gt;
                  Serial.print(&amp;quot;THRESHOLD2 = &amp;quot;);&lt;br /&gt;
                  Serial.print(THRESHOLD2);           // &lt;br /&gt;
                  Serial.print(&amp;quot; &amp;quot;);&lt;br /&gt;
           }&lt;br /&gt;
         }&lt;br /&gt;
         else if (command == 51) {              // If command = &amp;quot;3&amp;quot; print the THRESHOLD3&lt;br /&gt;
           command = Serial.read();&lt;br /&gt;
           if (command &amp;gt; 47 &amp;amp;&amp;amp; command &amp;lt; 58) {          // If command is between 0-9 Decrement the Threshold by number sent&lt;br /&gt;
             THRESHOLD3 -= command - 48;                 // ASCII math to get value sent   &lt;br /&gt;
                  Serial.print(&amp;quot;THRESHOLD3 = &amp;quot;);&lt;br /&gt;
                  Serial.print(THRESHOLD3);           // &lt;br /&gt;
                  Serial.print(&amp;quot; &amp;quot;);&lt;br /&gt;
           }&lt;br /&gt;
         }&lt;br /&gt;
         else if (command == 52) {                    // If command = &amp;quot;4&amp;quot; print the THRESHOLD4&lt;br /&gt;
           command = Serial.read();&lt;br /&gt;
           if (command &amp;gt; 47 &amp;amp;&amp;amp; command &amp;lt; 58) {          // If command is between 0-9 Decrement the Threshold by number sent&lt;br /&gt;
             THRESHOLD4 -= command - 48;                 // ASCII math to get value sent   &lt;br /&gt;
                  Serial.print(&amp;quot;THRESHOLD4 = &amp;quot;);&lt;br /&gt;
                  Serial.print(THRESHOLD4);           // &lt;br /&gt;
                  Serial.print(&amp;quot; &amp;quot;);&lt;br /&gt;
           }&lt;br /&gt;
         }           &lt;br /&gt;
        }  &lt;br /&gt;
      }&lt;br /&gt;
//****************  Warning - This is a potential for problem - Consider a manual lock out feature to lock out manual commands &lt;br /&gt;
//****************  Possibly create a command to open up manual commands for a certian time period then shut them off again automatically&lt;br /&gt;
      else if (command == 65) {      //If command = &amp;quot;A&amp;quot; Change Temp Threshhold&lt;br /&gt;
       if (Serial.available()) {&lt;br /&gt;
        command = Serial.read();&lt;br /&gt;
        if (command == 49) {        // If command = &amp;quot;1&amp;quot; print the AC ON message&lt;br /&gt;
         getDateDs1307();&lt;br /&gt;
         Serial.print(&amp;quot; - Manual AC ON &amp;quot;);&lt;br /&gt;
         ac_on_start = millis();   // Set the AC to a delay before it can be turned off again&lt;br /&gt;
         digitalWrite(ac_on,HIGH);&lt;br /&gt;
        }&lt;br /&gt;
        else if (command == 48) {        // If command = &amp;quot;0&amp;quot; print the AC OFF message&lt;br /&gt;
         getDateDs1307();&lt;br /&gt;
         Serial.print(&amp;quot; - Manual AC OFF &amp;quot;);&lt;br /&gt;
         digitalWrite(ac_on,LOW);&lt;br /&gt;
        }&lt;br /&gt;
       } &lt;br /&gt;
      } &lt;br /&gt;
      else if (command == 70) {      //If command = &amp;quot;F&amp;quot; Change Temp Threshhold&lt;br /&gt;
       if (Serial.available()) {&lt;br /&gt;
        command = Serial.read();&lt;br /&gt;
        if (command == 49) {        // If command = &amp;quot;1&amp;quot; print the FAN ON message&lt;br /&gt;
         getDateDs1307();&lt;br /&gt;
         Serial.print(&amp;quot; - Manual FAN ON &amp;quot;);&lt;br /&gt;
         ac_on_start = millis();&lt;br /&gt;
         digitalWrite(fan_on,HIGH);&lt;br /&gt;
        }&lt;br /&gt;
        else if (command == 48) {        // If command = &amp;quot;0&amp;quot; print the FAN OFF message&lt;br /&gt;
         getDateDs1307();&lt;br /&gt;
         Serial.print(&amp;quot; - Manual FAN OFF &amp;quot;);&lt;br /&gt;
         digitalWrite(fan_on,LOW);&lt;br /&gt;
        }&lt;br /&gt;
       } &lt;br /&gt;
      }&lt;br /&gt;
//********************** End of Warning Zone *******************************&lt;br /&gt;
&lt;br /&gt;
// ***************  This Section Will list the Staus of the Controller&lt;br /&gt;
      else if (command == 83) {      //If command = &amp;quot;S&amp;quot; Print Controller Status&lt;br /&gt;
        getDateDs1307();&lt;br /&gt;
        Serial.println(&amp;quot; &amp;quot;);&lt;br /&gt;
        Serial.println(&amp;quot; &amp;quot;);&lt;br /&gt;
        Serial.print(&amp;quot;Temp1 = &amp;quot;);&lt;br /&gt;
        Serial.println(temp1_avg);   &lt;br /&gt;
        Serial.print(&amp;quot;Temp2 = &amp;quot;);&lt;br /&gt;
        Serial.println(temp2_avg);&lt;br /&gt;
        Serial.print(&amp;quot;Temp3 = &amp;quot;);&lt;br /&gt;
        Serial.println(temp3_avg);   &lt;br /&gt;
        Serial.print(&amp;quot;Temp4 = &amp;quot;);&lt;br /&gt;
        Serial.println(temp4_avg);   &lt;br /&gt;
        Serial.println(&amp;quot; &amp;quot;);&lt;br /&gt;
        Serial.print(&amp;quot;THRESHOLD1 = &amp;quot;);&lt;br /&gt;
        Serial.println(THRESHOLD1);   &lt;br /&gt;
        Serial.print(&amp;quot;THRESHOLD2 = &amp;quot;);&lt;br /&gt;
        Serial.println(THRESHOLD2); &lt;br /&gt;
        Serial.print(&amp;quot;THRESHOLD3 = &amp;quot;);&lt;br /&gt;
        Serial.println(THRESHOLD3); &lt;br /&gt;
        Serial.print(&amp;quot;THRESHOLD4 = &amp;quot;);&lt;br /&gt;
        Serial.println(THRESHOLD4);&lt;br /&gt;
        Serial.println(&amp;quot; &amp;quot;);&lt;br /&gt;
        if (digitalRead(duct1) == HIGH) {Serial.println(&amp;quot;duct1 ON&amp;quot;);}&lt;br /&gt;
        else{Serial.println(&amp;quot;duct1 OFF&amp;quot;);}&lt;br /&gt;
        if (digitalRead(duct2) == HIGH) {Serial.println(&amp;quot;duct2 ON&amp;quot;);}&lt;br /&gt;
        else{Serial.println(&amp;quot;duct2 OFF&amp;quot;);}&lt;br /&gt;
        if (digitalRead(duct3) == HIGH) {Serial.println(&amp;quot;duct3 ON&amp;quot;);}&lt;br /&gt;
        else{Serial.println(&amp;quot;duct3 OFF&amp;quot;);}&lt;br /&gt;
        if (digitalRead(duct4) == HIGH) {Serial.println(&amp;quot;duct4 ON&amp;quot;);}&lt;br /&gt;
        else{Serial.println(&amp;quot;duct4 OFF&amp;quot;);}&lt;br /&gt;
        Serial.println(&amp;quot; &amp;quot;);&lt;br /&gt;
        if (digitalRead(fan_on) == HIGH) {Serial.println(&amp;quot;Fan ON&amp;quot;);}&lt;br /&gt;
        else{Serial.println(&amp;quot;Fan OFF&amp;quot;);}&lt;br /&gt;
        if (digitalRead(ac_on) == HIGH) {Serial.println(&amp;quot;AC  ON&amp;quot;);}&lt;br /&gt;
        else{Serial.println(&amp;quot;AC  OFF&amp;quot;);}&lt;br /&gt;
        Serial.print(&amp;quot;A/C Delay (millisec) = &amp;quot;);&lt;br /&gt;
        Serial.println(ac_on_delay);&lt;br /&gt;
        Serial.print(&amp;quot;Temp Polling (millisec) = &amp;quot;);&lt;br /&gt;
        Serial.println(polltime);          &lt;br /&gt;
        Serial.println(&amp;quot; &amp;quot;);&lt;br /&gt;
        &lt;br /&gt;
      }&lt;br /&gt;
      else if (command == 81) {      //If command = &amp;quot;Q&amp;quot; Set Date&lt;br /&gt;
       setDateDs1307();&lt;br /&gt;
       getDateDs1307();&lt;br /&gt;
       Serial.println(&amp;quot; &amp;quot;);&lt;br /&gt;
      }&lt;br /&gt;
      Serial.println(command);     // Echo command char found in serial que&lt;br /&gt;
      command = 0;                 // reset command &lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
//*****************************************************The End***********************&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== A/C_Control_v.01 User Guide ==&lt;br /&gt;
==== Commands ====&lt;br /&gt;
== Troubleshooting ==&lt;br /&gt;
=== Summary ===&lt;br /&gt;
When Troubleshooting a multi-functional issue, it is best practice to break down the issue into pieces and test each piece as a separate system.  However, we will first run through a quick test to see if we can find any obvious issues first.&lt;br /&gt;
=== Quick Test ===&lt;/div&gt;</summary>
		<author><name>Combustor</name></author>	</entry>

	<entry>
		<id>http://combustory.com/wiki/index.php/Temperature_Controller</id>
		<title>Temperature Controller</title>
		<link rel="alternate" type="text/html" href="http://combustory.com/wiki/index.php/Temperature_Controller"/>
				<updated>2008-09-10T17:03:41Z</updated>
		
		<summary type="html">&lt;p&gt;Combustor: /* Example of Method */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{default}}&lt;br /&gt;
== Warning ==&lt;br /&gt;
'''This page is in progress and none of the code can be considered good or complete. I am just using this as an alternate storage of the code for right now.'''&lt;br /&gt;
&lt;br /&gt;
== Summary ==&lt;br /&gt;
== Functional Description of the Method ==&lt;br /&gt;
== Requirements ==&lt;br /&gt;
== Example of Method ==&lt;br /&gt;
=== Quick Guide: ===&lt;br /&gt;
=== Detailed Guide: ===&lt;br /&gt;
=== I2C ===&lt;br /&gt;
==== X9241A - Digital Potentiometer ====&lt;br /&gt;
&lt;br /&gt;
There are basically only two functions that I am after right now which are both three byte instructions:&lt;br /&gt;
&lt;br /&gt;
* Read WCR(Wiper Control Register) for the four potentiometers 0-3 &lt;br /&gt;
** Send 1st byte - Address (my circuit - 10100101 or 0xA5)(binary - 1010 A0 A1 A2 A3) A values are actual pins set to high or low for an address.&lt;br /&gt;
** Send 2nd byte - Instruction (binary - 1001 (1/0)(1/0) 00) - The two bits are used to choose the potentiometer&lt;br /&gt;
** Read WCR requested Byte&lt;br /&gt;
* Write WCR for the four potentiometers 0-3&lt;br /&gt;
** Send 1st byte - Address (my circuit - 10100101 or 0xA5)(binary - 1010 A0 A1 A2 A3) A values are actual pins set to high or low for an address.&lt;br /&gt;
** Send 2nd byte - Instruction (binary - 1010 (1/0)(1/0) 00) - The two bits are used to choose the potentiometer&lt;br /&gt;
** Send WCR Byte - Potentiometer value (binary - 00 D5 D4 D3 D2 D1 D0) - D values are the 0-63 potentiometer positions&lt;br /&gt;
&lt;br /&gt;
==== DS1307 - Real Time Clock ====&lt;br /&gt;
&lt;br /&gt;
The code for this very useful chip came from the [[http://www.glacialwanderer.com/hobbyrobotics/?p=12 Glacial Wanderer]]&lt;br /&gt;
&lt;br /&gt;
==== A/C_Control_v.01 code ====&lt;br /&gt;
&lt;br /&gt;
''' While this says v.01, don't count on it being a released v.01, I am still working on v.01, this is a back up '''&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
/*&lt;br /&gt;
 * A/C Control v.01&lt;br /&gt;
 * by &amp;lt;http://www.combustory.com&amp;gt; John Vaughters&lt;br /&gt;
 * Credit to:&lt;br /&gt;
 * Maurice Ribble - http://www.glacialwanderer.com/hobbyrobotics for RTC DS1307 code&lt;br /&gt;
 *&lt;br /&gt;
 * Turns on an LED for temperatures from analog pins 1-5 on&lt;br /&gt;
 * digital pins 2-6 when the temperature rises above the THRESHOLDS 1-5.&lt;br /&gt;
 * The program also implements a &lt;br /&gt;
 * Serial Communication method that utilizes a leading CHAR for each command Described below. &lt;br /&gt;
 * Commands:&lt;br /&gt;
 * T(1-4) - Temp1-5 Status ex. T1, T2, etc&lt;br /&gt;
 * C(1-4)(0-9) - Increment THRESHOLD1-4 by (1-9) ex. C15 increments THRESHOLD1 BY 5 (Note: C40 will give you a status of THRESHOLD4)&lt;br /&gt;
 * D(1-4)(0-9) - Decrement THRESHOLD1-4 by (1-9) ex. D59 decrements THRESHOLD5 BY 9 (Note: D10 will give you a status of THRESHOLD1)&lt;br /&gt;
 * A(0-1) - Manual AC on command A1 is AC on, A0 is AC off&lt;br /&gt;
 * F(0-1) - Manual AC on command A1 is FAN on, A0 is FAN off &lt;br /&gt;
 * Q - Q Sets the date of the RTC DS1307 Chip&lt;br /&gt;
 */&lt;br /&gt;
&lt;br /&gt;
#include &amp;quot;Wire.h&amp;quot;&lt;br /&gt;
#define DS1307_I2C_ADDRESS 0x68&lt;br /&gt;
&lt;br /&gt;
// Global Variables&lt;br /&gt;
int val_cnt = 0;               // counter for the temp_val                   &lt;br /&gt;
int temp1Pin = 0;    // select the input pin for the Thermistor&lt;br /&gt;
int temp2Pin = 1;    // select the input pin for the Thermistor&lt;br /&gt;
int temp3Pin = 2;    // select the input pin for the Thermistor&lt;br /&gt;
int temp4Pin = 3;    // select the input pin for the Thermistor&lt;br /&gt;
int temp1_val[5] = {0,0,0,0,0};       // variable to store the value coming from the sensor&lt;br /&gt;
int temp2_val[5] = {0,0,0,0,0};       //           &lt;br /&gt;
int temp3_val[5] = {0,0,0,0,0};       //&lt;br /&gt;
int temp4_val[5] = {0,0,0,0,0};       //&lt;br /&gt;
int temp1_avg;                   // average over poll time of the temp values&lt;br /&gt;
int temp2_avg;&lt;br /&gt;
int temp3_avg;&lt;br /&gt;
int temp4_avg;&lt;br /&gt;
int duct1 = 2;                   // Ducts open or close using a digital output&lt;br /&gt;
int duct2 = 3;&lt;br /&gt;
int duct3 = 4;&lt;br /&gt;
int duct4 = 5;&lt;br /&gt;
int THRESHOLD1 = 580;    // Default theshold values&lt;br /&gt;
int THRESHOLD2 = 580;&lt;br /&gt;
int THRESHOLD3 = 580;&lt;br /&gt;
int THRESHOLD4 = 580;&lt;br /&gt;
int ac_on = 13;&lt;br /&gt;
int fan_on = 12;&lt;br /&gt;
int command = 0;       // This is the command char, in ascii form, sent from the serial port     &lt;br /&gt;
long polltime = 1000;  // The time to Poll the tempPins&lt;br /&gt;
long previousMillis = 0;        // will store last time Temp was updated&lt;br /&gt;
long ac_on_start = 0;     // Start A/C delay timer&lt;br /&gt;
long ac_on_delay = 10000;   // Time to wait before checking the ducts again&lt;br /&gt;
byte second, minute, hour, dayOfWeek, dayOfMonth, month, year;&lt;br /&gt;
&lt;br /&gt;
  &lt;br /&gt;
// Convert normal decimal numbers to binary coded decimal&lt;br /&gt;
byte decToBcd(byte val)&lt;br /&gt;
{&lt;br /&gt;
  return ( (val/10*16) + (val%10) );&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
// Convert binary coded decimal to normal decimal numbers&lt;br /&gt;
byte bcdToDec(byte val)&lt;br /&gt;
{&lt;br /&gt;
  return ( (val/16*10) + (val%16) );&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
// 1) Sets the date and time on the ds1307&lt;br /&gt;
// 2) Starts the clock&lt;br /&gt;
// 3) Sets hour mode to 24 hour clock&lt;br /&gt;
// Assumes you're passing in valid numbers&lt;br /&gt;
// Watch for scope issues with Global Variables&lt;br /&gt;
/*void setDateDs1307(byte second,        // 0-59&lt;br /&gt;
                   byte minute,        // 0-59&lt;br /&gt;
                   byte hour,          // 1-23&lt;br /&gt;
                   byte dayOfWeek,     // 1-7&lt;br /&gt;
                   byte dayOfMonth,    // 1-28/29/30/31&lt;br /&gt;
                   byte month,         // 1-12&lt;br /&gt;
                   byte year)          // 0-99*/&lt;br /&gt;
void setDateDs1307()                &lt;br /&gt;
{&lt;br /&gt;
   Wire.beginTransmission(DS1307_I2C_ADDRESS);&lt;br /&gt;
   Wire.send(0);&lt;br /&gt;
   Wire.send(decToBcd(second));    // 0 to bit 7 starts the clock&lt;br /&gt;
   Wire.send(decToBcd(minute));&lt;br /&gt;
   Wire.send(decToBcd(hour));      // If you want 12 hour am/pm you need to set&lt;br /&gt;
                                   // bit 6 (also need to change readDateDs1307)&lt;br /&gt;
   Wire.send(decToBcd(dayOfWeek));&lt;br /&gt;
   Wire.send(decToBcd(dayOfMonth));&lt;br /&gt;
   Wire.send(decToBcd(month));&lt;br /&gt;
   Wire.send(decToBcd(year));&lt;br /&gt;
   Wire.endTransmission();&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
// Gets the date and time from the ds1307 and prints result&lt;br /&gt;
// Watch for scope issues with Global Variables&lt;br /&gt;
void getDateDs1307()&lt;br /&gt;
{&lt;br /&gt;
  // Reset the register pointer&lt;br /&gt;
  Wire.beginTransmission(DS1307_I2C_ADDRESS);&lt;br /&gt;
  Wire.send(0);&lt;br /&gt;
  Wire.endTransmission();&lt;br /&gt;
&lt;br /&gt;
  Wire.requestFrom(DS1307_I2C_ADDRESS, 7);&lt;br /&gt;
&lt;br /&gt;
  // A few of these need masks because certain bits are control bits&lt;br /&gt;
  second     = bcdToDec(Wire.receive() &amp;amp; 0x7f);&lt;br /&gt;
  minute     = bcdToDec(Wire.receive());&lt;br /&gt;
  hour       = bcdToDec(Wire.receive() &amp;amp; 0x3f);  // Need to change this if 12 hour am/pm&lt;br /&gt;
  dayOfWeek  = bcdToDec(Wire.receive());&lt;br /&gt;
  dayOfMonth = bcdToDec(Wire.receive());&lt;br /&gt;
  month      = bcdToDec(Wire.receive());&lt;br /&gt;
  year       = bcdToDec(Wire.receive());&lt;br /&gt;
  &lt;br /&gt;
  Serial.print(hour, DEC);&lt;br /&gt;
  Serial.print(&amp;quot;:&amp;quot;);&lt;br /&gt;
  Serial.print(minute, DEC);&lt;br /&gt;
  Serial.print(&amp;quot;:&amp;quot;);&lt;br /&gt;
  Serial.print(second, DEC);&lt;br /&gt;
  Serial.print(&amp;quot;  &amp;quot;);&lt;br /&gt;
  Serial.print(month, DEC);&lt;br /&gt;
  Serial.print(&amp;quot;/&amp;quot;);&lt;br /&gt;
  Serial.print(dayOfMonth, DEC);&lt;br /&gt;
  Serial.print(&amp;quot;/&amp;quot;);&lt;br /&gt;
  Serial.print(year, DEC);&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
void setup() {&lt;br /&gt;
  Wire.begin();&lt;br /&gt;
  Serial.begin(57600);&lt;br /&gt;
  pinMode(duct1, OUTPUT);&lt;br /&gt;
  pinMode(duct2, OUTPUT);&lt;br /&gt;
  pinMode(duct3, OUTPUT);&lt;br /&gt;
  pinMode(duct4, OUTPUT);&lt;br /&gt;
  pinMode(ac_on, OUTPUT);&lt;br /&gt;
  pinMode(fan_on, OUTPUT);&lt;br /&gt;
  // Initialize Date/Time to update RTC DS1307 - You need to run the Q command right after you download this program&lt;br /&gt;
  // This is temporary until a more complex date time command is finished&lt;br /&gt;
  second = 15;&lt;br /&gt;
  minute = 41;&lt;br /&gt;
  hour = 12;&lt;br /&gt;
  dayOfWeek = 5;&lt;br /&gt;
  dayOfMonth = 5;&lt;br /&gt;
  month = 9;&lt;br /&gt;
  year = 8;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
void loop() {&lt;br /&gt;
  if (millis() - previousMillis &amp;gt; polltime) {&lt;br /&gt;
    previousMillis = millis();   // remember the last time&lt;br /&gt;
    if (millis() - ac_on_start &amp;gt; ac_on_delay) { &lt;br /&gt;
      if (digitalRead(duct1) || digitalRead(duct2) || digitalRead(duct3) || digitalRead(duct4)){  // If any ducts are turned on turn on the A/C&lt;br /&gt;
       if (digitalRead(ac_on) != HIGH) { // Check ac_on state&lt;br /&gt;
        digitalWrite(ac_on,HIGH);&lt;br /&gt;
        getDateDs1307();&lt;br /&gt;
        Serial.println(&amp;quot; - AC ON&amp;quot;);&lt;br /&gt;
       }&lt;br /&gt;
       ac_on_start = millis();&lt;br /&gt;
      } &lt;br /&gt;
      else if (digitalRead(ac_on) != LOW){ //Check ac_on state&lt;br /&gt;
       digitalWrite(ac_on,LOW);&lt;br /&gt;
       getDateDs1307();&lt;br /&gt;
       Serial.println(&amp;quot; - AC OFF&amp;quot;);&lt;br /&gt;
      }&lt;br /&gt;
    }&lt;br /&gt;
    temp1_val[val_cnt] = analogRead(temp1Pin);    // read the value from the sensors&lt;br /&gt;
    temp2_val[val_cnt] = analogRead(temp2Pin);&lt;br /&gt;
    temp3_val[val_cnt] = analogRead(temp3Pin);&lt;br /&gt;
    temp4_val[val_cnt] = analogRead(temp4Pin);&lt;br /&gt;
    val_cnt ++;&lt;br /&gt;
    if (val_cnt == 5) {&lt;br /&gt;
      val_cnt = 0;&lt;br /&gt;
    }&lt;br /&gt;
    temp1_avg = (temp1_val[0] + temp1_val[1] + temp1_val[2] + temp1_val[3] + temp1_val[4])/5;&lt;br /&gt;
    temp2_avg = (temp2_val[0] + temp2_val[1] + temp2_val[2] + temp2_val[3] + temp2_val[4])/5;&lt;br /&gt;
    temp3_avg = (temp3_val[0] + temp3_val[1] + temp3_val[2] + temp3_val[3] + temp3_val[4])/5;&lt;br /&gt;
    temp4_avg = (temp4_val[0] + temp4_val[1] + temp4_val[2] + temp4_val[3] + temp4_val[4])/5;&lt;br /&gt;
// Check Thresholds against the Temperatures and set the ducts HIGH or LOW    &lt;br /&gt;
    if (temp1_avg &amp;gt;= THRESHOLD1) {digitalWrite(duct1, HIGH);}&lt;br /&gt;
    else {digitalWrite(duct1, LOW);}&lt;br /&gt;
    if (temp2_avg &amp;gt;= THRESHOLD2) {digitalWrite(duct2, HIGH);}&lt;br /&gt;
    else {digitalWrite(duct2, LOW);}&lt;br /&gt;
    if (temp3_avg &amp;gt;= THRESHOLD3) {digitalWrite(duct3, HIGH);}&lt;br /&gt;
    else {digitalWrite(duct3, LOW);}&lt;br /&gt;
    if (temp4_avg &amp;gt;= THRESHOLD4) {digitalWrite(duct4, HIGH);}&lt;br /&gt;
    else {digitalWrite(duct4, LOW);}&lt;br /&gt;
    if (Serial.available()) {      // Look for char in serial que and process if found&lt;br /&gt;
      command = Serial.read();&lt;br /&gt;
      if (command == 84) {          // If command = &amp;quot;T&amp;quot; &lt;br /&gt;
        command = Serial.read();&lt;br /&gt;
        if (command == 49) {          // If command = &amp;quot;1&amp;quot; print the Temp1&lt;br /&gt;
         Serial.print(&amp;quot;Temp1 = &amp;quot;);&lt;br /&gt;
         Serial.print(temp1_avg);           // &lt;br /&gt;
         Serial.print(&amp;quot; &amp;quot;);&lt;br /&gt;
        }&lt;br /&gt;
        else if (command == 50) {      // If command = &amp;quot;2&amp;quot; print the Temp2&lt;br /&gt;
         Serial.print(&amp;quot;Temp2 = &amp;quot;);&lt;br /&gt;
         Serial.print(temp2_avg);           // &lt;br /&gt;
         Serial.print(&amp;quot; &amp;quot;);&lt;br /&gt;
        }&lt;br /&gt;
        else if (command == 51) {      // If command = &amp;quot;3&amp;quot; print the Temp3&lt;br /&gt;
         Serial.print(&amp;quot;Temp3 = &amp;quot;);&lt;br /&gt;
         Serial.print(temp3_avg);           // &lt;br /&gt;
         Serial.print(&amp;quot; &amp;quot;);&lt;br /&gt;
        }&lt;br /&gt;
        else if (command == 52) {      // If command = &amp;quot;4&amp;quot; print the Temp4&lt;br /&gt;
         Serial.print(&amp;quot;Temp4 = &amp;quot;);&lt;br /&gt;
         Serial.print(temp4_avg);           // &lt;br /&gt;
         Serial.print(&amp;quot; &amp;quot;);&lt;br /&gt;
         }&lt;br /&gt;
       }&lt;br /&gt;
      else if (command == 67) {      //If command = &amp;quot;C&amp;quot; Change Temp Threshhold&lt;br /&gt;
        if (Serial.available()) {&lt;br /&gt;
         command = Serial.read();&lt;br /&gt;
         if (command == 49) {        // If command = &amp;quot;1&amp;quot; print the THRESHOLD1&lt;br /&gt;
           command = Serial.read();&lt;br /&gt;
           if (command &amp;gt; 47 &amp;amp;&amp;amp; command &amp;lt; 58) {          // If command is between 0-9 Increment the Threshold by number sent&lt;br /&gt;
             THRESHOLD1 += command - 48;                 // ASCII math to get value sent   &lt;br /&gt;
                  Serial.print(&amp;quot;THRESHOLD1 = &amp;quot;);&lt;br /&gt;
                  Serial.print(THRESHOLD1);           // &lt;br /&gt;
                  Serial.print(&amp;quot; &amp;quot;);&lt;br /&gt;
           }&lt;br /&gt;
         }  &lt;br /&gt;
         else if (command == 50) {     // If command = &amp;quot;2&amp;quot; print the THRESHOLD2&lt;br /&gt;
           command = Serial.read();&lt;br /&gt;
           if (command &amp;gt; 47 &amp;amp;&amp;amp; command &amp;lt; 58) {          // If command is between 0-9 Increment the Threshold by number sent&lt;br /&gt;
             THRESHOLD2 += command - 48;                 // ASCII math to get value sent   &lt;br /&gt;
                  Serial.print(&amp;quot;THRESHOLD2 = &amp;quot;);&lt;br /&gt;
                  Serial.print(THRESHOLD2);           // &lt;br /&gt;
                  Serial.print(&amp;quot; &amp;quot;);&lt;br /&gt;
           }&lt;br /&gt;
         }&lt;br /&gt;
         else if (command == 51) {             // If command = &amp;quot;3&amp;quot; print the THRESHOLD3&lt;br /&gt;
           command = Serial.read();&lt;br /&gt;
           if (command &amp;gt; 47 &amp;amp;&amp;amp; command &amp;lt; 58) {          // If command is between 0-9 Increment the Threshold by number sent&lt;br /&gt;
             THRESHOLD3 += command - 48;                 // ASCII math to get value sent   &lt;br /&gt;
                  Serial.print(&amp;quot;THRESHOLD3 = &amp;quot;);&lt;br /&gt;
                  Serial.print(THRESHOLD3);           // &lt;br /&gt;
                  Serial.print(&amp;quot; &amp;quot;);&lt;br /&gt;
           }&lt;br /&gt;
         }&lt;br /&gt;
         else if (command == 52) {             // If command = &amp;quot;4&amp;quot; print the THRESHOLD4&lt;br /&gt;
           command = Serial.read();&lt;br /&gt;
           if (command &amp;gt; 47 &amp;amp;&amp;amp; command &amp;lt; 58) {          // If command is between 0-9 Increment the Threshold by number sent&lt;br /&gt;
             THRESHOLD4 += command - 48;                 // ASCII math to get value sent   &lt;br /&gt;
                  Serial.print(&amp;quot;THRESHOLD4 = &amp;quot;);&lt;br /&gt;
                  Serial.print(THRESHOLD4);           // &lt;br /&gt;
                  Serial.print(&amp;quot; &amp;quot;);&lt;br /&gt;
           }&lt;br /&gt;
         }          &lt;br /&gt;
        }  &lt;br /&gt;
      }&lt;br /&gt;
      else if (command == 68) {      //If command = &amp;quot;D&amp;quot; Change Temp Threshhold&lt;br /&gt;
        if (Serial.available()) {&lt;br /&gt;
         command = Serial.read();&lt;br /&gt;
         if (command == 49) {           // If command = &amp;quot;1&amp;quot; print the THRESHOLD1&lt;br /&gt;
           command = Serial.read();&lt;br /&gt;
           if (command &amp;gt; 47 &amp;amp;&amp;amp; command &amp;lt; 58) {          // If command is between 0-9 Decrement the Threshold by number sent&lt;br /&gt;
             THRESHOLD1 -= command - 48;                 // ASCII math to get value sent   &lt;br /&gt;
                  Serial.print(&amp;quot;THRESHOLD1 = &amp;quot;);&lt;br /&gt;
                  Serial.print(THRESHOLD1);           // &lt;br /&gt;
                  Serial.print(&amp;quot; &amp;quot;);&lt;br /&gt;
           }&lt;br /&gt;
         }  &lt;br /&gt;
         else if (command == 50) {               // If command = &amp;quot;2&amp;quot; print the THRESHOLD2&lt;br /&gt;
           command = Serial.read();&lt;br /&gt;
           if (command &amp;gt; 47 &amp;amp;&amp;amp; command &amp;lt; 58) {          // If command is between 0-9 Decrement the Threshold by number sent&lt;br /&gt;
             THRESHOLD2 -= command - 48;                 // ASCII math to get value sent   &lt;br /&gt;
                  Serial.print(&amp;quot;THRESHOLD2 = &amp;quot;);&lt;br /&gt;
                  Serial.print(THRESHOLD2);           // &lt;br /&gt;
                  Serial.print(&amp;quot; &amp;quot;);&lt;br /&gt;
           }&lt;br /&gt;
         }&lt;br /&gt;
         else if (command == 51) {              // If command = &amp;quot;3&amp;quot; print the THRESHOLD3&lt;br /&gt;
           command = Serial.read();&lt;br /&gt;
           if (command &amp;gt; 47 &amp;amp;&amp;amp; command &amp;lt; 58) {          // If command is between 0-9 Decrement the Threshold by number sent&lt;br /&gt;
             THRESHOLD3 -= command - 48;                 // ASCII math to get value sent   &lt;br /&gt;
                  Serial.print(&amp;quot;THRESHOLD3 = &amp;quot;);&lt;br /&gt;
                  Serial.print(THRESHOLD3);           // &lt;br /&gt;
                  Serial.print(&amp;quot; &amp;quot;);&lt;br /&gt;
           }&lt;br /&gt;
         }&lt;br /&gt;
         else if (command == 52) {                    // If command = &amp;quot;4&amp;quot; print the THRESHOLD4&lt;br /&gt;
           command = Serial.read();&lt;br /&gt;
           if (command &amp;gt; 47 &amp;amp;&amp;amp; command &amp;lt; 58) {          // If command is between 0-9 Decrement the Threshold by number sent&lt;br /&gt;
             THRESHOLD4 -= command - 48;                 // ASCII math to get value sent   &lt;br /&gt;
                  Serial.print(&amp;quot;THRESHOLD4 = &amp;quot;);&lt;br /&gt;
                  Serial.print(THRESHOLD4);           // &lt;br /&gt;
                  Serial.print(&amp;quot; &amp;quot;);&lt;br /&gt;
           }&lt;br /&gt;
         }           &lt;br /&gt;
        }  &lt;br /&gt;
      }&lt;br /&gt;
//****************  Warning - This is a potential for problem - Consider a manual lock out feature to lock out manual commands &lt;br /&gt;
//****************  Possibly create a command to open up manual commands for a certian time period then shut them off again automatically&lt;br /&gt;
      else if (command == 65) {      //If command = &amp;quot;A&amp;quot; Change Temp Threshhold&lt;br /&gt;
       if (Serial.available()) {&lt;br /&gt;
        command = Serial.read();&lt;br /&gt;
        if (command == 49) {        // If command = &amp;quot;1&amp;quot; print the AC ON message&lt;br /&gt;
         getDateDs1307();&lt;br /&gt;
         Serial.print(&amp;quot; - Manual AC ON &amp;quot;);&lt;br /&gt;
         ac_on_start = millis();   // Set the AC to a delay before it can be turned off again&lt;br /&gt;
         digitalWrite(ac_on,HIGH);&lt;br /&gt;
        }&lt;br /&gt;
        else if (command == 48) {        // If command = &amp;quot;0&amp;quot; print the AC OFF message&lt;br /&gt;
         getDateDs1307();&lt;br /&gt;
         Serial.print(&amp;quot; - Manual AC OFF &amp;quot;);&lt;br /&gt;
         digitalWrite(ac_on,LOW);&lt;br /&gt;
        }&lt;br /&gt;
       } &lt;br /&gt;
      } &lt;br /&gt;
      else if (command == 70) {      //If command = &amp;quot;F&amp;quot; Change Temp Threshhold&lt;br /&gt;
       if (Serial.available()) {&lt;br /&gt;
        command = Serial.read();&lt;br /&gt;
        if (command == 49) {        // If command = &amp;quot;1&amp;quot; print the FAN ON message&lt;br /&gt;
         getDateDs1307();&lt;br /&gt;
         Serial.print(&amp;quot; - Manual FAN ON &amp;quot;);&lt;br /&gt;
         ac_on_start = millis();&lt;br /&gt;
         digitalWrite(fan_on,HIGH);&lt;br /&gt;
        }&lt;br /&gt;
        else if (command == 48) {        // If command = &amp;quot;0&amp;quot; print the FAN OFF message&lt;br /&gt;
         getDateDs1307();&lt;br /&gt;
         Serial.print(&amp;quot; - Manual FAN OFF &amp;quot;);&lt;br /&gt;
         digitalWrite(fan_on,LOW);&lt;br /&gt;
        }&lt;br /&gt;
       } &lt;br /&gt;
      }&lt;br /&gt;
//********************** End of Warning Zone *******************************&lt;br /&gt;
&lt;br /&gt;
// ***************  This Section Will list the Staus of the Controller&lt;br /&gt;
      else if (command == 83) {      //If command = &amp;quot;S&amp;quot; Print Controller Status&lt;br /&gt;
        getDateDs1307();&lt;br /&gt;
        Serial.println(&amp;quot; &amp;quot;);&lt;br /&gt;
        Serial.println(&amp;quot; &amp;quot;);&lt;br /&gt;
        Serial.print(&amp;quot;Temp1 = &amp;quot;);&lt;br /&gt;
        Serial.println(temp1_avg);   &lt;br /&gt;
        Serial.print(&amp;quot;Temp2 = &amp;quot;);&lt;br /&gt;
        Serial.println(temp2_avg);&lt;br /&gt;
        Serial.print(&amp;quot;Temp3 = &amp;quot;);&lt;br /&gt;
        Serial.println(temp3_avg);   &lt;br /&gt;
        Serial.print(&amp;quot;Temp4 = &amp;quot;);&lt;br /&gt;
        Serial.println(temp4_avg);   &lt;br /&gt;
        Serial.println(&amp;quot; &amp;quot;);&lt;br /&gt;
        Serial.print(&amp;quot;THRESHOLD1 = &amp;quot;);&lt;br /&gt;
        Serial.println(THRESHOLD1);   &lt;br /&gt;
        Serial.print(&amp;quot;THRESHOLD2 = &amp;quot;);&lt;br /&gt;
        Serial.println(THRESHOLD2); &lt;br /&gt;
        Serial.print(&amp;quot;THRESHOLD3 = &amp;quot;);&lt;br /&gt;
        Serial.println(THRESHOLD3); &lt;br /&gt;
        Serial.print(&amp;quot;THRESHOLD4 = &amp;quot;);&lt;br /&gt;
        Serial.println(THRESHOLD4);&lt;br /&gt;
        Serial.println(&amp;quot; &amp;quot;);&lt;br /&gt;
        if (digitalRead(duct1) == HIGH) {Serial.println(&amp;quot;duct1 ON&amp;quot;);}&lt;br /&gt;
        else{Serial.println(&amp;quot;duct1 OFF&amp;quot;);}&lt;br /&gt;
        if (digitalRead(duct2) == HIGH) {Serial.println(&amp;quot;duct2 ON&amp;quot;);}&lt;br /&gt;
        else{Serial.println(&amp;quot;duct2 OFF&amp;quot;);}&lt;br /&gt;
        if (digitalRead(duct3) == HIGH) {Serial.println(&amp;quot;duct3 ON&amp;quot;);}&lt;br /&gt;
        else{Serial.println(&amp;quot;duct3 OFF&amp;quot;);}&lt;br /&gt;
        if (digitalRead(duct4) == HIGH) {Serial.println(&amp;quot;duct4 ON&amp;quot;);}&lt;br /&gt;
        else{Serial.println(&amp;quot;duct4 OFF&amp;quot;);}&lt;br /&gt;
        Serial.println(&amp;quot; &amp;quot;);&lt;br /&gt;
        if (digitalRead(fan_on) == HIGH) {Serial.println(&amp;quot;Fan ON&amp;quot;);}&lt;br /&gt;
        else{Serial.println(&amp;quot;Fan OFF&amp;quot;);}&lt;br /&gt;
        if (digitalRead(ac_on) == HIGH) {Serial.println(&amp;quot;AC  ON&amp;quot;);}&lt;br /&gt;
        else{Serial.println(&amp;quot;AC  OFF&amp;quot;);}&lt;br /&gt;
        Serial.print(&amp;quot;A/C Delay (millisec) = &amp;quot;);&lt;br /&gt;
        Serial.println(ac_on_delay);&lt;br /&gt;
        Serial.print(&amp;quot;Temp Polling (millisec) = &amp;quot;);&lt;br /&gt;
        Serial.println(polltime);          &lt;br /&gt;
        Serial.println(&amp;quot; &amp;quot;);&lt;br /&gt;
        &lt;br /&gt;
      }&lt;br /&gt;
      else if (command == 81) {      //If command = &amp;quot;Q&amp;quot; Set Date&lt;br /&gt;
       setDateDs1307();&lt;br /&gt;
       getDateDs1307();&lt;br /&gt;
       Serial.println(&amp;quot; &amp;quot;);&lt;br /&gt;
      }&lt;br /&gt;
      Serial.println(command);     // Echo command char found in serial que&lt;br /&gt;
      command = 0;                 // reset command &lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
//*****************************************************The End***********************&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== A/C_Control_v.01 User Guide ==&lt;br /&gt;
==== Commands ====&lt;br /&gt;
== Troubleshooting ==&lt;br /&gt;
=== Summary ===&lt;br /&gt;
When Troubleshooting a multi-functional issue, it is best practice to break down the issue into pieces and test each piece as a separate system.  However, we will first run through a quick test to see if we can find any obvious issues first.&lt;br /&gt;
=== Quick Test ===&lt;/div&gt;</summary>
		<author><name>Combustor</name></author>	</entry>

	<entry>
		<id>http://combustory.com/wiki/index.php/Temperature_Controller</id>
		<title>Temperature Controller</title>
		<link rel="alternate" type="text/html" href="http://combustory.com/wiki/index.php/Temperature_Controller"/>
				<updated>2008-09-10T17:02:16Z</updated>
		
		<summary type="html">&lt;p&gt;Combustor: /* Example of Method */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{default}}&lt;br /&gt;
== Warning ==&lt;br /&gt;
'''This page is in progress and none of the code can be considered good or complete. I am just using this as an alternate storage of the code for right now.'''&lt;br /&gt;
&lt;br /&gt;
== Summary ==&lt;br /&gt;
== Functional Description of the Method ==&lt;br /&gt;
== Requirements ==&lt;br /&gt;
== Example of Method ==&lt;br /&gt;
=== Quick Guide: ===&lt;br /&gt;
=== Detailed Guide: ===&lt;br /&gt;
=== I2C ===&lt;br /&gt;
==== X9241A - Digital Potentiometer ====&lt;br /&gt;
&lt;br /&gt;
There are basically only two functions that I am after right now which are both three byte instructions:&lt;br /&gt;
&lt;br /&gt;
* Read WCR(Wiper Control Register) for the four potentiometers 0-3 &lt;br /&gt;
** Send 1st byte - Address (my circuit - 10100101)(binary - 1010 A0 A1 A2 A3) A values are actual pins set to high or low for an address.&lt;br /&gt;
** Send 2nd byte - Instruction (binary - 1001 (1/0)(1/0) 00) - The two bits are used to choose the potentiometer&lt;br /&gt;
** Read WCR requested Byte&lt;br /&gt;
* Write WCR for the four potentiometers 0-3&lt;br /&gt;
** Send 1st byte - Address (my circuit - 10100101)(binary - 1010 A0 A1 A2 A3) A values are actual pins set to high or low for an address.&lt;br /&gt;
** Send 2nd byte - Instruction (binary - 1010 (1/0)(1/0) 00) - The two bits are used to choose the potentiometer&lt;br /&gt;
** Send WCR Byte - Potentiometer value (binary - 00 D5 D4 D3 D2 D1 D0) - D values are the 0-63 potentiometer positions&lt;br /&gt;
&lt;br /&gt;
==== DS1307 - Real Time Clock ====&lt;br /&gt;
&lt;br /&gt;
The code for this very useful chip came from the [[http://www.glacialwanderer.com/hobbyrobotics/?p=12 Glacial Wanderer]]&lt;br /&gt;
&lt;br /&gt;
==== A/C_Control_v.01 code ====&lt;br /&gt;
&lt;br /&gt;
''' While this says v.01, don't count on it being a released v.01, I am still working on v.01, this is a back up '''&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
/*&lt;br /&gt;
 * A/C Control v.01&lt;br /&gt;
 * by &amp;lt;http://www.combustory.com&amp;gt; John Vaughters&lt;br /&gt;
 * Credit to:&lt;br /&gt;
 * Maurice Ribble - http://www.glacialwanderer.com/hobbyrobotics for RTC DS1307 code&lt;br /&gt;
 *&lt;br /&gt;
 * Turns on an LED for temperatures from analog pins 1-5 on&lt;br /&gt;
 * digital pins 2-6 when the temperature rises above the THRESHOLDS 1-5.&lt;br /&gt;
 * The program also implements a &lt;br /&gt;
 * Serial Communication method that utilizes a leading CHAR for each command Described below. &lt;br /&gt;
 * Commands:&lt;br /&gt;
 * T(1-4) - Temp1-5 Status ex. T1, T2, etc&lt;br /&gt;
 * C(1-4)(0-9) - Increment THRESHOLD1-4 by (1-9) ex. C15 increments THRESHOLD1 BY 5 (Note: C40 will give you a status of THRESHOLD4)&lt;br /&gt;
 * D(1-4)(0-9) - Decrement THRESHOLD1-4 by (1-9) ex. D59 decrements THRESHOLD5 BY 9 (Note: D10 will give you a status of THRESHOLD1)&lt;br /&gt;
 * A(0-1) - Manual AC on command A1 is AC on, A0 is AC off&lt;br /&gt;
 * F(0-1) - Manual AC on command A1 is FAN on, A0 is FAN off &lt;br /&gt;
 * Q - Q Sets the date of the RTC DS1307 Chip&lt;br /&gt;
 */&lt;br /&gt;
&lt;br /&gt;
#include &amp;quot;Wire.h&amp;quot;&lt;br /&gt;
#define DS1307_I2C_ADDRESS 0x68&lt;br /&gt;
&lt;br /&gt;
// Global Variables&lt;br /&gt;
int val_cnt = 0;               // counter for the temp_val                   &lt;br /&gt;
int temp1Pin = 0;    // select the input pin for the Thermistor&lt;br /&gt;
int temp2Pin = 1;    // select the input pin for the Thermistor&lt;br /&gt;
int temp3Pin = 2;    // select the input pin for the Thermistor&lt;br /&gt;
int temp4Pin = 3;    // select the input pin for the Thermistor&lt;br /&gt;
int temp1_val[5] = {0,0,0,0,0};       // variable to store the value coming from the sensor&lt;br /&gt;
int temp2_val[5] = {0,0,0,0,0};       //           &lt;br /&gt;
int temp3_val[5] = {0,0,0,0,0};       //&lt;br /&gt;
int temp4_val[5] = {0,0,0,0,0};       //&lt;br /&gt;
int temp1_avg;                   // average over poll time of the temp values&lt;br /&gt;
int temp2_avg;&lt;br /&gt;
int temp3_avg;&lt;br /&gt;
int temp4_avg;&lt;br /&gt;
int duct1 = 2;                   // Ducts open or close using a digital output&lt;br /&gt;
int duct2 = 3;&lt;br /&gt;
int duct3 = 4;&lt;br /&gt;
int duct4 = 5;&lt;br /&gt;
int THRESHOLD1 = 580;    // Default theshold values&lt;br /&gt;
int THRESHOLD2 = 580;&lt;br /&gt;
int THRESHOLD3 = 580;&lt;br /&gt;
int THRESHOLD4 = 580;&lt;br /&gt;
int ac_on = 13;&lt;br /&gt;
int fan_on = 12;&lt;br /&gt;
int command = 0;       // This is the command char, in ascii form, sent from the serial port     &lt;br /&gt;
long polltime = 1000;  // The time to Poll the tempPins&lt;br /&gt;
long previousMillis = 0;        // will store last time Temp was updated&lt;br /&gt;
long ac_on_start = 0;     // Start A/C delay timer&lt;br /&gt;
long ac_on_delay = 10000;   // Time to wait before checking the ducts again&lt;br /&gt;
byte second, minute, hour, dayOfWeek, dayOfMonth, month, year;&lt;br /&gt;
&lt;br /&gt;
  &lt;br /&gt;
// Convert normal decimal numbers to binary coded decimal&lt;br /&gt;
byte decToBcd(byte val)&lt;br /&gt;
{&lt;br /&gt;
  return ( (val/10*16) + (val%10) );&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
// Convert binary coded decimal to normal decimal numbers&lt;br /&gt;
byte bcdToDec(byte val)&lt;br /&gt;
{&lt;br /&gt;
  return ( (val/16*10) + (val%16) );&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
// 1) Sets the date and time on the ds1307&lt;br /&gt;
// 2) Starts the clock&lt;br /&gt;
// 3) Sets hour mode to 24 hour clock&lt;br /&gt;
// Assumes you're passing in valid numbers&lt;br /&gt;
// Watch for scope issues with Global Variables&lt;br /&gt;
/*void setDateDs1307(byte second,        // 0-59&lt;br /&gt;
                   byte minute,        // 0-59&lt;br /&gt;
                   byte hour,          // 1-23&lt;br /&gt;
                   byte dayOfWeek,     // 1-7&lt;br /&gt;
                   byte dayOfMonth,    // 1-28/29/30/31&lt;br /&gt;
                   byte month,         // 1-12&lt;br /&gt;
                   byte year)          // 0-99*/&lt;br /&gt;
void setDateDs1307()                &lt;br /&gt;
{&lt;br /&gt;
   Wire.beginTransmission(DS1307_I2C_ADDRESS);&lt;br /&gt;
   Wire.send(0);&lt;br /&gt;
   Wire.send(decToBcd(second));    // 0 to bit 7 starts the clock&lt;br /&gt;
   Wire.send(decToBcd(minute));&lt;br /&gt;
   Wire.send(decToBcd(hour));      // If you want 12 hour am/pm you need to set&lt;br /&gt;
                                   // bit 6 (also need to change readDateDs1307)&lt;br /&gt;
   Wire.send(decToBcd(dayOfWeek));&lt;br /&gt;
   Wire.send(decToBcd(dayOfMonth));&lt;br /&gt;
   Wire.send(decToBcd(month));&lt;br /&gt;
   Wire.send(decToBcd(year));&lt;br /&gt;
   Wire.endTransmission();&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
// Gets the date and time from the ds1307 and prints result&lt;br /&gt;
// Watch for scope issues with Global Variables&lt;br /&gt;
void getDateDs1307()&lt;br /&gt;
{&lt;br /&gt;
  // Reset the register pointer&lt;br /&gt;
  Wire.beginTransmission(DS1307_I2C_ADDRESS);&lt;br /&gt;
  Wire.send(0);&lt;br /&gt;
  Wire.endTransmission();&lt;br /&gt;
&lt;br /&gt;
  Wire.requestFrom(DS1307_I2C_ADDRESS, 7);&lt;br /&gt;
&lt;br /&gt;
  // A few of these need masks because certain bits are control bits&lt;br /&gt;
  second     = bcdToDec(Wire.receive() &amp;amp; 0x7f);&lt;br /&gt;
  minute     = bcdToDec(Wire.receive());&lt;br /&gt;
  hour       = bcdToDec(Wire.receive() &amp;amp; 0x3f);  // Need to change this if 12 hour am/pm&lt;br /&gt;
  dayOfWeek  = bcdToDec(Wire.receive());&lt;br /&gt;
  dayOfMonth = bcdToDec(Wire.receive());&lt;br /&gt;
  month      = bcdToDec(Wire.receive());&lt;br /&gt;
  year       = bcdToDec(Wire.receive());&lt;br /&gt;
  &lt;br /&gt;
  Serial.print(hour, DEC);&lt;br /&gt;
  Serial.print(&amp;quot;:&amp;quot;);&lt;br /&gt;
  Serial.print(minute, DEC);&lt;br /&gt;
  Serial.print(&amp;quot;:&amp;quot;);&lt;br /&gt;
  Serial.print(second, DEC);&lt;br /&gt;
  Serial.print(&amp;quot;  &amp;quot;);&lt;br /&gt;
  Serial.print(month, DEC);&lt;br /&gt;
  Serial.print(&amp;quot;/&amp;quot;);&lt;br /&gt;
  Serial.print(dayOfMonth, DEC);&lt;br /&gt;
  Serial.print(&amp;quot;/&amp;quot;);&lt;br /&gt;
  Serial.print(year, DEC);&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
void setup() {&lt;br /&gt;
  Wire.begin();&lt;br /&gt;
  Serial.begin(57600);&lt;br /&gt;
  pinMode(duct1, OUTPUT);&lt;br /&gt;
  pinMode(duct2, OUTPUT);&lt;br /&gt;
  pinMode(duct3, OUTPUT);&lt;br /&gt;
  pinMode(duct4, OUTPUT);&lt;br /&gt;
  pinMode(ac_on, OUTPUT);&lt;br /&gt;
  pinMode(fan_on, OUTPUT);&lt;br /&gt;
  // Initialize Date/Time to update RTC DS1307 - You need to run the Q command right after you download this program&lt;br /&gt;
  // This is temporary until a more complex date time command is finished&lt;br /&gt;
  second = 15;&lt;br /&gt;
  minute = 41;&lt;br /&gt;
  hour = 12;&lt;br /&gt;
  dayOfWeek = 5;&lt;br /&gt;
  dayOfMonth = 5;&lt;br /&gt;
  month = 9;&lt;br /&gt;
  year = 8;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
void loop() {&lt;br /&gt;
  if (millis() - previousMillis &amp;gt; polltime) {&lt;br /&gt;
    previousMillis = millis();   // remember the last time&lt;br /&gt;
    if (millis() - ac_on_start &amp;gt; ac_on_delay) { &lt;br /&gt;
      if (digitalRead(duct1) || digitalRead(duct2) || digitalRead(duct3) || digitalRead(duct4)){  // If any ducts are turned on turn on the A/C&lt;br /&gt;
       if (digitalRead(ac_on) != HIGH) { // Check ac_on state&lt;br /&gt;
        digitalWrite(ac_on,HIGH);&lt;br /&gt;
        getDateDs1307();&lt;br /&gt;
        Serial.println(&amp;quot; - AC ON&amp;quot;);&lt;br /&gt;
       }&lt;br /&gt;
       ac_on_start = millis();&lt;br /&gt;
      } &lt;br /&gt;
      else if (digitalRead(ac_on) != LOW){ //Check ac_on state&lt;br /&gt;
       digitalWrite(ac_on,LOW);&lt;br /&gt;
       getDateDs1307();&lt;br /&gt;
       Serial.println(&amp;quot; - AC OFF&amp;quot;);&lt;br /&gt;
      }&lt;br /&gt;
    }&lt;br /&gt;
    temp1_val[val_cnt] = analogRead(temp1Pin);    // read the value from the sensors&lt;br /&gt;
    temp2_val[val_cnt] = analogRead(temp2Pin);&lt;br /&gt;
    temp3_val[val_cnt] = analogRead(temp3Pin);&lt;br /&gt;
    temp4_val[val_cnt] = analogRead(temp4Pin);&lt;br /&gt;
    val_cnt ++;&lt;br /&gt;
    if (val_cnt == 5) {&lt;br /&gt;
      val_cnt = 0;&lt;br /&gt;
    }&lt;br /&gt;
    temp1_avg = (temp1_val[0] + temp1_val[1] + temp1_val[2] + temp1_val[3] + temp1_val[4])/5;&lt;br /&gt;
    temp2_avg = (temp2_val[0] + temp2_val[1] + temp2_val[2] + temp2_val[3] + temp2_val[4])/5;&lt;br /&gt;
    temp3_avg = (temp3_val[0] + temp3_val[1] + temp3_val[2] + temp3_val[3] + temp3_val[4])/5;&lt;br /&gt;
    temp4_avg = (temp4_val[0] + temp4_val[1] + temp4_val[2] + temp4_val[3] + temp4_val[4])/5;&lt;br /&gt;
// Check Thresholds against the Temperatures and set the ducts HIGH or LOW    &lt;br /&gt;
    if (temp1_avg &amp;gt;= THRESHOLD1) {digitalWrite(duct1, HIGH);}&lt;br /&gt;
    else {digitalWrite(duct1, LOW);}&lt;br /&gt;
    if (temp2_avg &amp;gt;= THRESHOLD2) {digitalWrite(duct2, HIGH);}&lt;br /&gt;
    else {digitalWrite(duct2, LOW);}&lt;br /&gt;
    if (temp3_avg &amp;gt;= THRESHOLD3) {digitalWrite(duct3, HIGH);}&lt;br /&gt;
    else {digitalWrite(duct3, LOW);}&lt;br /&gt;
    if (temp4_avg &amp;gt;= THRESHOLD4) {digitalWrite(duct4, HIGH);}&lt;br /&gt;
    else {digitalWrite(duct4, LOW);}&lt;br /&gt;
    if (Serial.available()) {      // Look for char in serial que and process if found&lt;br /&gt;
      command = Serial.read();&lt;br /&gt;
      if (command == 84) {          // If command = &amp;quot;T&amp;quot; &lt;br /&gt;
        command = Serial.read();&lt;br /&gt;
        if (command == 49) {          // If command = &amp;quot;1&amp;quot; print the Temp1&lt;br /&gt;
         Serial.print(&amp;quot;Temp1 = &amp;quot;);&lt;br /&gt;
         Serial.print(temp1_avg);           // &lt;br /&gt;
         Serial.print(&amp;quot; &amp;quot;);&lt;br /&gt;
        }&lt;br /&gt;
        else if (command == 50) {      // If command = &amp;quot;2&amp;quot; print the Temp2&lt;br /&gt;
         Serial.print(&amp;quot;Temp2 = &amp;quot;);&lt;br /&gt;
         Serial.print(temp2_avg);           // &lt;br /&gt;
         Serial.print(&amp;quot; &amp;quot;);&lt;br /&gt;
        }&lt;br /&gt;
        else if (command == 51) {      // If command = &amp;quot;3&amp;quot; print the Temp3&lt;br /&gt;
         Serial.print(&amp;quot;Temp3 = &amp;quot;);&lt;br /&gt;
         Serial.print(temp3_avg);           // &lt;br /&gt;
         Serial.print(&amp;quot; &amp;quot;);&lt;br /&gt;
        }&lt;br /&gt;
        else if (command == 52) {      // If command = &amp;quot;4&amp;quot; print the Temp4&lt;br /&gt;
         Serial.print(&amp;quot;Temp4 = &amp;quot;);&lt;br /&gt;
         Serial.print(temp4_avg);           // &lt;br /&gt;
         Serial.print(&amp;quot; &amp;quot;);&lt;br /&gt;
         }&lt;br /&gt;
       }&lt;br /&gt;
      else if (command == 67) {      //If command = &amp;quot;C&amp;quot; Change Temp Threshhold&lt;br /&gt;
        if (Serial.available()) {&lt;br /&gt;
         command = Serial.read();&lt;br /&gt;
         if (command == 49) {        // If command = &amp;quot;1&amp;quot; print the THRESHOLD1&lt;br /&gt;
           command = Serial.read();&lt;br /&gt;
           if (command &amp;gt; 47 &amp;amp;&amp;amp; command &amp;lt; 58) {          // If command is between 0-9 Increment the Threshold by number sent&lt;br /&gt;
             THRESHOLD1 += command - 48;                 // ASCII math to get value sent   &lt;br /&gt;
                  Serial.print(&amp;quot;THRESHOLD1 = &amp;quot;);&lt;br /&gt;
                  Serial.print(THRESHOLD1);           // &lt;br /&gt;
                  Serial.print(&amp;quot; &amp;quot;);&lt;br /&gt;
           }&lt;br /&gt;
         }  &lt;br /&gt;
         else if (command == 50) {     // If command = &amp;quot;2&amp;quot; print the THRESHOLD2&lt;br /&gt;
           command = Serial.read();&lt;br /&gt;
           if (command &amp;gt; 47 &amp;amp;&amp;amp; command &amp;lt; 58) {          // If command is between 0-9 Increment the Threshold by number sent&lt;br /&gt;
             THRESHOLD2 += command - 48;                 // ASCII math to get value sent   &lt;br /&gt;
                  Serial.print(&amp;quot;THRESHOLD2 = &amp;quot;);&lt;br /&gt;
                  Serial.print(THRESHOLD2);           // &lt;br /&gt;
                  Serial.print(&amp;quot; &amp;quot;);&lt;br /&gt;
           }&lt;br /&gt;
         }&lt;br /&gt;
         else if (command == 51) {             // If command = &amp;quot;3&amp;quot; print the THRESHOLD3&lt;br /&gt;
           command = Serial.read();&lt;br /&gt;
           if (command &amp;gt; 47 &amp;amp;&amp;amp; command &amp;lt; 58) {          // If command is between 0-9 Increment the Threshold by number sent&lt;br /&gt;
             THRESHOLD3 += command - 48;                 // ASCII math to get value sent   &lt;br /&gt;
                  Serial.print(&amp;quot;THRESHOLD3 = &amp;quot;);&lt;br /&gt;
                  Serial.print(THRESHOLD3);           // &lt;br /&gt;
                  Serial.print(&amp;quot; &amp;quot;);&lt;br /&gt;
           }&lt;br /&gt;
         }&lt;br /&gt;
         else if (command == 52) {             // If command = &amp;quot;4&amp;quot; print the THRESHOLD4&lt;br /&gt;
           command = Serial.read();&lt;br /&gt;
           if (command &amp;gt; 47 &amp;amp;&amp;amp; command &amp;lt; 58) {          // If command is between 0-9 Increment the Threshold by number sent&lt;br /&gt;
             THRESHOLD4 += command - 48;                 // ASCII math to get value sent   &lt;br /&gt;
                  Serial.print(&amp;quot;THRESHOLD4 = &amp;quot;);&lt;br /&gt;
                  Serial.print(THRESHOLD4);           // &lt;br /&gt;
                  Serial.print(&amp;quot; &amp;quot;);&lt;br /&gt;
           }&lt;br /&gt;
         }          &lt;br /&gt;
        }  &lt;br /&gt;
      }&lt;br /&gt;
      else if (command == 68) {      //If command = &amp;quot;D&amp;quot; Change Temp Threshhold&lt;br /&gt;
        if (Serial.available()) {&lt;br /&gt;
         command = Serial.read();&lt;br /&gt;
         if (command == 49) {           // If command = &amp;quot;1&amp;quot; print the THRESHOLD1&lt;br /&gt;
           command = Serial.read();&lt;br /&gt;
           if (command &amp;gt; 47 &amp;amp;&amp;amp; command &amp;lt; 58) {          // If command is between 0-9 Decrement the Threshold by number sent&lt;br /&gt;
             THRESHOLD1 -= command - 48;                 // ASCII math to get value sent   &lt;br /&gt;
                  Serial.print(&amp;quot;THRESHOLD1 = &amp;quot;);&lt;br /&gt;
                  Serial.print(THRESHOLD1);           // &lt;br /&gt;
                  Serial.print(&amp;quot; &amp;quot;);&lt;br /&gt;
           }&lt;br /&gt;
         }  &lt;br /&gt;
         else if (command == 50) {               // If command = &amp;quot;2&amp;quot; print the THRESHOLD2&lt;br /&gt;
           command = Serial.read();&lt;br /&gt;
           if (command &amp;gt; 47 &amp;amp;&amp;amp; command &amp;lt; 58) {          // If command is between 0-9 Decrement the Threshold by number sent&lt;br /&gt;
             THRESHOLD2 -= command - 48;                 // ASCII math to get value sent   &lt;br /&gt;
                  Serial.print(&amp;quot;THRESHOLD2 = &amp;quot;);&lt;br /&gt;
                  Serial.print(THRESHOLD2);           // &lt;br /&gt;
                  Serial.print(&amp;quot; &amp;quot;);&lt;br /&gt;
           }&lt;br /&gt;
         }&lt;br /&gt;
         else if (command == 51) {              // If command = &amp;quot;3&amp;quot; print the THRESHOLD3&lt;br /&gt;
           command = Serial.read();&lt;br /&gt;
           if (command &amp;gt; 47 &amp;amp;&amp;amp; command &amp;lt; 58) {          // If command is between 0-9 Decrement the Threshold by number sent&lt;br /&gt;
             THRESHOLD3 -= command - 48;                 // ASCII math to get value sent   &lt;br /&gt;
                  Serial.print(&amp;quot;THRESHOLD3 = &amp;quot;);&lt;br /&gt;
                  Serial.print(THRESHOLD3);           // &lt;br /&gt;
                  Serial.print(&amp;quot; &amp;quot;);&lt;br /&gt;
           }&lt;br /&gt;
         }&lt;br /&gt;
         else if (command == 52) {                    // If command = &amp;quot;4&amp;quot; print the THRESHOLD4&lt;br /&gt;
           command = Serial.read();&lt;br /&gt;
           if (command &amp;gt; 47 &amp;amp;&amp;amp; command &amp;lt; 58) {          // If command is between 0-9 Decrement the Threshold by number sent&lt;br /&gt;
             THRESHOLD4 -= command - 48;                 // ASCII math to get value sent   &lt;br /&gt;
                  Serial.print(&amp;quot;THRESHOLD4 = &amp;quot;);&lt;br /&gt;
                  Serial.print(THRESHOLD4);           // &lt;br /&gt;
                  Serial.print(&amp;quot; &amp;quot;);&lt;br /&gt;
           }&lt;br /&gt;
         }           &lt;br /&gt;
        }  &lt;br /&gt;
      }&lt;br /&gt;
//****************  Warning - This is a potential for problem - Consider a manual lock out feature to lock out manual commands &lt;br /&gt;
//****************  Possibly create a command to open up manual commands for a certian time period then shut them off again automatically&lt;br /&gt;
      else if (command == 65) {      //If command = &amp;quot;A&amp;quot; Change Temp Threshhold&lt;br /&gt;
       if (Serial.available()) {&lt;br /&gt;
        command = Serial.read();&lt;br /&gt;
        if (command == 49) {        // If command = &amp;quot;1&amp;quot; print the AC ON message&lt;br /&gt;
         getDateDs1307();&lt;br /&gt;
         Serial.print(&amp;quot; - Manual AC ON &amp;quot;);&lt;br /&gt;
         ac_on_start = millis();   // Set the AC to a delay before it can be turned off again&lt;br /&gt;
         digitalWrite(ac_on,HIGH);&lt;br /&gt;
        }&lt;br /&gt;
        else if (command == 48) {        // If command = &amp;quot;0&amp;quot; print the AC OFF message&lt;br /&gt;
         getDateDs1307();&lt;br /&gt;
         Serial.print(&amp;quot; - Manual AC OFF &amp;quot;);&lt;br /&gt;
         digitalWrite(ac_on,LOW);&lt;br /&gt;
        }&lt;br /&gt;
       } &lt;br /&gt;
      } &lt;br /&gt;
      else if (command == 70) {      //If command = &amp;quot;F&amp;quot; Change Temp Threshhold&lt;br /&gt;
       if (Serial.available()) {&lt;br /&gt;
        command = Serial.read();&lt;br /&gt;
        if (command == 49) {        // If command = &amp;quot;1&amp;quot; print the FAN ON message&lt;br /&gt;
         getDateDs1307();&lt;br /&gt;
         Serial.print(&amp;quot; - Manual FAN ON &amp;quot;);&lt;br /&gt;
         ac_on_start = millis();&lt;br /&gt;
         digitalWrite(fan_on,HIGH);&lt;br /&gt;
        }&lt;br /&gt;
        else if (command == 48) {        // If command = &amp;quot;0&amp;quot; print the FAN OFF message&lt;br /&gt;
         getDateDs1307();&lt;br /&gt;
         Serial.print(&amp;quot; - Manual FAN OFF &amp;quot;);&lt;br /&gt;
         digitalWrite(fan_on,LOW);&lt;br /&gt;
        }&lt;br /&gt;
       } &lt;br /&gt;
      }&lt;br /&gt;
//********************** End of Warning Zone *******************************&lt;br /&gt;
&lt;br /&gt;
// ***************  This Section Will list the Staus of the Controller&lt;br /&gt;
      else if (command == 83) {      //If command = &amp;quot;S&amp;quot; Print Controller Status&lt;br /&gt;
        getDateDs1307();&lt;br /&gt;
        Serial.println(&amp;quot; &amp;quot;);&lt;br /&gt;
        Serial.println(&amp;quot; &amp;quot;);&lt;br /&gt;
        Serial.print(&amp;quot;Temp1 = &amp;quot;);&lt;br /&gt;
        Serial.println(temp1_avg);   &lt;br /&gt;
        Serial.print(&amp;quot;Temp2 = &amp;quot;);&lt;br /&gt;
        Serial.println(temp2_avg);&lt;br /&gt;
        Serial.print(&amp;quot;Temp3 = &amp;quot;);&lt;br /&gt;
        Serial.println(temp3_avg);   &lt;br /&gt;
        Serial.print(&amp;quot;Temp4 = &amp;quot;);&lt;br /&gt;
        Serial.println(temp4_avg);   &lt;br /&gt;
        Serial.println(&amp;quot; &amp;quot;);&lt;br /&gt;
        Serial.print(&amp;quot;THRESHOLD1 = &amp;quot;);&lt;br /&gt;
        Serial.println(THRESHOLD1);   &lt;br /&gt;
        Serial.print(&amp;quot;THRESHOLD2 = &amp;quot;);&lt;br /&gt;
        Serial.println(THRESHOLD2); &lt;br /&gt;
        Serial.print(&amp;quot;THRESHOLD3 = &amp;quot;);&lt;br /&gt;
        Serial.println(THRESHOLD3); &lt;br /&gt;
        Serial.print(&amp;quot;THRESHOLD4 = &amp;quot;);&lt;br /&gt;
        Serial.println(THRESHOLD4);&lt;br /&gt;
        Serial.println(&amp;quot; &amp;quot;);&lt;br /&gt;
        if (digitalRead(duct1) == HIGH) {Serial.println(&amp;quot;duct1 ON&amp;quot;);}&lt;br /&gt;
        else{Serial.println(&amp;quot;duct1 OFF&amp;quot;);}&lt;br /&gt;
        if (digitalRead(duct2) == HIGH) {Serial.println(&amp;quot;duct2 ON&amp;quot;);}&lt;br /&gt;
        else{Serial.println(&amp;quot;duct2 OFF&amp;quot;);}&lt;br /&gt;
        if (digitalRead(duct3) == HIGH) {Serial.println(&amp;quot;duct3 ON&amp;quot;);}&lt;br /&gt;
        else{Serial.println(&amp;quot;duct3 OFF&amp;quot;);}&lt;br /&gt;
        if (digitalRead(duct4) == HIGH) {Serial.println(&amp;quot;duct4 ON&amp;quot;);}&lt;br /&gt;
        else{Serial.println(&amp;quot;duct4 OFF&amp;quot;);}&lt;br /&gt;
        Serial.println(&amp;quot; &amp;quot;);&lt;br /&gt;
        if (digitalRead(fan_on) == HIGH) {Serial.println(&amp;quot;Fan ON&amp;quot;);}&lt;br /&gt;
        else{Serial.println(&amp;quot;Fan OFF&amp;quot;);}&lt;br /&gt;
        if (digitalRead(ac_on) == HIGH) {Serial.println(&amp;quot;AC  ON&amp;quot;);}&lt;br /&gt;
        else{Serial.println(&amp;quot;AC  OFF&amp;quot;);}&lt;br /&gt;
        Serial.print(&amp;quot;A/C Delay (millisec) = &amp;quot;);&lt;br /&gt;
        Serial.println(ac_on_delay);&lt;br /&gt;
        Serial.print(&amp;quot;Temp Polling (millisec) = &amp;quot;);&lt;br /&gt;
        Serial.println(polltime);          &lt;br /&gt;
        Serial.println(&amp;quot; &amp;quot;);&lt;br /&gt;
        &lt;br /&gt;
      }&lt;br /&gt;
      else if (command == 81) {      //If command = &amp;quot;Q&amp;quot; Set Date&lt;br /&gt;
       setDateDs1307();&lt;br /&gt;
       getDateDs1307();&lt;br /&gt;
       Serial.println(&amp;quot; &amp;quot;);&lt;br /&gt;
      }&lt;br /&gt;
      Serial.println(command);     // Echo command char found in serial que&lt;br /&gt;
      command = 0;                 // reset command &lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
//*****************************************************The End***********************&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== A/C_Control_v.01 User Guide ==&lt;br /&gt;
==== Commands ====&lt;br /&gt;
== Troubleshooting ==&lt;br /&gt;
=== Summary ===&lt;br /&gt;
When Troubleshooting a multi-functional issue, it is best practice to break down the issue into pieces and test each piece as a separate system.  However, we will first run through a quick test to see if we can find any obvious issues first.&lt;br /&gt;
=== Quick Test ===&lt;/div&gt;</summary>
		<author><name>Combustor</name></author>	</entry>

	<entry>
		<id>http://combustory.com/wiki/index.php/The_MPGuino_-_Arduino_Code</id>
		<title>The MPGuino - Arduino Code</title>
		<link rel="alternate" type="text/html" href="http://combustory.com/wiki/index.php/The_MPGuino_-_Arduino_Code"/>
				<updated>2008-09-10T14:50:32Z</updated>
		
		<summary type="html">&lt;p&gt;Combustor: /* MPGuino.pde Code v.701 */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{default}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Check here for any updates http://opengauge.googlecode.com/svn/trunk/mpguino/mpguino.pde'''&lt;br /&gt;
&lt;br /&gt;
== MPGuino.pde Code v.701 ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#define ver=701&lt;br /&gt;
/*&lt;br /&gt;
&lt;br /&gt;
*/&lt;br /&gt;
//GPL Software    &lt;br /&gt;
//#define debuguino youbetyourbippy  &lt;br /&gt;
#include &amp;lt;avr/pgmspace.h&amp;gt;  &lt;br /&gt;
byte brightness[]={0,42,85,128}; //middle button cycles through these brightness settings      &lt;br /&gt;
#define brightnessLength (sizeof(brightness)/sizeof(byte)) //array size      &lt;br /&gt;
byte brightnessIdx=1;      &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
#define contrastIdx 0  //do contrast first to get display dialed in&lt;br /&gt;
#define vssPulsesPerMileIdx 1&lt;br /&gt;
#define microSecondsPerGallonIdx 2&lt;br /&gt;
#define injPulsesPer2Revolutions 3&lt;br /&gt;
#define currentTripResetTimeoutUSIdx 4&lt;br /&gt;
#define tankSizeIdx 5 &lt;br /&gt;
#define injectorSettleTimeIdx 6&lt;br /&gt;
#define weightIdx 7&lt;br /&gt;
#define scratchpadIdx 8&lt;br /&gt;
char *  parmLabels[]={&amp;quot;Contrast&amp;quot;,&amp;quot;VSS Pulses/Mile&amp;quot;, &amp;quot;MicroSec/Gallon&amp;quot;,&amp;quot;Pulses/2 revs&amp;quot;,&amp;quot;Timout(microSec)&amp;quot;,&amp;quot;Tank Gal * 1000&amp;quot;,&amp;quot;Injector DelayuS&amp;quot;,&amp;quot;Weight (lbs)&amp;quot;,&amp;quot;scratchpad(odo?)&amp;quot;};&lt;br /&gt;
//unsigned long  parms[]={15ul,16408ul,684968626ul,3ul,420000000ul,13300ul,500ul};//default values&lt;br /&gt;
unsigned long  parms[]={15ul,10000ul,304409714ul,4ul,420000000ul,13300ul,500ul,2400ul,0ul,};//default values&lt;br /&gt;
#define parmsLength (sizeof(parms)/sizeof(unsigned long)) //array size      &lt;br /&gt;
&lt;br /&gt;
#define nil 3999999999ul&lt;br /&gt;
 &lt;br /&gt;
#define guinosig B10100101&lt;br /&gt;
#include &amp;lt;EEPROM.h&amp;gt;&lt;br /&gt;
//Vehicle Interface Pins      &lt;br /&gt;
#define InjectorOpenPin 2      &lt;br /&gt;
#define InjectorClosedPin 3      &lt;br /&gt;
#define VSSPin 14 //analog 0      &lt;br /&gt;
 &lt;br /&gt;
//LCD Pins      &lt;br /&gt;
#define DIPin 4 // register select RS      &lt;br /&gt;
#define DB4Pin 7       &lt;br /&gt;
#define DB5Pin 8       &lt;br /&gt;
#define DB6Pin 12       &lt;br /&gt;
#define DB7Pin 13      &lt;br /&gt;
#define ContrastPin 6      &lt;br /&gt;
#define EnablePin 5       &lt;br /&gt;
#define BrightnessPin 9      &lt;br /&gt;
 &lt;br /&gt;
#define lbuttonPin 17 // Left Button, on analog 3,        &lt;br /&gt;
#define mbuttonPin 18 // Middle Button, on analog 4       &lt;br /&gt;
#define rbuttonPin 19 // Right Button, on analog 5       &lt;br /&gt;
 &lt;br /&gt;
#define vssBit 1     //  pin14 is a bitmask 1 on port C        &lt;br /&gt;
#define lbuttonBit 8 //  pin17 is a bitmask 8 on port C        &lt;br /&gt;
#define mbuttonBit 16 // pin18 is a bitmask 16 on port C        &lt;br /&gt;
#define rbuttonBit 32 // pin19 is a bitmask 32 on port C        &lt;br /&gt;
#define loopsPerSecond 2 // how many times will we try and loop in a second     &lt;br /&gt;
&lt;br /&gt;
typedef void (* pFunc)(void);//type for display function pointers      &lt;br /&gt;
&lt;br /&gt;
volatile unsigned long timer2_overflow_count;&lt;br /&gt;
&lt;br /&gt;
/*** Set up the Events ***&lt;br /&gt;
We have our own ISR for timer2 which gets called about once a millisecond.&lt;br /&gt;
So we define certain event functions that we can schedule by calling addEvent&lt;br /&gt;
with the event ID and the number of milliseconds to wait before calling the event. &lt;br /&gt;
The milliseconds is approximate.&lt;br /&gt;
&lt;br /&gt;
Keep the event functions SMALL!!!  This is an interrupt!&lt;br /&gt;
&lt;br /&gt;
*/&lt;br /&gt;
//event functions&lt;br /&gt;
&lt;br /&gt;
void enableLButton(){PCMSK1 |= (1 &amp;lt;&amp;lt; PCINT11);}&lt;br /&gt;
void enableMButton(){PCMSK1 |= (1 &amp;lt;&amp;lt; PCINT12);}&lt;br /&gt;
void enableRButton(){PCMSK1 |= (1 &amp;lt;&amp;lt; PCINT13);}&lt;br /&gt;
//array of the event functions&lt;br /&gt;
pFunc eventFuncs[] ={enableVSS, enableLButton,enableMButton,enableRButton};&lt;br /&gt;
#define eventFuncSize (sizeof(eventFuncs)/sizeof(pFunc)) &lt;br /&gt;
//define the event IDs&lt;br /&gt;
#define enableVSSID 0&lt;br /&gt;
#define enableLButtonID 1&lt;br /&gt;
#define enableMButtonID 2&lt;br /&gt;
#define enableRButtonID 3&lt;br /&gt;
//ms counters&lt;br /&gt;
unsigned int eventFuncCounts[eventFuncSize];&lt;br /&gt;
&lt;br /&gt;
//schedule an event to occur ms milliseconds from now&lt;br /&gt;
void addEvent(byte eventID, unsigned int ms){&lt;br /&gt;
  eventFuncCounts[eventID]=ms;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
/* this ISR gets called every 1.024 milliseconds, we will call that a millisecond for our purposes&lt;br /&gt;
go through all the event counts, &lt;br /&gt;
  if any are non zero subtract 1 and call the associated function if it just turned zero.  */&lt;br /&gt;
ISR(TIMER2_OVF_vect){&lt;br /&gt;
  timer2_overflow_count++;&lt;br /&gt;
  for(byte eventID = 0; eventID &amp;lt; eventFuncSize; eventID++){&lt;br /&gt;
    if(eventFuncCounts[eventID]!= 0){&lt;br /&gt;
      eventFuncCounts[eventID]--;&lt;br /&gt;
      if(eventFuncCounts[eventID] == 0)&lt;br /&gt;
          eventFuncs[eventID](); &lt;br /&gt;
    }  &lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
unsigned long maxLoopLength = 0; //see if we are overutilizing the CPU      &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
#define buttonsUp   lbuttonBit + mbuttonBit + rbuttonBit  // start with the buttons in the right state      &lt;br /&gt;
byte buttonState = buttonsUp;      &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
//overflow counter used by millis2()      &lt;br /&gt;
unsigned long lastMicroSeconds=millis2() * 1000;   &lt;br /&gt;
unsigned long microSeconds (void){     &lt;br /&gt;
  unsigned long tmp_timer2_overflow_count;    &lt;br /&gt;
  unsigned long tmp;    &lt;br /&gt;
  byte tmp_tcnt2;    &lt;br /&gt;
  cli(); //disable interrupts    &lt;br /&gt;
  tmp_timer2_overflow_count = timer2_overflow_count;    &lt;br /&gt;
  tmp_tcnt2 = TCNT2;    &lt;br /&gt;
  sei(); // enable interrupts    &lt;br /&gt;
  tmp = ((tmp_timer2_overflow_count &amp;lt;&amp;lt; 8) + tmp_tcnt2) * 4;     &lt;br /&gt;
  if((tmp&amp;lt;=lastMicroSeconds) &amp;amp;&amp;amp; (lastMicroSeconds&amp;lt;4290560000ul))    &lt;br /&gt;
    return microSeconds();     &lt;br /&gt;
  lastMicroSeconds=tmp;   &lt;br /&gt;
  return tmp;     &lt;br /&gt;
}    &lt;br /&gt;
 &lt;br /&gt;
unsigned long elapsedMicroseconds(unsigned long startMicroSeconds, unsigned long currentMicroseconds ){      &lt;br /&gt;
  if(currentMicroseconds &amp;gt;= startMicroSeconds)      &lt;br /&gt;
    return currentMicroseconds-startMicroSeconds;      &lt;br /&gt;
  return 4294967295 - (startMicroSeconds-currentMicroseconds);      &lt;br /&gt;
}      &lt;br /&gt;
&lt;br /&gt;
unsigned long elapsedMicroseconds(unsigned long startMicroSeconds ){      &lt;br /&gt;
  return elapsedMicroseconds(startMicroSeconds, microSeconds());&lt;br /&gt;
}      &lt;br /&gt;
 &lt;br /&gt;
//Trip prototype      &lt;br /&gt;
class Trip{      &lt;br /&gt;
public:      &lt;br /&gt;
  unsigned long loopCount; //how long has this trip been running      &lt;br /&gt;
  unsigned long injPulses; //rpm      &lt;br /&gt;
  unsigned long injHiSec;// seconds the injector has been open      &lt;br /&gt;
  unsigned long injHius;// microseconds, fractional part of the injectors open       &lt;br /&gt;
  unsigned long vssPulses;//from the speedo      &lt;br /&gt;
  unsigned long vssPulseLength; // only used by instant&lt;br /&gt;
  //these functions actually return in thousandths,       &lt;br /&gt;
  unsigned long miles();        &lt;br /&gt;
  unsigned long gallons();      &lt;br /&gt;
  unsigned long mpg();        &lt;br /&gt;
  unsigned long mph();        &lt;br /&gt;
  unsigned long time(); //mmm.ss        &lt;br /&gt;
  void update(Trip t);      &lt;br /&gt;
  void reset();      &lt;br /&gt;
  Trip();      &lt;br /&gt;
};      &lt;br /&gt;
 &lt;br /&gt;
//LCD prototype      &lt;br /&gt;
namespace LCD{      &lt;br /&gt;
  void gotoXY(byte x, byte y);      &lt;br /&gt;
  void print(char * string);      &lt;br /&gt;
  void init();      &lt;br /&gt;
  void tickleEnable();      &lt;br /&gt;
  void cmdWriteSet();      &lt;br /&gt;
  void LcdCommandWrite(byte value);      &lt;br /&gt;
  void LcdDataWrite(byte value);      &lt;br /&gt;
  byte pushNibble(byte value);      &lt;br /&gt;
};      &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
//main objects we will be working with:      &lt;br /&gt;
unsigned long injHiStart; //for timing injector pulses      &lt;br /&gt;
Trip tmpTrip;      &lt;br /&gt;
Trip instant;      &lt;br /&gt;
Trip current;      &lt;br /&gt;
Trip tank;      &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
unsigned volatile long instInjStart=nil; &lt;br /&gt;
unsigned volatile long tmpInstInjStart=nil; &lt;br /&gt;
unsigned volatile long instInjEnd; &lt;br /&gt;
unsigned volatile long tmpInstInjEnd; &lt;br /&gt;
unsigned volatile long instInjTot; &lt;br /&gt;
unsigned volatile long tmpInstInjTot;     &lt;br /&gt;
unsigned volatile long instInjCount; &lt;br /&gt;
unsigned volatile long tmpInstInjCount;     &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
void processInjOpen(void){      &lt;br /&gt;
  injHiStart = microSeconds();  &lt;br /&gt;
  if (tmpInstInjStart == nil)&lt;br /&gt;
    tmpInstInjStart=injHiStart;&lt;br /&gt;
  tmpInstInjEnd=injHiStart;&lt;br /&gt;
}      &lt;br /&gt;
 &lt;br /&gt;
void processInjClosed(void){      &lt;br /&gt;
  long x = elapsedMicroseconds(injHiStart)- parms[injectorSettleTimeIdx];       &lt;br /&gt;
  if(x &amp;gt;0)&lt;br /&gt;
    tmpTrip.injHius += x;       &lt;br /&gt;
  tmpTrip.injPulses++;      &lt;br /&gt;
&lt;br /&gt;
  if (tmpInstInjStart != nil){&lt;br /&gt;
    if(x &amp;gt;0)&lt;br /&gt;
      tmpInstInjTot += x;     &lt;br /&gt;
      tmpInstInjCount++;&lt;br /&gt;
  }  &lt;br /&gt;
}      &lt;br /&gt;
&lt;br /&gt;
volatile boolean vssFlop = 0;&lt;br /&gt;
&lt;br /&gt;
void enableVSS(){&lt;br /&gt;
//    tmpTrip.vssPulses++; &lt;br /&gt;
    vssFlop = !vssFlop;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
unsigned volatile long lastVSS1;&lt;br /&gt;
unsigned volatile long lastVSSTime;&lt;br /&gt;
unsigned volatile long lastVSS2;&lt;br /&gt;
&lt;br /&gt;
volatile boolean lastVssFlop = vssFlop;&lt;br /&gt;
&lt;br /&gt;
//attach the vss/buttons interrupt      &lt;br /&gt;
ISR( PCINT1_vect ){   &lt;br /&gt;
  static byte vsspinstate=0;      &lt;br /&gt;
  byte p = PINC;//bypassing digitalRead for interrupt performance      &lt;br /&gt;
  if ((p &amp;amp; vssBit) != (vsspinstate &amp;amp; vssBit)){      &lt;br /&gt;
    addEvent(enableVSSID,2 ); //check back in a couple milli&lt;br /&gt;
  }&lt;br /&gt;
  if(lastVssFlop != vssFlop){&lt;br /&gt;
    lastVSS1=lastVSS2;&lt;br /&gt;
    unsigned long t = microSeconds();&lt;br /&gt;
    lastVSS2=elapsedMicroseconds(lastVSSTime,t);&lt;br /&gt;
    lastVSSTime=t;&lt;br /&gt;
    tmpTrip.vssPulses++; &lt;br /&gt;
    tmpTrip.vssPulseLength += lastVSS2;&lt;br /&gt;
    lastVssFlop = vssFlop;&lt;br /&gt;
  }&lt;br /&gt;
  vsspinstate = p;      &lt;br /&gt;
  buttonState &amp;amp;= p;      &lt;br /&gt;
}       &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
pFunc displayFuncs[] ={ &lt;br /&gt;
  doDisplayCustom, &lt;br /&gt;
  doDisplayInstantCurrent, &lt;br /&gt;
  doDisplayInstantTank, &lt;br /&gt;
#ifndef debuguino  //need to make room for Serial, so BigNums is out in debug mode&lt;br /&gt;
  doDisplayBigInstant, &lt;br /&gt;
  doDisplayBigCurrent, &lt;br /&gt;
  doDisplayBigTank, &lt;br /&gt;
#endif  &lt;br /&gt;
  doDisplay2, &lt;br /&gt;
  doDisplay3, &lt;br /&gt;
  doDisplay4, &lt;br /&gt;
  doDisplay5, &lt;br /&gt;
  doDisplay6, &lt;br /&gt;
  doDisplay7};      &lt;br /&gt;
#define displayFuncSize (sizeof(displayFuncs)/sizeof(pFunc)) //array size      &lt;br /&gt;
prog_char  * displayFuncNames[displayFuncSize]; &lt;br /&gt;
byte newRun = 0;&lt;br /&gt;
void setup (void){&lt;br /&gt;
  init2();&lt;br /&gt;
  #ifdef debuguino  &lt;br /&gt;
  Serial.begin(9600);  &lt;br /&gt;
  Serial.println(&amp;quot;OpenGauge MPGuino online&amp;quot;);  &lt;br /&gt;
  #endif      &lt;br /&gt;
  newRun = load();//load the default parameters&lt;br /&gt;
  byte x = 0;&lt;br /&gt;
  displayFuncNames[x++]=  PSTR(&amp;quot;Custom &amp;quot;); &lt;br /&gt;
  displayFuncNames[x++]=  PSTR(&amp;quot;Instant/Current &amp;quot;); &lt;br /&gt;
  displayFuncNames[x++]=  PSTR(&amp;quot;Instant/Tank &amp;quot;); &lt;br /&gt;
#ifndef debuguino  &lt;br /&gt;
  displayFuncNames[x++]=  PSTR(&amp;quot;BIG Instant &amp;quot;); &lt;br /&gt;
  displayFuncNames[x++]=  PSTR(&amp;quot;BIG Current &amp;quot;); &lt;br /&gt;
  displayFuncNames[x++]=  PSTR(&amp;quot;BIG Tank &amp;quot;); &lt;br /&gt;
#endif&lt;br /&gt;
  displayFuncNames[x++]=  PSTR(&amp;quot;Current &amp;quot;); &lt;br /&gt;
  displayFuncNames[x++]=  PSTR(&amp;quot;Tank &amp;quot;); &lt;br /&gt;
  displayFuncNames[x++]=  PSTR(&amp;quot;Instant raw Data&amp;quot;); &lt;br /&gt;
  displayFuncNames[x++]=  PSTR(&amp;quot;Current raw Data&amp;quot;); &lt;br /&gt;
  displayFuncNames[x++]=  PSTR(&amp;quot;Tank raw Data &amp;quot;); &lt;br /&gt;
  displayFuncNames[x++]= PSTR(&amp;quot;CPU Monitor &amp;quot;);      &lt;br /&gt;
 &lt;br /&gt;
  pinMode(BrightnessPin,OUTPUT);      &lt;br /&gt;
  analogWrite(BrightnessPin,255-brightness[brightnessIdx]);      &lt;br /&gt;
  pinMode(EnablePin,OUTPUT);       &lt;br /&gt;
  pinMode(DIPin,OUTPUT);       &lt;br /&gt;
  pinMode(DB4Pin,OUTPUT);       &lt;br /&gt;
  pinMode(DB5Pin,OUTPUT);       &lt;br /&gt;
  pinMode(DB6Pin,OUTPUT);       &lt;br /&gt;
  pinMode(DB7Pin,OUTPUT);       &lt;br /&gt;
  delay2(500);      &lt;br /&gt;
 &lt;br /&gt;
  pinMode(ContrastPin,OUTPUT);      &lt;br /&gt;
  analogWrite(ContrastPin,parms[contrastIdx]);  &lt;br /&gt;
  LCD::init();      &lt;br /&gt;
  LCD::LcdCommandWrite(B00000001);  // clear display, set cursor position to zero         &lt;br /&gt;
  LCD::LcdCommandWrite(B10000000);  // set dram to zero&lt;br /&gt;
  LCD::gotoXY(0,0); &lt;br /&gt;
  LCD::print(getStr(PSTR(&amp;quot;OpenGauge       &amp;quot;)));      &lt;br /&gt;
  LCD::gotoXY(0,1);      &lt;br /&gt;
  LCD::print(getStr(PSTR(&amp;quot;  MPGuino  v0.71&amp;quot;)));      &lt;br /&gt;
&lt;br /&gt;
  pinMode(InjectorOpenPin, INPUT);       &lt;br /&gt;
  pinMode(InjectorClosedPin, INPUT);       &lt;br /&gt;
  pinMode(VSSPin, INPUT);            &lt;br /&gt;
  attachInterrupt(0, processInjOpen, FALLING);      &lt;br /&gt;
  attachInterrupt(1, processInjClosed, RISING);      &lt;br /&gt;
 &lt;br /&gt;
  pinMode( lbuttonPin, INPUT );       &lt;br /&gt;
  pinMode( mbuttonPin, INPUT );       &lt;br /&gt;
  pinMode( rbuttonPin, INPUT );      &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
  //&amp;quot;turn on&amp;quot; the internal pullup resistors      &lt;br /&gt;
  digitalWrite( lbuttonPin, HIGH);       &lt;br /&gt;
  digitalWrite( mbuttonPin, HIGH);       &lt;br /&gt;
  digitalWrite( rbuttonPin, HIGH);       &lt;br /&gt;
//  digitalWrite( VSSPin, HIGH);       &lt;br /&gt;
 &lt;br /&gt;
  //low level interrupt enable stuff      &lt;br /&gt;
  PCMSK1 |= (1 &amp;lt;&amp;lt; PCINT8);&lt;br /&gt;
  enableLButton();&lt;br /&gt;
  enableMButton();&lt;br /&gt;
  enableRButton();&lt;br /&gt;
  PCICR |= (1 &amp;lt;&amp;lt; PCIE1);       &lt;br /&gt;
 &lt;br /&gt;
  delay2(1500);       &lt;br /&gt;
}       &lt;br /&gt;
 &lt;br /&gt;
byte screen=0;      &lt;br /&gt;
byte holdDisplay = 0; &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
#define looptime 1000000ul/loopsPerSecond //1/2 second      &lt;br /&gt;
void loop (void){       &lt;br /&gt;
  if(newRun !=1)&lt;br /&gt;
    initGuino();//go through the initialization screen&lt;br /&gt;
  unsigned long lastActivity =microSeconds();&lt;br /&gt;
  unsigned long tankHold;      //state at point of last activity&lt;br /&gt;
  while(true){      &lt;br /&gt;
    unsigned long loopStart=microSeconds();      &lt;br /&gt;
    instant.reset();           //clear instant      &lt;br /&gt;
    cli();&lt;br /&gt;
    instant.update(tmpTrip);   //&amp;quot;copy&amp;quot; of tmpTrip in instant now      &lt;br /&gt;
    tmpTrip.reset();           //reset tmpTrip first so we don't lose too many interrupts      &lt;br /&gt;
    instInjStart=tmpInstInjStart; &lt;br /&gt;
    instInjEnd=tmpInstInjEnd; &lt;br /&gt;
    instInjTot=tmpInstInjTot;     &lt;br /&gt;
    instInjCount=tmpInstInjCount;&lt;br /&gt;
    &lt;br /&gt;
    tmpInstInjStart=nil; &lt;br /&gt;
    tmpInstInjEnd=nil; &lt;br /&gt;
    tmpInstInjTot=0;     &lt;br /&gt;
    tmpInstInjCount=0;&lt;br /&gt;
&lt;br /&gt;
    sei();&lt;br /&gt;
    #ifdef debuguino  &lt;br /&gt;
//    Serial.print(&amp;quot;instant: &amp;quot;);Serial.print(instant.injHiSec);Serial.print(&amp;quot;,&amp;quot;);Serial.print(instant.injHius);  &lt;br /&gt;
//    Serial.print(&amp;quot;,&amp;quot;);Serial.print(instant.injPulses);Serial.print(&amp;quot;,&amp;quot;);Serial.println(instant.vssPulses);      &lt;br /&gt;
    #endif  &lt;br /&gt;
    current.update(instant);   //use instant to update current      &lt;br /&gt;
    tank.update(instant);      //use instant to update tank      &lt;br /&gt;
    #ifdef debuguino  &lt;br /&gt;
//    Serial.print(&amp;quot;current: &amp;quot;);Serial.print(current.injHiSec);Serial.print(&amp;quot;,&amp;quot;);Serial.print(current.injHius);  &lt;br /&gt;
//    Serial.print(&amp;quot;,&amp;quot;);Serial.print(current.injPulses);Serial.print(&amp;quot;,&amp;quot;);Serial.println(current.vssPulses);      &lt;br /&gt;
    #endif  &lt;br /&gt;
&lt;br /&gt;
//currentTripResetTimeoutUS&lt;br /&gt;
    if(instant.vssPulses == 0 &amp;amp;&amp;amp; instant.injPulses == 0 &amp;amp;&amp;amp; holdDisplay==0){&lt;br /&gt;
      if(elapsedMicroseconds(lastActivity) &amp;gt; parms[currentTripResetTimeoutUSIdx] &amp;amp;&amp;amp; lastActivity != nil){&lt;br /&gt;
        analogWrite(BrightnessPin,255-brightness[0]);    //nitey night&lt;br /&gt;
        lastActivity = nil;&lt;br /&gt;
      }&lt;br /&gt;
    }else{&lt;br /&gt;
      if(lastActivity == nil){//wake up!!!&lt;br /&gt;
        analogWrite(BrightnessPin,255-brightness[brightnessIdx]);    &lt;br /&gt;
        lastActivity=loopStart;&lt;br /&gt;
        current.reset();&lt;br /&gt;
        tank.loopCount = tankHold;&lt;br /&gt;
        current.update(instant); &lt;br /&gt;
        tank.update(instant); &lt;br /&gt;
      }else{&lt;br /&gt;
        lastActivity=loopStart;&lt;br /&gt;
        tankHold = tank.loopCount;&lt;br /&gt;
      }&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
 if(holdDisplay==0){&lt;br /&gt;
    displayFuncs[screen]();    //call the appropriate display routine      &lt;br /&gt;
    LCD::gotoXY(0,0);        &lt;br /&gt;
    &lt;br /&gt;
//see if any buttons were pressed, display a brief message if so      &lt;br /&gt;
      if(!(buttonState&amp;amp;lbuttonBit) &amp;amp;&amp;amp; !(buttonState&amp;amp;mbuttonBit)&amp;amp;&amp;amp; !(buttonState&amp;amp;rbuttonBit)){// left and middle and right = initialize      &lt;br /&gt;
          LCD::print(getStr(PSTR(&amp;quot;Setup &amp;quot;)));    &lt;br /&gt;
          initGuino();  &lt;br /&gt;
      //}else if(!(buttonState&amp;amp;lbuttonBit) &amp;amp;&amp;amp; !(buttonState&amp;amp;rbuttonBit)){// left and right = run lcd init = tank reset      &lt;br /&gt;
      //    LCD::print(getStr(PSTR(&amp;quot;Init LCD &amp;quot;))); &lt;br /&gt;
      //    LCD::init();&lt;br /&gt;
      }else if (!(buttonState&amp;amp;lbuttonBit) &amp;amp;&amp;amp; !(buttonState&amp;amp;mbuttonBit)){// left and middle = tank reset      &lt;br /&gt;
          tank.reset();      &lt;br /&gt;
          LCD::print(getStr(PSTR(&amp;quot;Tank Reset &amp;quot;)));      &lt;br /&gt;
      }else if(!(buttonState&amp;amp;mbuttonBit) &amp;amp;&amp;amp; !(buttonState&amp;amp;rbuttonBit)){// right and middle = current reset      &lt;br /&gt;
          current.reset();      &lt;br /&gt;
          LCD::print(getStr(PSTR(&amp;quot;Current Reset &amp;quot;)));      &lt;br /&gt;
      }else if(!(buttonState&amp;amp;lbuttonBit)){ //left is rotate through screeens to the left      &lt;br /&gt;
        if(screen!=0)      &lt;br /&gt;
          screen=(screen-1);       &lt;br /&gt;
        else      &lt;br /&gt;
          screen=displayFuncSize-1;      &lt;br /&gt;
        LCD::print(getStr(displayFuncNames[screen]));      &lt;br /&gt;
      }else if(!(buttonState&amp;amp;mbuttonBit)){ //middle is cycle through brightness settings      &lt;br /&gt;
        brightnessIdx = (brightnessIdx + 1) % brightnessLength;      &lt;br /&gt;
        analogWrite(BrightnessPin,255-brightness[brightnessIdx]);      &lt;br /&gt;
        LCD::print(getStr(PSTR(&amp;quot;Brightness &amp;quot;)));      &lt;br /&gt;
        LCD::LcdDataWrite('0' + brightnessIdx);      &lt;br /&gt;
        LCD::print(&amp;quot; &amp;quot;);      &lt;br /&gt;
      }else if(!(buttonState&amp;amp;rbuttonBit)){//right is rotate through screeens to the left      &lt;br /&gt;
        screen=(screen+1)%displayFuncSize;      &lt;br /&gt;
        LCD::print(getStr(displayFuncNames[screen]));      &lt;br /&gt;
      }      &lt;br /&gt;
      if(buttonState!=buttonsUp)&lt;br /&gt;
         holdDisplay=1;&lt;br /&gt;
     }else{&lt;br /&gt;
        holdDisplay=0;&lt;br /&gt;
    } &lt;br /&gt;
    buttonState=buttonsUp;//reset the buttons      &lt;br /&gt;
 &lt;br /&gt;
      //keep track of how long the loops take before we go int waiting.      &lt;br /&gt;
      unsigned long loopX=elapsedMicroseconds(loopStart);      &lt;br /&gt;
      if(loopX&amp;gt;maxLoopLength) maxLoopLength = loopX;      &lt;br /&gt;
 &lt;br /&gt;
      while (elapsedMicroseconds(loopStart) &amp;lt; (looptime));//wait for the end of a second to arrive      &lt;br /&gt;
  }      &lt;br /&gt;
 &lt;br /&gt;
}       &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
char fBuff[7];//used by format      &lt;br /&gt;
//format a number into NNN.NN  the number should already be representing thousandths      &lt;br /&gt;
char* format(unsigned long num){      &lt;br /&gt;
  unsigned long d = 10000;      &lt;br /&gt;
  long t;      &lt;br /&gt;
  byte dp=3;      &lt;br /&gt;
  byte l=6;      &lt;br /&gt;
 &lt;br /&gt;
  //123456 = 123.46      &lt;br /&gt;
  if(num&amp;gt;9999999){      &lt;br /&gt;
    d=100000;      &lt;br /&gt;
    dp=99;      &lt;br /&gt;
    num/=100;      &lt;br /&gt;
  }else if(num&amp;gt;999999){      &lt;br /&gt;
    dp=4;      &lt;br /&gt;
    num/=10;      &lt;br /&gt;
  }      &lt;br /&gt;
 &lt;br /&gt;
  unsigned long val = num/10;      &lt;br /&gt;
  if ((num - (val * 10)) &amp;gt;= 5)  //will the first unprinted digit be greater than 4?      &lt;br /&gt;
    val += 1;   //round up val      &lt;br /&gt;
 &lt;br /&gt;
  for(byte x = 0; x &amp;lt; l; x++){      &lt;br /&gt;
    if(x==dp)      //time to poke in the decimal point?      &lt;br /&gt;
      fBuff[x]='.';      &lt;br /&gt;
    else{      &lt;br /&gt;
      t = val/d;        &lt;br /&gt;
      fBuff[x]= '0' + t%10;//poke the ascii character for the digit.      &lt;br /&gt;
      val-= t*d;      &lt;br /&gt;
      d/=10;            &lt;br /&gt;
    }      &lt;br /&gt;
  }      &lt;br /&gt;
  fBuff[6]= 0;         //good old zero terminated strings       &lt;br /&gt;
  return fBuff;      &lt;br /&gt;
}  &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
//get a string from flash &lt;br /&gt;
char mBuff[17];//used by getStr &lt;br /&gt;
char * getStr(prog_char * str){ &lt;br /&gt;
  strcpy_P(mBuff, str); &lt;br /&gt;
  return mBuff; &lt;br /&gt;
} &lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
void doDisplayCustom(){displayTripCombo('I','M',instantmpg(),'S',instantmph(),'R','P',instantrpm(),'C',current.mpg());}      &lt;br /&gt;
void doDisplayInstantCurrent(){displayTripCombo('I','M',instantmpg(),'S',instantmph(),'C','M',current.mpg(),'D',current.miles());}      &lt;br /&gt;
 &lt;br /&gt;
void doDisplayInstantTank(){displayTripCombo('I','M',instantmpg(),'S',instantmph(),'T','M',tank.mpg(),'D',tank.miles());}      &lt;br /&gt;
&lt;br /&gt;
#ifndef debuguino  &lt;br /&gt;
void doDisplayBigInstant() {bigNum(instant.mpg(),&amp;quot;INST&amp;quot;,&amp;quot;MPG &amp;quot;);}      &lt;br /&gt;
void doDisplayBigCurrent() {bigNum(current.mpg(),&amp;quot;CURR&amp;quot;,&amp;quot;MPG &amp;quot;);}      &lt;br /&gt;
void doDisplayBigTank()    {bigNum(tank.mpg(),&amp;quot;TANK&amp;quot;,&amp;quot;MPG &amp;quot;);}      &lt;br /&gt;
#endif &lt;br /&gt;
 &lt;br /&gt;
void doDisplay2(void){tDisplay(&amp;amp;current);}   //display current trip formatted data.        &lt;br /&gt;
void doDisplay3(void){tDisplay(&amp;amp;tank);}      //display tank trip formatted data.        &lt;br /&gt;
void doDisplay4(void){rawDisplay(&amp;amp;instant);} //display instant trip &amp;quot;raw&amp;quot; injector and vss data.        &lt;br /&gt;
void doDisplay5(void){rawDisplay(&amp;amp;current);} //display current trip &amp;quot;raw&amp;quot; injector and vss data.        &lt;br /&gt;
void doDisplay6(void){rawDisplay(&amp;amp;tank);}    //display tank trip &amp;quot;raw&amp;quot; injector and vss data.        &lt;br /&gt;
void doDisplay7(void){      &lt;br /&gt;
  LCD::gotoXY(0,0);LCD::print(&amp;quot;C%&amp;quot;);LCD::print(format(maxLoopLength*1000/(looptime/100)));LCD::print(&amp;quot; T&amp;quot;); LCD::print(format(tank.time()));     &lt;br /&gt;
  unsigned long mem = memoryTest();      &lt;br /&gt;
  mem*=1000;      &lt;br /&gt;
  LCD::gotoXY(0,1);LCD::print(&amp;quot;FREE MEM: &amp;quot;);LCD::print(format(mem));      &lt;br /&gt;
}    //display max cpu utilization and ram.        &lt;br /&gt;
 &lt;br /&gt;
void displayTripCombo(char t1, char t1L1, unsigned long t1V1, char t1L2, unsigned long t1V2,  char t2, char t2L1, unsigned long t2V1, char t2L2, unsigned long t2V2){ &lt;br /&gt;
  LCD::gotoXY(0,0);LCD::LcdDataWrite(t1);LCD::LcdDataWrite(t1L1);LCD::print(format(t1V1));LCD::LcdDataWrite(' '); &lt;br /&gt;
      LCD::LcdDataWrite(t1L2);LCD::print(format(t1V2)); &lt;br /&gt;
  LCD::gotoXY(0,1);LCD::LcdDataWrite(t2);LCD::LcdDataWrite(t2L1);LCD::print(format(t2V1));LCD::LcdDataWrite(' '); &lt;br /&gt;
      LCD::LcdDataWrite(t2L2);LCD::print(format(t2V2)); &lt;br /&gt;
}      &lt;br /&gt;
 &lt;br /&gt;
//arduino doesn't do well with types defined in a script as parameters, so have to pass as void * and use -&amp;gt; notation.      &lt;br /&gt;
void tDisplay( void * r){ //display trip functions.        &lt;br /&gt;
  Trip *t = (Trip *)r;      &lt;br /&gt;
  LCD::gotoXY(0,0);LCD::print(&amp;quot;MH&amp;quot;);LCD::print(format(t-&amp;gt;mph()));LCD::print(&amp;quot;MG&amp;quot;);LCD::print(format(t-&amp;gt;mpg()));      &lt;br /&gt;
  LCD::gotoXY(0,1);LCD::print(&amp;quot;MI&amp;quot;);LCD::print(format(t-&amp;gt;miles()));LCD::print(&amp;quot;GA&amp;quot;);LCD::print(format(t-&amp;gt;gallons()));      &lt;br /&gt;
}      &lt;br /&gt;
 &lt;br /&gt;
void rawDisplay(void * r){      &lt;br /&gt;
  Trip *t = (Trip *)r;      &lt;br /&gt;
  LCD::gotoXY(0,0);LCD::print(&amp;quot;IJ&amp;quot;);LCD::print(format(t-&amp;gt;injHiSec*1000));LCD::print(&amp;quot;uS&amp;quot;);LCD::print(format(t-&amp;gt;injHius*1000));      &lt;br /&gt;
  LCD::gotoXY(0,1);LCD::print(&amp;quot;IC&amp;quot;);LCD::print(format(t-&amp;gt;injPulses*1000));LCD::print(&amp;quot;VC&amp;quot;);LCD::print(format(t-&amp;gt;vssPulses*1000));      &lt;br /&gt;
}      &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
    &lt;br /&gt;
//x=0..16, y= 0..1      &lt;br /&gt;
void LCD::gotoXY(byte x, byte y){      &lt;br /&gt;
  byte dr=x+0x80;      &lt;br /&gt;
  if (y==1)       &lt;br /&gt;
    dr += 0x40;      &lt;br /&gt;
  if (y==2)       &lt;br /&gt;
    dr += 0x14;      &lt;br /&gt;
  if (y==3)       &lt;br /&gt;
    dr += 0x54;      &lt;br /&gt;
  LCD::LcdCommandWrite(dr);        &lt;br /&gt;
}      &lt;br /&gt;
 &lt;br /&gt;
void LCD::print(char * string){      &lt;br /&gt;
  byte x = 0;      &lt;br /&gt;
  char c = string[x];      &lt;br /&gt;
  while(c != 0){      &lt;br /&gt;
    LCD::LcdDataWrite(c);       &lt;br /&gt;
    x++;      &lt;br /&gt;
    c = string[x];      &lt;br /&gt;
  }      &lt;br /&gt;
}      &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
void LCD::init(){&lt;br /&gt;
  delay2(16);                    // wait for more than 15 msec&lt;br /&gt;
  pushNibble(B00110000);  // send (B0011) to DB7-4&lt;br /&gt;
  cmdWriteSet();&lt;br /&gt;
  tickleEnable();&lt;br /&gt;
  delay2(5);                     // wait for more than 4.1 msec&lt;br /&gt;
  pushNibble(B00110000);  // send (B0011) to DB7-4&lt;br /&gt;
  cmdWriteSet();&lt;br /&gt;
  tickleEnable();&lt;br /&gt;
  delay2(1);                     // wait for more than 100 usec&lt;br /&gt;
  pushNibble(B00110000);  // send (B0011) to DB7-4&lt;br /&gt;
  cmdWriteSet();&lt;br /&gt;
  tickleEnable();&lt;br /&gt;
  delay2(1);                     // wait for more than 100 usec&lt;br /&gt;
  pushNibble(B00100000);  // send (B0010) to DB7-4 for 4bit&lt;br /&gt;
  cmdWriteSet();&lt;br /&gt;
  tickleEnable();&lt;br /&gt;
  delay2(1);                     // wait for more than 100 usec&lt;br /&gt;
  // ready to use normal LcdCommandWrite() function now!&lt;br /&gt;
  LcdCommandWrite(B00101000);   // 4-bit interface, 2 display lines, 5x8 font&lt;br /&gt;
  LcdCommandWrite(B00001100);   // display control:&lt;br /&gt;
  LcdCommandWrite(B00000110);   // entry mode set: increment automatically, no display shift&lt;br /&gt;
#ifndef debuguino &lt;br /&gt;
//creating the custom fonts:&lt;br /&gt;
  LcdCommandWrite(B01001000);  // set cgram&lt;br /&gt;
  static byte chars[] PROGMEM ={&lt;br /&gt;
    B11111,B00000,B11111,B11111,B00000,&lt;br /&gt;
    B11111,B00000,B11111,B11111,B00000,&lt;br /&gt;
    B11111,B00000,B11111,B11111,B00000,&lt;br /&gt;
    B00000,B00000,B00000,B11111,B00000,&lt;br /&gt;
    B00000,B00000,B00000,B11111,B00000,&lt;br /&gt;
    B00000,B11111,B11111,B11111,B01110,&lt;br /&gt;
    B00000,B11111,B11111,B11111,B01110,&lt;br /&gt;
    B00000,B11111,B11111,B11111,B01110};&lt;br /&gt;
&lt;br /&gt;
    for(byte x=0;x&amp;lt;5;x++)&lt;br /&gt;
      for(byte y=0;y&amp;lt;8;y++)&lt;br /&gt;
          LcdDataWrite(pgm_read_byte(&amp;amp;chars[y*5+x])); //write the character data to the character generator ram&lt;br /&gt;
#endif&lt;br /&gt;
  LcdCommandWrite(B00000001);  // clear display, set cursor position to zero&lt;br /&gt;
  LcdCommandWrite(B10000000);  // set dram to zero&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
void  LCD::tickleEnable(){       &lt;br /&gt;
  // send a pulse to enable       &lt;br /&gt;
  digitalWrite(EnablePin,HIGH);       &lt;br /&gt;
  delayMicroseconds2(1);  // pause 1 ms according to datasheet       &lt;br /&gt;
  digitalWrite(EnablePin,LOW);       &lt;br /&gt;
  delayMicroseconds2(1);  // pause 1 ms according to datasheet       &lt;br /&gt;
}        &lt;br /&gt;
 &lt;br /&gt;
void LCD::cmdWriteSet(){       &lt;br /&gt;
  digitalWrite(EnablePin,LOW);       &lt;br /&gt;
  delayMicroseconds2(1);  // pause 1 ms according to datasheet       &lt;br /&gt;
  digitalWrite(DIPin,0);       &lt;br /&gt;
}       &lt;br /&gt;
 &lt;br /&gt;
byte LCD::pushNibble(byte value){       &lt;br /&gt;
  digitalWrite(DB7Pin, value &amp;amp; 128);       &lt;br /&gt;
  value &amp;lt;&amp;lt;= 1;       &lt;br /&gt;
  digitalWrite(DB6Pin, value &amp;amp; 128);       &lt;br /&gt;
  value &amp;lt;&amp;lt;= 1;       &lt;br /&gt;
  digitalWrite(DB5Pin, value &amp;amp; 128);       &lt;br /&gt;
  value &amp;lt;&amp;lt;= 1;       &lt;br /&gt;
  digitalWrite(DB4Pin, value &amp;amp; 128);       &lt;br /&gt;
  value &amp;lt;&amp;lt;= 1;       &lt;br /&gt;
  return value;      &lt;br /&gt;
}      &lt;br /&gt;
 &lt;br /&gt;
void LCD::LcdCommandWrite(byte value){       &lt;br /&gt;
  value=pushNibble(value);      &lt;br /&gt;
  cmdWriteSet();       &lt;br /&gt;
  tickleEnable();       &lt;br /&gt;
  value=pushNibble(value);      &lt;br /&gt;
  cmdWriteSet();       &lt;br /&gt;
  tickleEnable();       &lt;br /&gt;
  delay2(5);       &lt;br /&gt;
}       &lt;br /&gt;
 &lt;br /&gt;
void LCD::LcdDataWrite(byte value){       &lt;br /&gt;
  digitalWrite(DIPin, HIGH);       &lt;br /&gt;
  value=pushNibble(value);      &lt;br /&gt;
  tickleEnable();       &lt;br /&gt;
  value=pushNibble(value);      &lt;br /&gt;
  tickleEnable();       &lt;br /&gt;
  delay2(5);       &lt;br /&gt;
}       &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
// this function will return the number of bytes currently free in RAM      &lt;br /&gt;
extern int  __bss_end; &lt;br /&gt;
extern int  *__brkval; &lt;br /&gt;
int memoryTest(){ &lt;br /&gt;
  int free_memory; &lt;br /&gt;
  if((int)__brkval == 0) &lt;br /&gt;
    free_memory = ((int)&amp;amp;free_memory) - ((int)&amp;amp;__bss_end); &lt;br /&gt;
  else &lt;br /&gt;
    free_memory = ((int)&amp;amp;free_memory) - ((int)__brkval); &lt;br /&gt;
  return free_memory; &lt;br /&gt;
} &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
Trip::Trip(){      &lt;br /&gt;
}      &lt;br /&gt;
 &lt;br /&gt;
//for display computing&lt;br /&gt;
unsigned long tmp1[2];&lt;br /&gt;
unsigned long tmp2[2];&lt;br /&gt;
unsigned long tmp3[2];&lt;br /&gt;
&lt;br /&gt;
unsigned long instantmph(){      &lt;br /&gt;
  //unsigned long vssPulseTimeuS = (lastVSS1 + lastVSS2) / 2;&lt;br /&gt;
  unsigned long vssPulseTimeuS = instant.vssPulseLength/instant.vssPulses;&lt;br /&gt;
  &lt;br /&gt;
  init64(tmp1,0,1000000000ul);&lt;br /&gt;
  init64(tmp2,0,parms[vssPulsesPerMileIdx]);&lt;br /&gt;
  div64(tmp1,tmp2);&lt;br /&gt;
  init64(tmp2,0,3600);&lt;br /&gt;
  mul64(tmp1,tmp2);&lt;br /&gt;
  init64(tmp2,0,vssPulseTimeuS);&lt;br /&gt;
  div64(tmp1,tmp2);&lt;br /&gt;
  return tmp1[1];&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
unsigned long instantmpg(){     &lt;br /&gt;
  unsigned long imph=instantmph();&lt;br /&gt;
  unsigned long igph=instantgph();&lt;br /&gt;
  init64(tmp1,0,1000ul);&lt;br /&gt;
  init64(tmp2,0,imph);&lt;br /&gt;
  mul64(tmp1,tmp2);&lt;br /&gt;
  init64(tmp2,0,igph);&lt;br /&gt;
  div64(tmp1,tmp2);&lt;br /&gt;
  return tmp1[1];&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
unsigned long instantgph(){      &lt;br /&gt;
//  unsigned long vssPulseTimeuS = instant.vssPulseLength/instant.vssPulses;&lt;br /&gt;
  &lt;br /&gt;
//  unsigned long instInjStart=nil; &lt;br /&gt;
//unsigned long instInjEnd; &lt;br /&gt;
//unsigned long instInjTot; &lt;br /&gt;
  init64(tmp1,0,instInjTot);&lt;br /&gt;
  init64(tmp2,0,3600000000ul);&lt;br /&gt;
  mul64(tmp1,tmp2);&lt;br /&gt;
  init64(tmp2,0,1000ul);&lt;br /&gt;
  mul64(tmp1,tmp2);&lt;br /&gt;
  init64(tmp2,0,parms[microSecondsPerGallonIdx]);&lt;br /&gt;
  div64(tmp1,tmp2);&lt;br /&gt;
  init64(tmp2,0,instInjEnd-instInjStart);&lt;br /&gt;
  div64(tmp1,tmp2);&lt;br /&gt;
  return tmp1[1];      &lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
unsigned long instantrpm(){      &lt;br /&gt;
//    instInjCount=tmpInstInjCount;&lt;br /&gt;
&lt;br /&gt;
  //  unsigned long vssPulseTimeuS = instant.vssPulseLength/instant.vssPulses;&lt;br /&gt;
  &lt;br /&gt;
//  unsigned long instInjStart=nil; &lt;br /&gt;
//unsigned long instInjEnd; &lt;br /&gt;
//unsigned long instInjTot; &lt;br /&gt;
  init64(tmp1,0,instInjCount);&lt;br /&gt;
  init64(tmp2,0,120000000ul);&lt;br /&gt;
  mul64(tmp1,tmp2);&lt;br /&gt;
  init64(tmp2,0,1000ul);&lt;br /&gt;
  mul64(tmp1,tmp2);&lt;br /&gt;
  init64(tmp2,0,parms[injPulsesPer2Revolutions]);&lt;br /&gt;
  div64(tmp1,tmp2);&lt;br /&gt;
  init64(tmp2,0,instInjEnd-instInjStart);&lt;br /&gt;
  div64(tmp1,tmp2);&lt;br /&gt;
  return tmp1[1];      &lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
unsigned long Trip::miles(){      &lt;br /&gt;
  init64(tmp1,0,vssPulses);&lt;br /&gt;
  init64(tmp2,0,1000);&lt;br /&gt;
  mul64(tmp1,tmp2);&lt;br /&gt;
  init64(tmp2,0,parms[vssPulsesPerMileIdx]);&lt;br /&gt;
  div64(tmp1,tmp2);&lt;br /&gt;
  return tmp1[1];      &lt;br /&gt;
}      &lt;br /&gt;
 &lt;br /&gt;
unsigned long Trip::mph(){      &lt;br /&gt;
  if(loopCount == 0)     &lt;br /&gt;
     return 0;     &lt;br /&gt;
  init64(tmp1,0,loopsPerSecond);&lt;br /&gt;
  init64(tmp2,0,vssPulses);&lt;br /&gt;
  mul64(tmp1,tmp2);&lt;br /&gt;
  init64(tmp2,0,3600000);&lt;br /&gt;
  mul64(tmp1,tmp2);&lt;br /&gt;
  init64(tmp2,0,parms[vssPulsesPerMileIdx]);&lt;br /&gt;
  div64(tmp1,tmp2);&lt;br /&gt;
  init64(tmp2,0,loopCount);&lt;br /&gt;
  div64(tmp1,tmp2);&lt;br /&gt;
  return tmp1[1];      &lt;br /&gt;
}      &lt;br /&gt;
 &lt;br /&gt;
unsigned long  Trip::gallons(){      &lt;br /&gt;
  init64(tmp1,0,injHiSec);&lt;br /&gt;
  init64(tmp2,0,1000000);&lt;br /&gt;
  mul64(tmp1,tmp2);&lt;br /&gt;
  init64(tmp2,0,injHius);&lt;br /&gt;
  add64(tmp1,tmp2);&lt;br /&gt;
  init64(tmp2,0,1000);&lt;br /&gt;
  mul64(tmp1,tmp2);&lt;br /&gt;
  init64(tmp2,0,parms[microSecondsPerGallonIdx]);&lt;br /&gt;
  div64(tmp1,tmp2);&lt;br /&gt;
  return tmp1[1];      &lt;br /&gt;
}      &lt;br /&gt;
 &lt;br /&gt;
unsigned long  Trip::mpg(){      &lt;br /&gt;
  if(vssPulses==0) return 0;      &lt;br /&gt;
  if(injPulses==0) return 999999000; //who doesn't like to see 999999?  :)      &lt;br /&gt;
 &lt;br /&gt;
  init64(tmp1,0,injHiSec);&lt;br /&gt;
  init64(tmp3,0,1000000);&lt;br /&gt;
  mul64(tmp3,tmp1);&lt;br /&gt;
  init64(tmp1,0,injHius);&lt;br /&gt;
  add64(tmp3,tmp1);&lt;br /&gt;
  init64(tmp1,0,parms[vssPulsesPerMileIdx]);&lt;br /&gt;
  mul64(tmp3,tmp1);&lt;br /&gt;
 &lt;br /&gt;
  init64(tmp1,0,parms[microSecondsPerGallonIdx]);&lt;br /&gt;
  init64(tmp2,0,1000);&lt;br /&gt;
  mul64(tmp1,tmp2);&lt;br /&gt;
  init64(tmp2,0,vssPulses);&lt;br /&gt;
  mul64(tmp1,tmp2);&lt;br /&gt;
 &lt;br /&gt;
  div64(tmp1,tmp3);&lt;br /&gt;
  return tmp1[1];      &lt;br /&gt;
}      &lt;br /&gt;
 &lt;br /&gt;
//return the seconds as a time mmm.ss, eventually hhh:mm too      &lt;br /&gt;
unsigned long Trip::time(){      &lt;br /&gt;
//  return seconds*1000;      &lt;br /&gt;
  byte d = 60;      &lt;br /&gt;
  unsigned long seconds = loopCount/loopsPerSecond;     &lt;br /&gt;
//  if(seconds/60 &amp;gt; 999) d = 3600; //scale up to hours.minutes if we get past 999 minutes      &lt;br /&gt;
  return ((seconds/d)*1000) + ((seconds%d) * 10);       &lt;br /&gt;
}      &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
void Trip::reset(){      &lt;br /&gt;
  loopCount=0;      &lt;br /&gt;
  injPulses=0;      &lt;br /&gt;
  injHius=0;      &lt;br /&gt;
  injHiSec=0;      &lt;br /&gt;
  vssPulses=0;  &lt;br /&gt;
  vssPulseLength=0;&lt;br /&gt;
}      &lt;br /&gt;
 &lt;br /&gt;
void Trip::update(Trip t){     &lt;br /&gt;
  loopCount++;  //we call update once per loop     &lt;br /&gt;
  vssPulses+=t.vssPulses;      &lt;br /&gt;
  vssPulseLength+=t.vssPulseLength;&lt;br /&gt;
  if(t.injPulses &amp;gt; 2 &amp;amp;&amp;amp; t.injHius&amp;lt;500000){//chasing ghosts      &lt;br /&gt;
    injPulses+=t.injPulses;      &lt;br /&gt;
    injHius+=t.injHius;      &lt;br /&gt;
    if (injHius&amp;gt;=1000000){  //rollover into the injHiSec counter      &lt;br /&gt;
      injHiSec++;      &lt;br /&gt;
      injHius-=1000000;      &lt;br /&gt;
    }      &lt;br /&gt;
  }      &lt;br /&gt;
}   &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
#ifndef debuguino  &lt;br /&gt;
char bignumchars1[]={4,1,4,0, 1,4,32,0, 3,3,4,0, 1,3,4,0, 4,2,4,0,   4,3,3,0, 4,3,3,0, 1,1,4,0,   4,3,4,0, 4,3,4,0}; &lt;br /&gt;
char bignumchars2[]={4,2,4,0, 2,4,2,0,  4,2,2,0, 2,2,4,0, 32,32,4,0, 2,2,4,0, 4,2,4,0, 32,4,32,0, 4,2,4,0, 2,2,4,0};  &lt;br /&gt;
 &lt;br /&gt;
void bigNum (unsigned long t, char * txt1, char * txt2){      &lt;br /&gt;
//  unsigned long t = 98550ul;//number in thousandths &lt;br /&gt;
//  unsigned long t = 9855ul;//number in thousandths &lt;br /&gt;
//  char * txt1=&amp;quot;INST&amp;quot;; &lt;br /&gt;
//  char * txt2=&amp;quot;MPG &amp;quot;; &lt;br /&gt;
  char  dp = 32; &lt;br /&gt;
 &lt;br /&gt;
  char * r = &amp;quot;009.99&amp;quot;; //&amp;quot;009.99&amp;quot; &amp;quot;000.99&amp;quot; &amp;quot;000.09&amp;quot; &lt;br /&gt;
  if(t&amp;lt;=99500){ &lt;br /&gt;
    r=format(t/10); //009.86 &lt;br /&gt;
    dp=5; &lt;br /&gt;
  }else if(t&amp;lt;=999500){ &lt;br /&gt;
    r=format(t/100); //009.86 &lt;br /&gt;
  }   &lt;br /&gt;
 &lt;br /&gt;
  LCD::gotoXY(0,0); &lt;br /&gt;
  LCD::print(bignumchars1+(r[2]-'0')*4); &lt;br /&gt;
  LCD::print(&amp;quot; &amp;quot;); &lt;br /&gt;
  LCD::print(bignumchars1+(r[4]-'0')*4); &lt;br /&gt;
  LCD::print(&amp;quot; &amp;quot;); &lt;br /&gt;
  LCD::print(bignumchars1+(r[5]-'0')*4); &lt;br /&gt;
  LCD::print(&amp;quot; &amp;quot;); &lt;br /&gt;
  LCD::print(txt1); &lt;br /&gt;
 &lt;br /&gt;
  LCD::gotoXY(0,1); &lt;br /&gt;
  LCD::print(bignumchars2+(r[2]-'0')*4); &lt;br /&gt;
  LCD::print(&amp;quot; &amp;quot;); &lt;br /&gt;
  LCD::print(bignumchars2+(r[4]-'0')*4); &lt;br /&gt;
  LCD::LcdDataWrite(dp); &lt;br /&gt;
  LCD::print(bignumchars2+(r[5]-'0')*4); &lt;br /&gt;
  LCD::print(&amp;quot; &amp;quot;); &lt;br /&gt;
  LCD::print(txt2); &lt;br /&gt;
}      &lt;br /&gt;
#endif &lt;br /&gt;
//the standard 64 bit math brings in  5000+ bytes&lt;br /&gt;
//these bring in 1214 bytes, and everything is pass by reference&lt;br /&gt;
unsigned long zero64[]={0,0};&lt;br /&gt;
 &lt;br /&gt;
void init64(unsigned long  an[], unsigned long bigPart, unsigned long littlePart ){&lt;br /&gt;
  an[0]=bigPart;&lt;br /&gt;
  an[1]=littlePart;&lt;br /&gt;
}&lt;br /&gt;
 &lt;br /&gt;
//left shift 64 bit &amp;quot;number&amp;quot;&lt;br /&gt;
void shl64(unsigned long  an[]){&lt;br /&gt;
 an[0] &amp;lt;&amp;lt;= 1; &lt;br /&gt;
 if(an[1] &amp;amp; 0x80000000)&lt;br /&gt;
   an[0]++; &lt;br /&gt;
 an[1] &amp;lt;&amp;lt;= 1; &lt;br /&gt;
}&lt;br /&gt;
 &lt;br /&gt;
//right shift 64 bit &amp;quot;number&amp;quot;&lt;br /&gt;
void shr64(unsigned long  an[]){&lt;br /&gt;
 an[1] &amp;gt;&amp;gt;= 1; &lt;br /&gt;
 if(an[0] &amp;amp; 0x1)&lt;br /&gt;
   an[1]+=0x80000000; &lt;br /&gt;
 an[0] &amp;gt;&amp;gt;= 1; &lt;br /&gt;
}&lt;br /&gt;
 &lt;br /&gt;
//add ann to an&lt;br /&gt;
void add64(unsigned long  an[], unsigned long  ann[]){&lt;br /&gt;
  an[0]+=ann[0];&lt;br /&gt;
  if(an[1] + ann[1] &amp;lt; ann[1])&lt;br /&gt;
    an[0]++;&lt;br /&gt;
  an[1]+=ann[1];&lt;br /&gt;
}&lt;br /&gt;
 &lt;br /&gt;
//subtract ann from an&lt;br /&gt;
void sub64(unsigned long  an[], unsigned long  ann[]){&lt;br /&gt;
  an[0]-=ann[0];&lt;br /&gt;
  if(an[1] &amp;lt; ann[1]){&lt;br /&gt;
    an[0]--;&lt;br /&gt;
  }&lt;br /&gt;
  an[1]-= ann[1];&lt;br /&gt;
}&lt;br /&gt;
 &lt;br /&gt;
//true if an == ann&lt;br /&gt;
boolean eq64(unsigned long  an[], unsigned long  ann[]){&lt;br /&gt;
  return (an[0]==ann[0]) &amp;amp;&amp;amp; (an[1]==ann[1]);&lt;br /&gt;
}&lt;br /&gt;
 &lt;br /&gt;
//true if an &amp;lt; ann&lt;br /&gt;
boolean lt64(unsigned long  an[], unsigned long  ann[]){&lt;br /&gt;
  if(an[0]&amp;gt;ann[0]) return false;&lt;br /&gt;
  return (an[0]&amp;lt;ann[0]) || (an[1]&amp;lt;ann[1]);&lt;br /&gt;
}&lt;br /&gt;
 &lt;br /&gt;
//divide num by den&lt;br /&gt;
void div64(unsigned long num[], unsigned long den[]){&lt;br /&gt;
  unsigned long quot[2];&lt;br /&gt;
  unsigned long qbit[2];&lt;br /&gt;
  unsigned long tmp[2];&lt;br /&gt;
  init64(quot,0,0);&lt;br /&gt;
  init64(qbit,0,1);&lt;br /&gt;
 &lt;br /&gt;
  if (eq64(num, zero64)) {  //numerator 0, call it 0&lt;br /&gt;
    init64(num,0,0);&lt;br /&gt;
    return;        &lt;br /&gt;
  }&lt;br /&gt;
 &lt;br /&gt;
  if (eq64(den, zero64)) { //numerator not zero, denominator 0, infinity in my book.&lt;br /&gt;
    init64(num,0xffffffff,0xffffffff);&lt;br /&gt;
    return;        &lt;br /&gt;
  }&lt;br /&gt;
 &lt;br /&gt;
  init64(tmp,0x80000000,0);&lt;br /&gt;
  while(lt64(den,tmp)){&lt;br /&gt;
    shl64(den);&lt;br /&gt;
    shl64(qbit);&lt;br /&gt;
  } &lt;br /&gt;
 &lt;br /&gt;
  while(!eq64(qbit,zero64)){&lt;br /&gt;
    if(lt64(den,num) || eq64(den,num)){&lt;br /&gt;
      sub64(num,den);&lt;br /&gt;
      add64(quot,qbit);&lt;br /&gt;
    }&lt;br /&gt;
    shr64(den);&lt;br /&gt;
    shr64(qbit);&lt;br /&gt;
  }&lt;br /&gt;
 &lt;br /&gt;
  //remainder now in num, but using it to return quotient for now  &lt;br /&gt;
  init64(num,quot[0],quot[1]); &lt;br /&gt;
}&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
//multiply num by den&lt;br /&gt;
void mul64(unsigned long an[], unsigned long ann[]){&lt;br /&gt;
  unsigned long p[2] = {0,0};&lt;br /&gt;
  unsigned long y[2] = {ann[0], ann[1]};&lt;br /&gt;
  while(!eq64(y,zero64)) {&lt;br /&gt;
    if(y[1] &amp;amp; 1) &lt;br /&gt;
      add64(p,an);&lt;br /&gt;
    shl64(an);&lt;br /&gt;
    shr64(y);&lt;br /&gt;
  }&lt;br /&gt;
  init64(an,p[0],p[1]);&lt;br /&gt;
} &lt;br /&gt;
  &lt;br /&gt;
void save(){&lt;br /&gt;
  EEPROM.write(0,guinosig);&lt;br /&gt;
  byte p = 0;&lt;br /&gt;
  for(int x=4; p &amp;lt; parmsLength; x+= 4){&lt;br /&gt;
    unsigned long v = parms[p];&lt;br /&gt;
    EEPROM.write(x ,(v&amp;gt;&amp;gt;24)&amp;amp;255);&lt;br /&gt;
    EEPROM.write(x + 1,(v&amp;gt;&amp;gt;16)&amp;amp;255);&lt;br /&gt;
    EEPROM.write(x + 2,(v&amp;gt;&amp;gt;8)&amp;amp;255);&lt;br /&gt;
    EEPROM.write(x + 3,(v)&amp;amp;255);&lt;br /&gt;
    p++;&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
byte load(){ //return 1 if loaded ok&lt;br /&gt;
  byte b = EEPROM.read(0);&lt;br /&gt;
  if(b == guinosig){&lt;br /&gt;
    byte p = 0;&lt;br /&gt;
&lt;br /&gt;
    for(int x=4; p &amp;lt; parmsLength; x+= 4){&lt;br /&gt;
      unsigned long v = EEPROM.read(x);&lt;br /&gt;
      v = (v &amp;lt;&amp;lt; 8) + EEPROM.read(x+1);&lt;br /&gt;
      v = (v &amp;lt;&amp;lt; 8) + EEPROM.read(x+2);&lt;br /&gt;
      v = (v &amp;lt;&amp;lt; 8) + EEPROM.read(x+3);&lt;br /&gt;
      parms[p]=v;&lt;br /&gt;
      p++;&lt;br /&gt;
    }&lt;br /&gt;
    return 1;&lt;br /&gt;
  }&lt;br /&gt;
  return 0;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
char * uformat(unsigned long val){ &lt;br /&gt;
  unsigned long d = 1000000000ul;&lt;br /&gt;
  for(byte p = 0; p &amp;lt; 10 ; p++){&lt;br /&gt;
    mBuff[p]='0' + (val/d);&lt;br /&gt;
    val=val-(val/d*d);&lt;br /&gt;
    d/=10;&lt;br /&gt;
  }&lt;br /&gt;
  mBuff[10]=0;&lt;br /&gt;
  return mBuff;&lt;br /&gt;
} &lt;br /&gt;
&lt;br /&gt;
unsigned long rformat(char * val){ &lt;br /&gt;
  unsigned long d = 1000000000ul;&lt;br /&gt;
  unsigned long v = 0ul;&lt;br /&gt;
  for(byte p = 0; p &amp;lt; 10 ; p++){&lt;br /&gt;
    v=v+(d*(val[p]-'0'));&lt;br /&gt;
    d/=10;&lt;br /&gt;
  }&lt;br /&gt;
  return v;&lt;br /&gt;
} &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
#ifndef debuguino&lt;br /&gt;
void editParm(byte parmIdx){&lt;br /&gt;
  unsigned long v = parms[parmIdx];&lt;br /&gt;
  byte p=9;  //right end of 10 digit number&lt;br /&gt;
  //display label on top line&lt;br /&gt;
  //set cursor visible&lt;br /&gt;
  //set pos = 0&lt;br /&gt;
  //display v&lt;br /&gt;
&lt;br /&gt;
    LCD::gotoXY(8,0);        &lt;br /&gt;
    LCD::print(&amp;quot;        &amp;quot;);&lt;br /&gt;
    LCD::gotoXY(0,0);        &lt;br /&gt;
    LCD::print(parmLabels[parmIdx]);&lt;br /&gt;
    LCD::gotoXY(0,1);    &lt;br /&gt;
    char * fmtv=    uformat(v);&lt;br /&gt;
    LCD::print(fmtv);&lt;br /&gt;
    LCD::print(&amp;quot; OK XX&amp;quot;);&lt;br /&gt;
    LCD::LcdCommandWrite(B00001110);&lt;br /&gt;
&lt;br /&gt;
    for(int x=9 ; x&amp;gt;=0 ;x--){ //do a nice thing and put the cursor at the first non zero number&lt;br /&gt;
      if(fmtv[x] != '0')&lt;br /&gt;
         p=x; &lt;br /&gt;
    }&lt;br /&gt;
  byte keyLock=1;    &lt;br /&gt;
  while(true){&lt;br /&gt;
&lt;br /&gt;
    if(p&amp;lt;10)&lt;br /&gt;
      LCD::gotoXY(p,1);   &lt;br /&gt;
    if(p==10)     &lt;br /&gt;
      LCD::gotoXY(11,1);   &lt;br /&gt;
    if(p==11)     &lt;br /&gt;
      LCD::gotoXY(14,1);   &lt;br /&gt;
&lt;br /&gt;
     if(keyLock == 0){ &lt;br /&gt;
       if(!(buttonState&amp;amp;lbuttonBit)){// left&lt;br /&gt;
            p=p-1;&lt;br /&gt;
            if(p==255)p=11;&lt;br /&gt;
        }else if(!(buttonState&amp;amp;rbuttonBit)){// right&lt;br /&gt;
             p=p+1;&lt;br /&gt;
            if(p==12)p=0;&lt;br /&gt;
        }else if(!(buttonState&amp;amp;mbuttonBit)){// middle&lt;br /&gt;
             if(p==11){  //cancel selected&lt;br /&gt;
                LCD::LcdCommandWrite(B00001100);&lt;br /&gt;
                return;&lt;br /&gt;
             }&lt;br /&gt;
             if(p==10){  //ok selected&lt;br /&gt;
                LCD::LcdCommandWrite(B00001100);&lt;br /&gt;
                parms[parmIdx]=rformat(fmtv);&lt;br /&gt;
                return;&lt;br /&gt;
             }&lt;br /&gt;
             &lt;br /&gt;
             byte n = fmtv[p]-'0';&lt;br /&gt;
             n++;&lt;br /&gt;
             if (n &amp;gt; 9) n=0;&lt;br /&gt;
             if(p==0 &amp;amp;&amp;amp; n &amp;gt; 3) n=0;&lt;br /&gt;
             fmtv[p]='0'+ n;&lt;br /&gt;
             LCD::gotoXY(0,1);        &lt;br /&gt;
             LCD::print(fmtv);&lt;br /&gt;
             LCD::gotoXY(p,1);        &lt;br /&gt;
             if(parmIdx==contrastIdx)//adjust contrast dynamically&lt;br /&gt;
                 analogWrite(ContrastPin,rformat(fmtv));  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
      if(buttonState!=buttonsUp)&lt;br /&gt;
         keyLock=1;&lt;br /&gt;
     }else{&lt;br /&gt;
        keyLock=0;&lt;br /&gt;
     }&lt;br /&gt;
      buttonState=buttonsUp;&lt;br /&gt;
      delay2(125);&lt;br /&gt;
  }      &lt;br /&gt;
  &lt;br /&gt;
}&lt;br /&gt;
#endif&lt;br /&gt;
&lt;br /&gt;
void initGuino(){ //edit all the parameters&lt;br /&gt;
#ifndef debuguino&lt;br /&gt;
  for(int x = 0;x&amp;lt;parmsLength;x++)&lt;br /&gt;
    editParm(x);&lt;br /&gt;
  save();&lt;br /&gt;
  holdDisplay=1;&lt;br /&gt;
#endif&lt;br /&gt;
}  &lt;br /&gt;
&lt;br /&gt;
unsigned long millis2(){&lt;br /&gt;
	return timer2_overflow_count * 64UL * 2 / (16000000UL / 128000UL);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
void delay2(unsigned long ms){&lt;br /&gt;
	unsigned long start = millis2();&lt;br /&gt;
	while (millis2() - start &amp;lt; ms);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
/* Delay for the given number of microseconds.  Assumes a 16 MHz clock. &lt;br /&gt;
 * Disables interrupts, which will disrupt the millis2() function if used&lt;br /&gt;
 * too frequently. */&lt;br /&gt;
void delayMicroseconds2(unsigned int us){&lt;br /&gt;
	uint8_t oldSREG;&lt;br /&gt;
	if (--us == 0)	return;&lt;br /&gt;
	us &amp;lt;&amp;lt;= 2;&lt;br /&gt;
	us -= 2;&lt;br /&gt;
	oldSREG = SREG;&lt;br /&gt;
	cli();&lt;br /&gt;
	// busy wait&lt;br /&gt;
	__asm__ __volatile__ (&lt;br /&gt;
		&amp;quot;1: sbiw %0,1&amp;quot; &amp;quot;\n\t&amp;quot; // 2 cycles&lt;br /&gt;
		&amp;quot;brne 1b&amp;quot; : &amp;quot;=w&amp;quot; (us) : &amp;quot;0&amp;quot; (us) // 2 cycles&lt;br /&gt;
	);&lt;br /&gt;
	// reenable interrupts.&lt;br /&gt;
	SREG = oldSREG;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
void init2(){&lt;br /&gt;
	// this needs to be called before setup() or some functions won't&lt;br /&gt;
	// work there&lt;br /&gt;
	sei();&lt;br /&gt;
	&lt;br /&gt;
	// timer 0 is used for millis2() and delay2()&lt;br /&gt;
	timer2_overflow_count = 0;&lt;br /&gt;
	// on the ATmega168, timer 0 is also used for fast hardware pwm&lt;br /&gt;
	// (using phase-correct PWM would mean that timer 0 overflowed half as often&lt;br /&gt;
	// resulting in different millis2() behavior on the ATmega8 and ATmega168)&lt;br /&gt;
        TCCR2A=1&amp;lt;&amp;lt;WGM20|1&amp;lt;&amp;lt;WGM21;&lt;br /&gt;
	// set timer 2 prescale factor to 64&lt;br /&gt;
        TCCR2B=1&amp;lt;&amp;lt;CS22;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
//      TCCR2A=TCCR0A;&lt;br /&gt;
//      TCCR2B=TCCR0B;&lt;br /&gt;
	// enable timer 2 overflow interrupt&lt;br /&gt;
	TIMSK2|=1&amp;lt;&amp;lt;TOIE2;&lt;br /&gt;
	// disable timer 0 overflow interrupt&lt;br /&gt;
	TIMSK0&amp;amp;=!(1&amp;lt;&amp;lt;TOIE0);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
{{default}}&lt;/div&gt;</summary>
		<author><name>Combustor</name></author>	</entry>

	<entry>
		<id>http://combustory.com/wiki/index.php/The_MPGuino_-_Arduino_Code</id>
		<title>The MPGuino - Arduino Code</title>
		<link rel="alternate" type="text/html" href="http://combustory.com/wiki/index.php/The_MPGuino_-_Arduino_Code"/>
				<updated>2008-09-10T14:49:55Z</updated>
		
		<summary type="html">&lt;p&gt;Combustor: /* MPGuino.pde Code v.7 */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{default}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Check here for any updates http://opengauge.googlecode.com/svn/trunk/mpguino/mpguino.pde'''&lt;br /&gt;
&lt;br /&gt;
== MPGuino.pde Code v.701 ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
{{default}}&lt;/div&gt;</summary>
		<author><name>Combustor</name></author>	</entry>

	<entry>
		<id>http://combustory.com/wiki/index.php/MPGuino</id>
		<title>MPGuino</title>
		<link rel="alternate" type="text/html" href="http://combustory.com/wiki/index.php/MPGuino"/>
				<updated>2008-09-10T14:49:01Z</updated>
		
		<summary type="html">&lt;p&gt;Combustor: /* Software &amp;amp; Release notes */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{default}}&lt;br /&gt;
[[Image:MPGuino_Enclosure_mounted.jpg|right|thumb|400px|]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Summary ==&lt;br /&gt;
&lt;br /&gt;
This is an impressive use of the Arduino platform. One that will actually pay for itself too.  A small group of folks banded together and created an open platform called http://opengauge.googlecode.com where you will not really find much information concerning this device, but there are lots of information in a forum at http://www.ecomodder.com, where you will find tons of useful and fun ways on improving gas mileage for any car. To explain what these folks did for the average working Joe, who can't quite afford a car newer than 1995, is just amazing. It still works for just about any car with fuel injection, but for cars built before 1996, there is no [[OBD-II Diagnostic Tools | OBD-II]] option.&lt;br /&gt;
&lt;br /&gt;
They came up with a way to build a reasonably low-cost device that will gauge your MPG, even for cars that do not have an [[OBD-II Diagnostic Tools | OBD-II]] interface in there car. At the moment it is restricted to use in cars with fuel injection, but given enough time they may even find a way to gauge cars with carburetors.  To cut to the chase, this device uses inputs from the Vehicle Speed Sensor(VSS) and one fuel injector control wire, both of which are easily found in just about all fuel injected cars, minus mechanical fuel injection, which only Mercedes seemed to make reliably albeit expensively. So, sorry all those 300E owners, you can't play with this toy right now.&lt;br /&gt;
&lt;br /&gt;
The device sports an LCD screen with many display features that include Current,Instant and Tank MPG as well as Trip data for MPG, Mileage, and Tank Gallons. There are many other options and I recommend you reference the User Guide below for more detail.&lt;br /&gt;
&lt;br /&gt;
== Functional Description of the Solution ==&lt;br /&gt;
&lt;br /&gt;
To further detail the solution, the VSS provides a pulse input related to the speed and distance traveled, meaning from this sensor you know how fast the car is going from the pulse frequency and how far the car has traveled by counting the actual number of pulses. Pulses per mile vary from car to car and based on the forum I saw a range in the 4,000 - 10,000 pulses per mile. The injector control wire provides the fuel flow mass. By making the relation of the known flow rate of an injector and the amount of time that the injector is turned on, you can calculate the the actual fuel mass flow rate your car is using. &lt;br /&gt;
&lt;br /&gt;
On the electronics side they used the Arduino platform as the microprocessor and threw in some supporting components to prevent small fires that create anger and horrible smells.  I hate the smell of fried electronics, unfortunately I know it too well. The microprocessor polls the sensors in the micro-second realm, and writes the results to the LCD in the 1/2-1 sec. realm. This gives the user a near real time view of the actual data.&lt;br /&gt;
&lt;br /&gt;
There really is not much at the high level design function, but as they say, &amp;quot;The Devil is in the Details&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Theory of Operation ==  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Fuel Injectors'''&lt;br /&gt;
&lt;br /&gt;
To completely simplify a fuel injector, just imagine a water faucet valve. When the valve is open, the water flows out. The amount of water that flows out depends on the size of the faucet opening and the pressure of the water behind the faucet.  For a fuel injector, the manufacturers specify a lbs/hr of fuel flow by knowing the opening of the injector and specifying the constant pressure for which the injector supply is supposed to maintain. Therefore, if you provide the proper pressure to the injector as specified and you open the injector for one hour, you should get the specified pounds of fuel flowing out of the injector. For example, a 20 lb/hr injector will supply 20lbs of fuel if left turned on for one hour.&lt;br /&gt;
&lt;br /&gt;
This makes the calculation fairly simple to determine a fuel flow rate for your car by measuring the total amount the injector is open that comes from the Injector Sensor of the MPGuino and it is measured through the pulse width sent to the injector by the car computer. Also known as the injector pulse width. So the total time for each pulse width over a given time is the total time an injector is open.  This measurement is usually taken in a second time frame and an injector has a limitation known as a frequency response or a max number of pulses per second, which is related to the mechanical response time that the injector can open or close. The MPGuino measures the total time the injector is open, so we will just take that number as a known measured value.&lt;br /&gt;
&lt;br /&gt;
Ti = Time the injector is open as a ratio of a known time = For calculation purposes we will set it at usec/sec&lt;br /&gt;
&lt;br /&gt;
Fr = Fuel flow rate is a known from the manufacturer in lbs/hr&lt;br /&gt;
&lt;br /&gt;
Therefore:&lt;br /&gt;
&lt;br /&gt;
Fuel usage rate = Fr (lbs/hr) / 3600 (sec/hr) * Ti (usec/sec) /1000 = (lbs/sec)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math &amp;gt;Fu = \frac{Fr}{3600} * \frac {Ti}{1000}&amp;lt;/math &amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&lt;br /&gt;
Ti = 500 usec/sec as measured by MPGuino&lt;br /&gt;
&lt;br /&gt;
Fr = 20 lbs/hr as specified by manufacturer&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math &amp;gt; Fuel\ usage\ rate = \frac{20}{3600} * \frac{500}{1000} = 0.0028 (lbs/sec)&amp;lt;/math &amp;gt; &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''VSS - Vehicle Speed Sensor'''&lt;br /&gt;
&lt;br /&gt;
The VSS count is fairly straight forward.  There is a device on your car that rotates and creates a certain number of pulses per revolution. The sensor is usually attached to your transmission and it has a direct gear ratio to your tires that I will call the rolling ratio. This sensor is used to feed the vehicle computer the speed and distance data. The actual gear ratio has only one main variation, and that is the tire diameter. For the MPGuino to calculate the the MPG, this input is critical for determining the distance traveled. The VSS count is typically measured in counts per mile.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Theory vs. Reality'''&lt;br /&gt;
&lt;br /&gt;
As with any engineering of a product you will have fudge factors.  The important thing to realize is that you always design to get the fundamentals close and then expect to calibrate to meet the accuracy needed for the function.  For this product we will evaluate the best way to calibrate and adjust to improve the accuracy of the numbers.  This may not be necessary at all if your goal is to get feedback on your driving habits, then the accuracy does not matter, as long as you realize that the MPGuino is changing your driving habits to conserve gas AND best of all save you money.&lt;br /&gt;
&lt;br /&gt;
So first let's discuss the factors that will affect your accuracy. &lt;br /&gt;
&lt;br /&gt;
Factors NOT in our control:&lt;br /&gt;
&lt;br /&gt;
Is it possible to control or measure these factors? yes, is it practical? not in my opinion. So these factors will introduce errors that will need compensation in the fudging process. I feel it is a pretty safe assumption that over time these factors will average within a range that will permit fudging.&lt;br /&gt;
&lt;br /&gt;
''Injector Pressure'' - Your car has a pressure regulator to manage your fuel manifold pressure, and it will regulate to it's setting.  You could measure your pressure, but then you would have to know how that affects the fuel flow through the injector.  We also do not know how the pressure changes over time and this can affect your fuel flow.  &lt;br /&gt;
&lt;br /&gt;
''Injector Efficiency'' - Well, since MPGuino is a device that was targeted to older cars, then you have to expect that injectors tend to clog and become less efficient over time. The only way to calibrate that problem is to measure the actual flow through each injector.  Have fun if you want to tackle that project. `,~)&lt;br /&gt;
&lt;br /&gt;
''Rolling Ratio'' - The rolling ratio is a constant changing ratio that will affect your VSS counts per mile. The main reason it changes over time is due to tires. As a tire gets more worn your VSS counts per mile will increase. When you replace that old set of tires with new tires, you will have less counts per mile.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Fudging/Calibration process'''&lt;br /&gt;
&lt;br /&gt;
There are two areas I want to focus on to get this system as accurate as possible. Let's consider fudging the fuel flow rate and measuring the VSS counts per mile. I am taking this approach, because measuring the VSS counts is a practical option and it can be done with some accuracy.  In contrast the fuel flow rate used to calculate the total fuel usage is not very measurable and therefore should be fudged. &lt;br /&gt;
&lt;br /&gt;
To measure the VSS counts per mile get on the highway and find a mile marker and reset you VSS counts to zero.  Drive ten miles as marked by the mile markers and note your VSS counts. Divide by ten to get your VSS counts per mile.  Take an average of this process if you really want to nail it down, but I do not feel that is necessary. You may need to test this count every 6-12 months to readjust this number. You can compare your numbers to you odometer, but understand that the odometer does not take into account the tire diameter as accurately as your measurement, but it can be used as a verification that you are in the ball park. The best verification would be if you noticed that you have a fairly repeatable offset from the odometer and your calculation.&lt;br /&gt;
&lt;br /&gt;
To measure the fuel is much more difficult. Really the best way to do measure the fuel would be to drain the tank and run the tank dry of fuel. Now weigh the amount of fuel and put it in the tank. Run the tank dry again and compare the actual fuel usage with the MPGuino. Again do this multiple times and take the average. Personally I would not do this at all, but it is the only real way to get acuracy.  For a much more practical method, start a fuel usage log. Go to many different gas pumps and take an average over time. I have noticed that the cheapest gas stations tend to calibrate to the high side of the legal limit, if not actually outside the legal limit. Try to keep a standard procedure, like only filling to the first click off.  Compare your fuel usage average to your MPGuino fuel usage average and look for a trend. Now fudge the fuel usage to match.&lt;br /&gt;
&lt;br /&gt;
== Requirements and Knowledge ==&lt;br /&gt;
&lt;br /&gt;
* Basic soldering and electronic building skill&lt;br /&gt;
* The following parts list for the Arduino assembly&lt;br /&gt;
** 2 5.1v zener diodes&lt;br /&gt;
** 1 2n3906 PNP Transistor&lt;br /&gt;
** 1 220 ohm resistor&lt;br /&gt;
** 2 100k resistors&lt;br /&gt;
** 3 tactile switches&lt;br /&gt;
** 1 freeduino arduino clone (any arduino can probably be made to work) i.e. an iduino: http://spiffie.org/kits/iduino/ or a Freeduino&lt;br /&gt;
** 1 LCD (others might work as well, check pinout and chipset, etc). 16x2 LCD Module While Characters Blue Backlight Or a green one from sparkfun or mouser (a number of folks like the green ones better)&lt;br /&gt;
** Sufficient Perfboard&lt;br /&gt;
** A case to hold it all together&lt;br /&gt;
* Additional parts for the iDuino assembly&lt;br /&gt;
** 1 7805 Voltage Regulator &lt;br /&gt;
** 1 1n4004 diode&lt;br /&gt;
** 330 uf cap &lt;br /&gt;
** 1 .1uf cap.&lt;br /&gt;
* You will need to find the wires for the VSS on the vehicle computer or control unit.&lt;br /&gt;
* If you're lucky you won't need much troubleshooting skills&lt;br /&gt;
&lt;br /&gt;
== Assemble the Electronics  ==&lt;br /&gt;
&lt;br /&gt;
Here are the schematics. This should be enough for most of you. There are two assemblies that are possible to build. The Arduino or the iDuino. &lt;br /&gt;
&lt;br /&gt;
Notes: &lt;br /&gt;
&lt;br /&gt;
* The only two output leads for the VSS and the injector, other than that a 12vdc supply, and that is it.&lt;br /&gt;
* The Analog pins in this schematic show 0-5 are used as digital I/O, therefore, Analog pin 0 is Digital pin 14 then count up from there.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;big&amp;gt;'''Arduino Assembly Schematic'''&amp;lt;/big&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Image:MPGuino_Schematic.GIF]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;big&amp;gt;'''iDuino Assembly Schematic'''&amp;lt;/big&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Image:iDuino_Schematic.GIF]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Enclosures  ==&lt;br /&gt;
&lt;br /&gt;
{| Border=1&lt;br /&gt;
|+ &amp;lt;big&amp;gt;'''MPGuino Arduino Enclosure Pics - [http://www.hitechcontrols.com/hensel/polycarbonate/smooth/kf8040.htm KF 8040 - Polycarbonate Indoor/Outdoor Enclosures]]'''&amp;lt;/big&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
|[[Image:MPGuino_Enclosure_Front.jpg|thumb|400px|]]|| [[Image:MPGuino_Enclosure_Inside.jpg|thumb|400px|]] || [[Image:MPGuino_Enclosure_mounted.jpg|thumb|400px|]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{| Border=1&lt;br /&gt;
|+ &amp;lt;big&amp;gt;'''MPGuino iDuino Enclosure Pics - [[http://www.radioshack.com/product/index.jsp?productId=2062280&amp;amp;cp=&amp;amp;sr=1&amp;amp;origkw=project+box&amp;amp;kw=project+box&amp;amp;parentPage=search Radio Shack Enclosure]]'''&amp;lt;/big&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| [[Image:MPGuino_iDuino_Front.jpg|thumb|400px|]] || [[Image:MPGuino_iDuino_Inside_Front.jpg|thumb|400px|]] || [[Image:MPGuino_iDuino_Inside_Guts_Front.jpg|thumb|400px|]]&lt;br /&gt;
|-&lt;br /&gt;
| [[Image:MPGuino_iDuino_Back.jpg|thumb|400px|]] || [[Image:MPGuino_iDuino_Inside_Back.jpg|thumb|400px|]] || [[Image:MPGuino_iDuino_Inside_Guts.jpg|thumb|400px|]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== User Guide  ==&lt;br /&gt;
&lt;br /&gt;
'''Screens'''&lt;br /&gt;
&lt;br /&gt;
1. Instant MPG/Speed&lt;br /&gt;
Current MPG/Distance&lt;br /&gt;
&lt;br /&gt;
2. Instant MPG/Speed&lt;br /&gt;
Tank MPG/Distance&lt;br /&gt;
&lt;br /&gt;
3. Large font instant MPG&lt;br /&gt;
&lt;br /&gt;
4. Large font current MPG&lt;br /&gt;
&lt;br /&gt;
5. Large font tank MPG&lt;br /&gt;
&lt;br /&gt;
6. Current MPH, MPG, Miles, Gallons&lt;br /&gt;
&lt;br /&gt;
7. Tank MPH, MPG, Miles, Gallons&lt;br /&gt;
&lt;br /&gt;
8. Instant Raw Data (very useful for connection troubleshooting)&lt;br /&gt;
Injector open seconds, Injector open microSeconds,&lt;br /&gt;
Injector pulse count, Vehicle Speed Sensor pulse count&lt;br /&gt;
&lt;br /&gt;
9. Current trip Raw Data&lt;br /&gt;
Injector open seconds, Injector open microSeconds,&lt;br /&gt;
Injector pulse count, Vehicle Speed Sensor pulse count&lt;br /&gt;
&lt;br /&gt;
10. Tank trip Raw Data&lt;br /&gt;
Injector open seconds, Injector open microSeconds,&lt;br /&gt;
Injector pulse count, Vehicle Speed Sensor pulse count&lt;br /&gt;
&lt;br /&gt;
11. CPU Monitor&lt;br /&gt;
Max CPU %utilization, Tank running Time mm.ss,&lt;br /&gt;
Free Memory (bytes)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Start-up Settings'''&lt;br /&gt;
&lt;br /&gt;
There is also a setup screen that displays the first time the program is run and by pressing all three buttons at once. It walks you through the following setup variables. Use left and right buttons to select the digit you wish to change or the OK or Cancel (XX) items. Use middle button to rotate the current digit or select OK or XX if that is where the cursor is. Selecting OK will save the currently displayed value to the current variable and advance to the next variable. Selecting XX will just advance to the next variable.&lt;br /&gt;
&lt;br /&gt;
1. Contrast - This comes up first on a brand new run and changes on the screen are immediate so if you can't see anything try pressing middle button a few times.&lt;br /&gt;
&lt;br /&gt;
2. VSS Pulses/Mile - use this to adjust displayed speed/miles. If the speed/miles displayed on the mpguino is low then decrease this number by the percentage that it is off and vice versa for high readings. Most asian cars will be a multiple of 8204 and GM will be 10000, we are hoping users will contribute model specific data here.&lt;br /&gt;
&lt;br /&gt;
3. MicroSec/Gallon - use this to adjust displayed fuel consumption. You may want to readjust this initially to get a ballpark MPG reading (after VSS Pulses/Mile is deemed accurate), then calibrate it with a couple fillups. If the mpguino displayed MPG is high or the displayed tank gallons is low at fillup then reduce MicroSec/Gallon by the percentage that the gallons are low or the displayed mpg is high. Like the vss pulses, this would benefit from user contributions about what values work for what specific cars.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
4. Pulses/2 revs - not currently used, but a single injector on a 4 cylinder sequential system will make 1 squirt in 2 revolutions. Hope to be able to base RPM on this at some point.&lt;br /&gt;
&lt;br /&gt;
5. Timout(microSec) - defaults to 7 minutes. If there are no injector or speed signals from the car and no buttons are pressed in that time then the display backlight turns off. When activity resumes the display will turn back on and the current trip will reset and the tank trip will be restored to the point of last activity.&lt;br /&gt;
&lt;br /&gt;
6. Tank Gal * 1000 - not currently used, but defaults to 13300 or 13.3 gallons.&lt;br /&gt;
&lt;br /&gt;
7. Injector DelayuS - Represents the mechanical delay of the injector in microseconds. Advanced topic.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Button Functions''' &lt;br /&gt;
&lt;br /&gt;
1. left: cycle through screeens in reverse&lt;br /&gt;
&lt;br /&gt;
2. middle: cycle through pre-defined brightness settings&lt;br /&gt;
&lt;br /&gt;
3. right: cycle through screeens forward&lt;br /&gt;
&lt;br /&gt;
4. left+middle: tank reset&lt;br /&gt;
&lt;br /&gt;
5. right+middle: current reset&lt;br /&gt;
&lt;br /&gt;
6. left+middle+right: go to setup screen&lt;br /&gt;
&lt;br /&gt;
== Table of Car Settings  ==&lt;br /&gt;
&lt;br /&gt;
'''I am looking for data here, if you have a car to add, email me at combustor@combustory.com with the data.'''&lt;br /&gt;
&lt;br /&gt;
{| Border=1&lt;br /&gt;
|+ MPGuino Car Settings&lt;br /&gt;
! Car Year Make Model !! Engine !! Transmission !! VSS (count/mile) !! usec/gal&lt;br /&gt;
|-&lt;br /&gt;
|1989 Chevy Celebrity|| 3.1 || 4 spd auto || 4000 || 0240000000&lt;br /&gt;
|-&lt;br /&gt;
|1990 Mitsubishi Eclipse GST || 2.0 litre || 5 speed || 16364 || 126180393&lt;br /&gt;
|-&lt;br /&gt;
|1994 Suzuki Swift GA Sedan|| 1.3 Liter || 5 Speed || ???? || ????&lt;br /&gt;
|-&lt;br /&gt;
|1996 Jeep Wrangler || 4.0 Liter || 5 speed || ???? || ????&lt;br /&gt;
|-&lt;br /&gt;
|1997 Saturn SL2,SC2,SW2,S2|| 1.9 ||  || 10000 || 0289967320&lt;br /&gt;
|-&lt;br /&gt;
|2005 Subaru Impreza Outback Sport, 2.5RS || 2.5L N/A || 5MT || 8000 || 183165000 (still calibrating)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Software &amp;amp; Release notes  ==&lt;br /&gt;
&lt;br /&gt;
Here are the latest release notes as of this writing.  Get the latest SW from [[The MPGuino - Arduino Code]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''8/9/2008 updates for v0.70'''&lt;br /&gt;
&lt;br /&gt;
More experiments with vss processing. Instant mph is very smooth on saturn but still jumps a bit on the metro. Distance reading on metro appears reasonably accurate (102.6 miles on odo, 102.18 on mpguino using 8208 vsspulses/mile). So the guino is doing a pretty good job of counting the vss pulses, it is a little erratic in timing the pulses though.&lt;br /&gt;
&lt;br /&gt;
want to add EOC miles to the trip next, don't know if it will fit&lt;br /&gt;
sketch size: 12884&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''8/1/2008 updates for v0.69'''&lt;br /&gt;
&lt;br /&gt;
Added event handler and added debouncing on vss. Still trying to clean up reed switch vss signal via software with no luck. will make separate post for vss issue.&lt;br /&gt;
&lt;br /&gt;
Added instantaneous mph (mpg is next), this looks at the time between vss peaks to determine the speed instead of the number of pulses in the last half second, which was jumpy at slow speeds. We are getting really really tight on space. That might also be an issue when 0012 comes out (don't know when).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''8/1/2008 updates for v0.68'''&lt;br /&gt;
&lt;br /&gt;
Removed all dependencies on timer0 so we should be arduino 0012 compatible. This also establishes an ISR under our control for scheduling events. Disabled Timer0 so use millis2(), delay2(), etc.&lt;br /&gt;
&lt;br /&gt;
Knocked off a few hundred bytes by converting LCD to a namespace instead of a class.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''7/10/2008 updates for v0.67'''&lt;br /&gt;
&lt;br /&gt;
Incorporated LCD timings from Yoshi, removed pin 15 code and power up detection code.&lt;br /&gt;
&lt;br /&gt;
moved source code to google/svn Revision 32: /trunk&lt;br /&gt;
&lt;br /&gt;
other happenings:&lt;br /&gt;
did a test with the scope regarding the voltage drop at peak pulse. I had the guino set a pin high and low within the interrupts receiving high and low and the pulse widths were the same except the generated one was perfectly square. So that is a good thing. Will need to test exactly what voltage level is acceptable.&lt;br /&gt;
&lt;br /&gt;
The power supply on the scope died I think I just need a new TL431C or NTE999 though. I didn't get a chance to witness the vss bounce, the scope died during the attempt.&lt;br /&gt;
&lt;br /&gt;
I am planning on moving all timing critical code to timer 2 with an event handler. I need real interrupt style debouncing for the vss and might as well use it as an event scheduler for debouncing the buttons as well as whatever else. This move will also allow for arduino0012 compatability.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''6/27/2008 updates for v0.66'''&lt;br /&gt;
&lt;br /&gt;
ADDED AN ONBOARD VARIABLE EDITOR!!! VARIABLES STORED IN EEPROM!! Now you can upgrade and not lose your settings and make adjustments in the car. Refer to post 1[/url] for screens and edit usage.&lt;br /&gt;
&lt;br /&gt;
Updated screens descriptions in post 1&lt;br /&gt;
&lt;br /&gt;
Checked source into sourceforge.net, linked post 1 to sourceforge (ran out of room again and wiki didn't like the extension .pde).&lt;br /&gt;
&lt;br /&gt;
Sketch size 11734, 448 bytes free&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''6/26/2008 updates for v0.65'''&lt;br /&gt;
&lt;br /&gt;
Added 7 minute activity timeout. It saves the state of the persistent trips (just tank for now) at the point of last activity and after 7 minutes of no injector pulses/vss pulses/or button presses, it turns off the LED backlight and sets up current to be reset and tank to be restored when activity resumes.&lt;br /&gt;
&lt;br /&gt;
Despazed the buttons and Screen labels so they display for a second and accidental double button presses are minimized.&lt;br /&gt;
&lt;br /&gt;
Running out of excuses (and room) to no do the user input/eprom setup screen thing Sketch size 10502 bytes.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''6/23/2008 updates for v0.64'''&lt;br /&gt;
&lt;br /&gt;
Fixed instant/tank screen (was displaying instant/current on that screen).&lt;br /&gt;
&lt;br /&gt;
Improved LCD reinit on reprogram/reset. Can (usually) tell if LCD needs reinitializing. Press left and right buttons to force an LCD init if necessary. Want to free pin 15 for future tasks if it works well enough.&lt;br /&gt;
&lt;br /&gt;
Added a bit of default verbiage to debug mode.&lt;br /&gt;
&lt;br /&gt;
Working on a portable scope deal.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''6/20/2008 updates for v0.63'''&lt;br /&gt;
&lt;br /&gt;
Wrote 64bit arithmetic routines, yay no more messing with &amp;quot;ifs&amp;quot; when it should be math!&lt;br /&gt;
&lt;br /&gt;
Noticed double vss count didn't make it in .62, fixed.&lt;br /&gt;
&lt;br /&gt;
Subtracting 500uS from each injector pulse.&lt;br /&gt;
&lt;br /&gt;
Added cli/sei around top of loop trip copy.&lt;br /&gt;
&lt;br /&gt;
Made big font a smidgeon bolder.&lt;br /&gt;
&lt;br /&gt;
Code updated, sketch size 9812, CPU 54%, free mem 602&lt;br /&gt;
[[Category:Electronics]]&lt;/div&gt;</summary>
		<author><name>Combustor</name></author>	</entry>

	<entry>
		<id>http://combustory.com/wiki/index.php/The_Arduino_Code</id>
		<title>The Arduino Code</title>
		<link rel="alternate" type="text/html" href="http://combustory.com/wiki/index.php/The_Arduino_Code"/>
				<updated>2008-09-10T14:48:09Z</updated>
		
		<summary type="html">&lt;p&gt;Combustor: The Arduino Code moved to The MPGuino - Arduino Code&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;#REDIRECT [[The MPGuino - Arduino Code]]&lt;/div&gt;</summary>
		<author><name>Combustor</name></author>	</entry>

	<entry>
		<id>http://combustory.com/wiki/index.php/The_MPGuino_-_Arduino_Code</id>
		<title>The MPGuino - Arduino Code</title>
		<link rel="alternate" type="text/html" href="http://combustory.com/wiki/index.php/The_MPGuino_-_Arduino_Code"/>
				<updated>2008-09-10T14:48:08Z</updated>
		
		<summary type="html">&lt;p&gt;Combustor: The Arduino Code moved to The MPGuino - Arduino Code&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{default}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Check here for any updates http://opengauge.googlecode.com/svn/trunk/mpguino/mpguino.pde'''&lt;br /&gt;
&lt;br /&gt;
== MPGuino.pde Code v.7 ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#define ver=700&lt;br /&gt;
/*&lt;br /&gt;
&lt;br /&gt;
*/&lt;br /&gt;
//GPL Software    &lt;br /&gt;
//#define debuguino youbetyourbippy  &lt;br /&gt;
#include &amp;lt;avr/pgmspace.h&amp;gt;  &lt;br /&gt;
byte brightness[]={0,42,85,128}; //middle button cycles through these brightness settings      &lt;br /&gt;
#define brightnessLength (sizeof(brightness)/sizeof(byte)) //array size      &lt;br /&gt;
byte brightnessIdx=1;      &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
#define contrastIdx 0  //do contrast first to get display dialed in&lt;br /&gt;
#define vssPulsesPerMileIdx 1&lt;br /&gt;
#define microSecondsPerGallonIdx 2&lt;br /&gt;
#define injPulsesPer2Revolutions 3&lt;br /&gt;
#define currentTripResetTimeoutUSIdx 4&lt;br /&gt;
#define tankSizeIdx 5 &lt;br /&gt;
#define injectorSettleTimeIdx 6&lt;br /&gt;
#define weightIdx 7&lt;br /&gt;
#define scratchpadIdx 8&lt;br /&gt;
char *  parmLabels[]={&amp;quot;Contrast&amp;quot;,&amp;quot;VSS Pulses/Mile&amp;quot;, &amp;quot;MicroSec/Gallon&amp;quot;,&amp;quot;Pulses/2 revs&amp;quot;,&amp;quot;Timout(microSec)&amp;quot;,&amp;quot;Tank Gal * 1000&amp;quot;,&amp;quot;Injector DelayuS&amp;quot;,&amp;quot;Weight (lbs)&amp;quot;,&amp;quot;scratchpad(odo?)&amp;quot;};&lt;br /&gt;
//unsigned long  parms[]={15ul,16408ul,684968626ul,3ul,420000000ul,13300ul,500ul};//default values&lt;br /&gt;
unsigned long  parms[]={15ul,10000ul,304409714ul,4ul,420000000ul,13300ul,500ul,2400ul,0ul,};//default values&lt;br /&gt;
#define parmsLength (sizeof(parms)/sizeof(unsigned long)) //array size      &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
#define guinosig B10100101&lt;br /&gt;
#include &amp;lt;EEPROM.h&amp;gt;&lt;br /&gt;
//Vehicle Interface Pins      &lt;br /&gt;
#define InjectorOpenPin 2      &lt;br /&gt;
#define InjectorClosedPin 3      &lt;br /&gt;
#define VSSPin 14 //analog 0      &lt;br /&gt;
 &lt;br /&gt;
//LCD Pins      &lt;br /&gt;
#define DIPin 4 // register select RS      &lt;br /&gt;
#define DB4Pin 7       &lt;br /&gt;
#define DB5Pin 8       &lt;br /&gt;
#define DB6Pin 12       &lt;br /&gt;
#define DB7Pin 13      &lt;br /&gt;
#define ContrastPin 6      &lt;br /&gt;
#define EnablePin 5       &lt;br /&gt;
#define BrightnessPin 9      &lt;br /&gt;
 &lt;br /&gt;
#define lbuttonPin 17 // Left Button, on analog 3,        &lt;br /&gt;
#define mbuttonPin 18 // Middle Button, on analog 4       &lt;br /&gt;
#define rbuttonPin 19 // Right Button, on analog 5       &lt;br /&gt;
 &lt;br /&gt;
#define vssBit 1     //  pin14 is a bitmask 1 on port C        &lt;br /&gt;
#define lbuttonBit 8 //  pin17 is a bitmask 8 on port C        &lt;br /&gt;
#define mbuttonBit 16 // pin18 is a bitmask 16 on port C        &lt;br /&gt;
#define rbuttonBit 32 // pin19 is a bitmask 32 on port C        &lt;br /&gt;
#define loopsPerSecond 2 // how many times will we try and loop in a second     &lt;br /&gt;
&lt;br /&gt;
typedef void (* pFunc)(void);//type for display function pointers      &lt;br /&gt;
&lt;br /&gt;
volatile unsigned long timer2_overflow_count;&lt;br /&gt;
&lt;br /&gt;
/*** Set up the Events ***&lt;br /&gt;
We have our own ISR for timer2 which gets called about once a millisecond.&lt;br /&gt;
So we define certain event functions that we can schedule by calling addEvent&lt;br /&gt;
with the event ID and the number of milliseconds to wait before calling the event. &lt;br /&gt;
The milliseconds is approximate.&lt;br /&gt;
&lt;br /&gt;
Keep the event functions SMALL!!!  This is an interrupt!&lt;br /&gt;
&lt;br /&gt;
*/&lt;br /&gt;
//event functions&lt;br /&gt;
&lt;br /&gt;
void enableLButton(){PCMSK1 |= (1 &amp;lt;&amp;lt; PCINT11);}&lt;br /&gt;
void enableMButton(){PCMSK1 |= (1 &amp;lt;&amp;lt; PCINT12);}&lt;br /&gt;
void enableRButton(){PCMSK1 |= (1 &amp;lt;&amp;lt; PCINT13);}&lt;br /&gt;
//array of the event functions&lt;br /&gt;
pFunc eventFuncs[] ={enableVSS, enableLButton,enableMButton,enableRButton};&lt;br /&gt;
#define eventFuncSize (sizeof(eventFuncs)/sizeof(pFunc)) &lt;br /&gt;
//define the event IDs&lt;br /&gt;
#define enableVSSID 0&lt;br /&gt;
#define enableLButtonID 1&lt;br /&gt;
#define enableMButtonID 2&lt;br /&gt;
#define enableRButtonID 3&lt;br /&gt;
//ms counters&lt;br /&gt;
unsigned int eventFuncCounts[eventFuncSize];&lt;br /&gt;
&lt;br /&gt;
//schedule an event to occur ms milliseconds from now&lt;br /&gt;
void addEvent(byte eventID, unsigned int ms){&lt;br /&gt;
  eventFuncCounts[eventID]=ms;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
/* this ISR gets called every 1.024 milliseconds, we will call that a millisecond for our purposes&lt;br /&gt;
go through all the event counts, &lt;br /&gt;
  if any are non zero subtract 1 and call the associated function if it just turned zero.  */&lt;br /&gt;
ISR(TIMER2_OVF_vect){&lt;br /&gt;
  timer2_overflow_count++;&lt;br /&gt;
  for(byte eventID = 0; eventID &amp;lt; eventFuncSize; eventID++){&lt;br /&gt;
    if(eventFuncCounts[eventID]!= 0){&lt;br /&gt;
      eventFuncCounts[eventID]--;&lt;br /&gt;
      if(eventFuncCounts[eventID] == 0)&lt;br /&gt;
          eventFuncs[eventID](); &lt;br /&gt;
    }  &lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
unsigned long maxLoopLength = 0; //see if we are overutilizing the CPU      &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
#define buttonsUp   lbuttonBit + mbuttonBit + rbuttonBit  // start with the buttons in the right state      &lt;br /&gt;
byte buttonState = buttonsUp;      &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
//overflow counter used by millis2()      &lt;br /&gt;
unsigned long lastMicroSeconds=millis2() * 1000;   &lt;br /&gt;
unsigned long microSeconds (void){     &lt;br /&gt;
  unsigned long tmp_timer2_overflow_count;    &lt;br /&gt;
  unsigned long tmp;    &lt;br /&gt;
  byte tmp_tcnt2;    &lt;br /&gt;
  cli(); //disable interrupts    &lt;br /&gt;
  tmp_timer2_overflow_count = timer2_overflow_count;    &lt;br /&gt;
  tmp_tcnt2 = TCNT2;    &lt;br /&gt;
  sei(); // enable interrupts    &lt;br /&gt;
  tmp = ((tmp_timer2_overflow_count &amp;lt;&amp;lt; 8) + tmp_tcnt2) * 4;     &lt;br /&gt;
  if((tmp&amp;lt;=lastMicroSeconds) &amp;amp;&amp;amp; (lastMicroSeconds&amp;lt;4290560000ul))    &lt;br /&gt;
    return microSeconds();     &lt;br /&gt;
  lastMicroSeconds=tmp;   &lt;br /&gt;
  return tmp;     &lt;br /&gt;
}    &lt;br /&gt;
 &lt;br /&gt;
unsigned long elapsedMicroseconds(unsigned long startMicroSeconds, unsigned long currentMicroseconds ){      &lt;br /&gt;
  if(currentMicroseconds &amp;gt;= startMicroSeconds)      &lt;br /&gt;
    return currentMicroseconds-startMicroSeconds;      &lt;br /&gt;
  return 4294967295 - (startMicroSeconds-currentMicroseconds);      &lt;br /&gt;
}      &lt;br /&gt;
&lt;br /&gt;
unsigned long elapsedMicroseconds(unsigned long startMicroSeconds ){      &lt;br /&gt;
  return elapsedMicroseconds(startMicroSeconds, microSeconds());&lt;br /&gt;
}      &lt;br /&gt;
 &lt;br /&gt;
//Trip prototype      &lt;br /&gt;
class Trip{      &lt;br /&gt;
public:      &lt;br /&gt;
  unsigned long loopCount; //how long has this trip been running      &lt;br /&gt;
  unsigned long injPulses; //rpm      &lt;br /&gt;
  unsigned long injHiSec;// seconds the injector has been open      &lt;br /&gt;
  unsigned long injHius;// microseconds, fractional part of the injectors open       &lt;br /&gt;
  unsigned long vssPulses;//from the speedo      &lt;br /&gt;
  //these functions actually return in thousandths,       &lt;br /&gt;
  unsigned long miles();        &lt;br /&gt;
  unsigned long gallons();      &lt;br /&gt;
  unsigned long mpg();        &lt;br /&gt;
  unsigned long mph();        &lt;br /&gt;
  unsigned long time(); //mmm.ss        &lt;br /&gt;
  void update(Trip t);      &lt;br /&gt;
  void reset();      &lt;br /&gt;
  Trip();      &lt;br /&gt;
};      &lt;br /&gt;
 &lt;br /&gt;
//LCD prototype      &lt;br /&gt;
namespace LCD{      &lt;br /&gt;
  void gotoXY(byte x, byte y);      &lt;br /&gt;
  void print(char * string);      &lt;br /&gt;
  void init();      &lt;br /&gt;
  void tickleEnable();      &lt;br /&gt;
  void cmdWriteSet();      &lt;br /&gt;
  void LcdCommandWrite(byte value);      &lt;br /&gt;
  void LcdDataWrite(byte value);      &lt;br /&gt;
  byte pushNibble(byte value);      &lt;br /&gt;
};      &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
//main objects we will be working with:      &lt;br /&gt;
unsigned long injHiStart; //for timing injector pulses      &lt;br /&gt;
Trip tmpTrip;      &lt;br /&gt;
Trip instant;      &lt;br /&gt;
Trip current;      &lt;br /&gt;
Trip tank;      &lt;br /&gt;
 &lt;br /&gt;
void processInjOpen(void){      &lt;br /&gt;
  injHiStart = microSeconds();      &lt;br /&gt;
}      &lt;br /&gt;
 &lt;br /&gt;
void processInjClosed(void){      &lt;br /&gt;
  long x = elapsedMicroseconds(injHiStart)- parms[injectorSettleTimeIdx];       &lt;br /&gt;
  if(x &amp;gt;0)&lt;br /&gt;
    tmpTrip.injHius += x;       &lt;br /&gt;
  tmpTrip.injPulses++;      &lt;br /&gt;
}      &lt;br /&gt;
&lt;br /&gt;
volatile boolean vssFlop = 0;&lt;br /&gt;
&lt;br /&gt;
void enableVSS(){&lt;br /&gt;
    tmpTrip.vssPulses++; &lt;br /&gt;
    vssFlop = !vssFlop;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
unsigned volatile long lastVSS1;&lt;br /&gt;
unsigned volatile long lastVSSTime;&lt;br /&gt;
unsigned volatile long lastVSS2;&lt;br /&gt;
&lt;br /&gt;
volatile boolean lastVssFlop = vssFlop;&lt;br /&gt;
&lt;br /&gt;
//attach the vss/buttons interrupt      &lt;br /&gt;
ISR( PCINT1_vect ){   &lt;br /&gt;
  static byte vsspinstate=0;      &lt;br /&gt;
  byte p = PINC;//bypassing digitalRead for interrupt performance      &lt;br /&gt;
  if ((p &amp;amp; vssBit) != (vsspinstate &amp;amp; vssBit)){      &lt;br /&gt;
    addEvent(enableVSSID,2 ); //check back in a couple milli&lt;br /&gt;
  }     &lt;br /&gt;
  if(lastVssFlop != vssFlop){&lt;br /&gt;
    lastVSS1=lastVSS2;&lt;br /&gt;
    unsigned long t = microSeconds();&lt;br /&gt;
    lastVSS2=elapsedMicroseconds(lastVSSTime,t);&lt;br /&gt;
    lastVSSTime=t;&lt;br /&gt;
    lastVssFlop = vssFlop;&lt;br /&gt;
  }&lt;br /&gt;
  vsspinstate = p;      &lt;br /&gt;
  buttonState &amp;amp;= p;      &lt;br /&gt;
}       &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
pFunc displayFuncs[] ={ &lt;br /&gt;
  doDisplayInstantCurrent, &lt;br /&gt;
  doDisplayInstantTank, &lt;br /&gt;
  doDisplayBigInstant, &lt;br /&gt;
  doDisplayBigCurrent, &lt;br /&gt;
  doDisplayBigTank, &lt;br /&gt;
  doDisplay2, &lt;br /&gt;
  doDisplay3, &lt;br /&gt;
  doDisplay4, &lt;br /&gt;
  doDisplay5, &lt;br /&gt;
  doDisplay6, &lt;br /&gt;
  doDisplay7};      &lt;br /&gt;
#define displayFuncSize (sizeof(displayFuncs)/sizeof(pFunc)) //array size      &lt;br /&gt;
prog_char  * displayFuncNames[displayFuncSize]; &lt;br /&gt;
byte newRun = 0;&lt;br /&gt;
void setup (void){&lt;br /&gt;
  init2();&lt;br /&gt;
  #ifdef debuguino  &lt;br /&gt;
  Serial.begin(9600);  &lt;br /&gt;
  Serial.println(&amp;quot;OpenGauge MPGuino online&amp;quot;);  &lt;br /&gt;
  #endif      &lt;br /&gt;
  newRun = load();//load the default parameters&lt;br /&gt;
  displayFuncNames[0]=  PSTR(&amp;quot;Instant/Current &amp;quot;); &lt;br /&gt;
  displayFuncNames[1]=  PSTR(&amp;quot;Instant/Tank &amp;quot;); &lt;br /&gt;
  displayFuncNames[2]=  PSTR(&amp;quot;BIG Instant &amp;quot;); &lt;br /&gt;
  displayFuncNames[3]=  PSTR(&amp;quot;BIG Current &amp;quot;); &lt;br /&gt;
  displayFuncNames[4]=  PSTR(&amp;quot;BIG Tank &amp;quot;); &lt;br /&gt;
  displayFuncNames[5]=  PSTR(&amp;quot;Current &amp;quot;); &lt;br /&gt;
  displayFuncNames[6]=  PSTR(&amp;quot;Tank &amp;quot;); &lt;br /&gt;
  displayFuncNames[7]=  PSTR(&amp;quot;Instant raw Data&amp;quot;); &lt;br /&gt;
  displayFuncNames[8]=  PSTR(&amp;quot;Current raw Data&amp;quot;); &lt;br /&gt;
  displayFuncNames[9]=  PSTR(&amp;quot;Tank raw Data &amp;quot;); &lt;br /&gt;
  displayFuncNames[10]= PSTR(&amp;quot;CPU Monitor &amp;quot;);      &lt;br /&gt;
 &lt;br /&gt;
  pinMode(BrightnessPin,OUTPUT);      &lt;br /&gt;
  analogWrite(BrightnessPin,255-brightness[brightnessIdx]);      &lt;br /&gt;
  pinMode(EnablePin,OUTPUT);       &lt;br /&gt;
  pinMode(DIPin,OUTPUT);       &lt;br /&gt;
  pinMode(DB4Pin,OUTPUT);       &lt;br /&gt;
  pinMode(DB5Pin,OUTPUT);       &lt;br /&gt;
  pinMode(DB6Pin,OUTPUT);       &lt;br /&gt;
  pinMode(DB7Pin,OUTPUT);       &lt;br /&gt;
  delay2(500);      &lt;br /&gt;
 &lt;br /&gt;
  pinMode(ContrastPin,OUTPUT);      &lt;br /&gt;
  analogWrite(ContrastPin,parms[contrastIdx]);  &lt;br /&gt;
  LCD::init();      &lt;br /&gt;
  LCD::LcdCommandWrite(B00000001);  // clear display, set cursor position to zero         &lt;br /&gt;
  LCD::LcdCommandWrite(B10000000);  // set dram to zero&lt;br /&gt;
  LCD::gotoXY(0,0); &lt;br /&gt;
  LCD::print(getStr(PSTR(&amp;quot;OpenGauge       &amp;quot;)));      &lt;br /&gt;
  LCD::gotoXY(0,1);      &lt;br /&gt;
  LCD::print(getStr(PSTR(&amp;quot;  MPGuino  v0.70&amp;quot;)));      &lt;br /&gt;
&lt;br /&gt;
  pinMode(InjectorOpenPin, INPUT);       &lt;br /&gt;
  pinMode(InjectorClosedPin, INPUT);       &lt;br /&gt;
  pinMode(VSSPin, INPUT);            &lt;br /&gt;
  attachInterrupt(0, processInjOpen, FALLING);      &lt;br /&gt;
  attachInterrupt(1, processInjClosed, RISING);      &lt;br /&gt;
 &lt;br /&gt;
  pinMode( lbuttonPin, INPUT );       &lt;br /&gt;
  pinMode( mbuttonPin, INPUT );       &lt;br /&gt;
  pinMode( rbuttonPin, INPUT );      &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
  //&amp;quot;turn on&amp;quot; the internal pullup resistors      &lt;br /&gt;
  digitalWrite( lbuttonPin, HIGH);       &lt;br /&gt;
  digitalWrite( mbuttonPin, HIGH);       &lt;br /&gt;
  digitalWrite( rbuttonPin, HIGH);       &lt;br /&gt;
//  digitalWrite( VSSPin, HIGH);       &lt;br /&gt;
 &lt;br /&gt;
  //low level interrupt enable stuff      &lt;br /&gt;
  PCMSK1 |= (1 &amp;lt;&amp;lt; PCINT8);&lt;br /&gt;
  enableLButton();&lt;br /&gt;
  enableMButton();&lt;br /&gt;
  enableRButton();&lt;br /&gt;
  PCICR |= (1 &amp;lt;&amp;lt; PCIE1);       &lt;br /&gt;
 &lt;br /&gt;
  delay2(1500);       &lt;br /&gt;
}       &lt;br /&gt;
 &lt;br /&gt;
byte screen=0;      &lt;br /&gt;
byte holdDisplay = 0; &lt;br /&gt;
&lt;br /&gt;
#define looptime 1000000ul/loopsPerSecond //1/2 second      &lt;br /&gt;
void loop (void){       &lt;br /&gt;
  if(newRun !=1)&lt;br /&gt;
    initGuino();//go through the initialization screen&lt;br /&gt;
  unsigned long lastActivity =microSeconds();&lt;br /&gt;
  unsigned long tankHold;      //state at point of last activity&lt;br /&gt;
  while(true){      &lt;br /&gt;
    unsigned long loopStart=microSeconds();      &lt;br /&gt;
    instant.reset();           //clear instant      &lt;br /&gt;
    cli();&lt;br /&gt;
    instant.update(tmpTrip);   //&amp;quot;copy&amp;quot; of tmpTrip in instant now      &lt;br /&gt;
    tmpTrip.reset();           //reset tmpTrip first so we don't lose too many interrupts      &lt;br /&gt;
    sei();&lt;br /&gt;
    &lt;br /&gt;
    #ifdef debuguino  &lt;br /&gt;
    Serial.print(&amp;quot;instant: &amp;quot;);Serial.print(instant.injHiSec);Serial.print(&amp;quot;,&amp;quot;);Serial.print(instant.injHius);  &lt;br /&gt;
    Serial.print(&amp;quot;,&amp;quot;);Serial.print(instant.injPulses);Serial.print(&amp;quot;,&amp;quot;);Serial.println(instant.vssPulses);      &lt;br /&gt;
    #endif  &lt;br /&gt;
    current.update(instant);   //use instant to update current      &lt;br /&gt;
    tank.update(instant);      //use instant to update tank      &lt;br /&gt;
    #ifdef debuguino  &lt;br /&gt;
    Serial.print(&amp;quot;current: &amp;quot;);Serial.print(current.injHiSec);Serial.print(&amp;quot;,&amp;quot;);Serial.print(current.injHius);  &lt;br /&gt;
    Serial.print(&amp;quot;,&amp;quot;);Serial.print(current.injPulses);Serial.print(&amp;quot;,&amp;quot;);Serial.println(current.vssPulses);      &lt;br /&gt;
    #endif  &lt;br /&gt;
&lt;br /&gt;
//currentTripResetTimeoutUS&lt;br /&gt;
    if(instant.vssPulses == 0 &amp;amp;&amp;amp; instant.injPulses == 0 &amp;amp;&amp;amp; holdDisplay==0){&lt;br /&gt;
      if(elapsedMicroseconds(lastActivity) &amp;gt; parms[currentTripResetTimeoutUSIdx] &amp;amp;&amp;amp; lastActivity != 3999999999ul){&lt;br /&gt;
        analogWrite(BrightnessPin,255-brightness[0]);    //nitey night&lt;br /&gt;
        lastActivity = 3999999999ul;&lt;br /&gt;
      }&lt;br /&gt;
    }else{&lt;br /&gt;
      if(lastActivity == 3999999999ul){//wake up!!!&lt;br /&gt;
        analogWrite(BrightnessPin,255-brightness[brightnessIdx]);    &lt;br /&gt;
        lastActivity=loopStart;&lt;br /&gt;
        current.reset();&lt;br /&gt;
        tank.loopCount = tankHold;&lt;br /&gt;
        current.update(instant); &lt;br /&gt;
        tank.update(instant); &lt;br /&gt;
      }else{&lt;br /&gt;
        lastActivity=loopStart;&lt;br /&gt;
        tankHold = tank.loopCount;&lt;br /&gt;
      }&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
 if(holdDisplay==0){&lt;br /&gt;
    displayFuncs[screen]();    //call the appropriate display routine      &lt;br /&gt;
    LCD::gotoXY(0,0);        &lt;br /&gt;
    &lt;br /&gt;
//see if any buttons were pressed, display a brief message if so      &lt;br /&gt;
      if(!(buttonState&amp;amp;lbuttonBit) &amp;amp;&amp;amp; !(buttonState&amp;amp;mbuttonBit)&amp;amp;&amp;amp; !(buttonState&amp;amp;rbuttonBit)){// left and middle and right = initialize      &lt;br /&gt;
          LCD::print(getStr(PSTR(&amp;quot;Setup &amp;quot;)));    &lt;br /&gt;
          initGuino();  &lt;br /&gt;
      //}else if(!(buttonState&amp;amp;lbuttonBit) &amp;amp;&amp;amp; !(buttonState&amp;amp;rbuttonBit)){// left and right = run lcd init = tank reset      &lt;br /&gt;
      //    LCD::print(getStr(PSTR(&amp;quot;Init LCD &amp;quot;))); &lt;br /&gt;
      //    LCD::init();&lt;br /&gt;
      }else if (!(buttonState&amp;amp;lbuttonBit) &amp;amp;&amp;amp; !(buttonState&amp;amp;mbuttonBit)){// left and middle = tank reset      &lt;br /&gt;
          tank.reset();      &lt;br /&gt;
          LCD::print(getStr(PSTR(&amp;quot;Tank Reset &amp;quot;)));      &lt;br /&gt;
      }else if(!(buttonState&amp;amp;mbuttonBit) &amp;amp;&amp;amp; !(buttonState&amp;amp;rbuttonBit)){// right and middle = current reset      &lt;br /&gt;
          current.reset();      &lt;br /&gt;
          LCD::print(getStr(PSTR(&amp;quot;Current Reset &amp;quot;)));      &lt;br /&gt;
      }else if(!(buttonState&amp;amp;lbuttonBit)){ //left is rotate through screeens to the left      &lt;br /&gt;
        if(screen!=0)      &lt;br /&gt;
          screen=(screen-1);       &lt;br /&gt;
        else      &lt;br /&gt;
          screen=displayFuncSize-1;      &lt;br /&gt;
        LCD::print(getStr(displayFuncNames[screen]));      &lt;br /&gt;
      }else if(!(buttonState&amp;amp;mbuttonBit)){ //middle is cycle through brightness settings      &lt;br /&gt;
        brightnessIdx = (brightnessIdx + 1) % brightnessLength;      &lt;br /&gt;
        analogWrite(BrightnessPin,255-brightness[brightnessIdx]);      &lt;br /&gt;
        LCD::print(getStr(PSTR(&amp;quot;Brightness &amp;quot;)));      &lt;br /&gt;
        LCD::LcdDataWrite('0' + brightnessIdx);      &lt;br /&gt;
        LCD::print(&amp;quot; &amp;quot;);      &lt;br /&gt;
      }else if(!(buttonState&amp;amp;rbuttonBit)){//right is rotate through screeens to the left      &lt;br /&gt;
        screen=(screen+1)%displayFuncSize;      &lt;br /&gt;
        LCD::print(getStr(displayFuncNames[screen]));      &lt;br /&gt;
      }      &lt;br /&gt;
      if(buttonState!=buttonsUp)&lt;br /&gt;
         holdDisplay=1;&lt;br /&gt;
     }else{&lt;br /&gt;
        holdDisplay=0;&lt;br /&gt;
    } &lt;br /&gt;
    buttonState=buttonsUp;//reset the buttons      &lt;br /&gt;
 &lt;br /&gt;
      //keep track of how long the loops take before we go int waiting.      &lt;br /&gt;
      unsigned long loopX=elapsedMicroseconds(loopStart);      &lt;br /&gt;
      if(loopX&amp;gt;maxLoopLength) maxLoopLength = loopX;      &lt;br /&gt;
 &lt;br /&gt;
      while (elapsedMicroseconds(loopStart) &amp;lt; (looptime));//wait for the end of a second to arrive      &lt;br /&gt;
  }      &lt;br /&gt;
 &lt;br /&gt;
}       &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
char fBuff[7];//used by format      &lt;br /&gt;
//format a number into NNN.NN  the number should already be representing thousandths      &lt;br /&gt;
char* format(unsigned long num){      &lt;br /&gt;
  unsigned long d = 10000;      &lt;br /&gt;
  long t;      &lt;br /&gt;
  byte dp=3;      &lt;br /&gt;
  byte l=6;      &lt;br /&gt;
 &lt;br /&gt;
  //123456 = 123.46      &lt;br /&gt;
  if(num&amp;gt;9999999){      &lt;br /&gt;
    d=100000;      &lt;br /&gt;
    dp=99;      &lt;br /&gt;
    num/=100;      &lt;br /&gt;
  }else if(num&amp;gt;999999){      &lt;br /&gt;
    dp=4;      &lt;br /&gt;
    num/=10;      &lt;br /&gt;
  }      &lt;br /&gt;
 &lt;br /&gt;
  unsigned long val = num/10;      &lt;br /&gt;
  if ((num - (val * 10)) &amp;gt;= 5)  //will the first unprinted digit be greater than 4?      &lt;br /&gt;
    val += 1;   //round up val      &lt;br /&gt;
 &lt;br /&gt;
  for(byte x = 0; x &amp;lt; l; x++){      &lt;br /&gt;
    if(x==dp)      //time to poke in the decimal point?      &lt;br /&gt;
      fBuff[x]='.';      &lt;br /&gt;
    else{      &lt;br /&gt;
      t = val/d;        &lt;br /&gt;
      fBuff[x]= '0' + t%10;//poke the ascii character for the digit.      &lt;br /&gt;
      val-= t*d;      &lt;br /&gt;
      d/=10;            &lt;br /&gt;
    }      &lt;br /&gt;
  }      &lt;br /&gt;
  fBuff[6]= 0;         //good old zero terminated strings       &lt;br /&gt;
  return fBuff;      &lt;br /&gt;
}  &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
//get a string from flash &lt;br /&gt;
char mBuff[17];//used by getStr &lt;br /&gt;
char * getStr(prog_char * str){ &lt;br /&gt;
  strcpy_P(mBuff, str); &lt;br /&gt;
  return mBuff; &lt;br /&gt;
} &lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
void doDisplayInstantCurrent(){displayTripCombo('I','M',instant.mpg(),'S',instantmph(),'C','M',current.mpg(),'D',current.miles());}      &lt;br /&gt;
 &lt;br /&gt;
void doDisplayInstantTank(){displayTripCombo('I','M',instant.mpg(),'S',instantmph(),'T','M',tank.mpg(),'D',tank.miles());}      &lt;br /&gt;
 &lt;br /&gt;
void doDisplayBigInstant() {bigNum(instant.mpg(),&amp;quot;INST&amp;quot;,&amp;quot;MPG &amp;quot;);}      &lt;br /&gt;
void doDisplayBigCurrent() {bigNum(current.mpg(),&amp;quot;CURR&amp;quot;,&amp;quot;MPG &amp;quot;);}      &lt;br /&gt;
void doDisplayBigTank()    {bigNum(tank.mpg(),&amp;quot;TANK&amp;quot;,&amp;quot;MPG &amp;quot;);}      &lt;br /&gt;
 &lt;br /&gt;
void doDisplay2(void){tDisplay(&amp;amp;current);}   //display current trip formatted data.        &lt;br /&gt;
void doDisplay3(void){tDisplay(&amp;amp;tank);}      //display tank trip formatted data.        &lt;br /&gt;
void doDisplay4(void){rawDisplay(&amp;amp;instant);} //display instant trip &amp;quot;raw&amp;quot; injector and vss data.        &lt;br /&gt;
void doDisplay5(void){rawDisplay(&amp;amp;current);} //display current trip &amp;quot;raw&amp;quot; injector and vss data.        &lt;br /&gt;
void doDisplay6(void){rawDisplay(&amp;amp;tank);}    //display tank trip &amp;quot;raw&amp;quot; injector and vss data.        &lt;br /&gt;
void doDisplay7(void){      &lt;br /&gt;
  LCD::gotoXY(0,0);LCD::print(&amp;quot;C%&amp;quot;);LCD::print(format(maxLoopLength*1000/(looptime/100)));LCD::print(&amp;quot; T&amp;quot;); LCD::print(format(tank.time()));     &lt;br /&gt;
  unsigned long mem = memoryTest();      &lt;br /&gt;
  mem*=1000;      &lt;br /&gt;
  LCD::gotoXY(0,1);LCD::print(&amp;quot;FREE MEM: &amp;quot;);LCD::print(format(mem));      &lt;br /&gt;
}    //display max cpu utilization and ram.        &lt;br /&gt;
 &lt;br /&gt;
void displayTripCombo(char t1, char t1L1, unsigned long t1V1, char t1L2, unsigned long t1V2,  char t2, char t2L1, unsigned long t2V1, char t2L2, unsigned long t2V2){ &lt;br /&gt;
  LCD::gotoXY(0,0);LCD::LcdDataWrite(t1);LCD::LcdDataWrite(t1L1);LCD::print(format(t1V1));LCD::LcdDataWrite(' '); &lt;br /&gt;
      LCD::LcdDataWrite(t1L2);LCD::print(format(t1V2)); &lt;br /&gt;
  LCD::gotoXY(0,1);LCD::LcdDataWrite(t2);LCD::LcdDataWrite(t2L1);LCD::print(format(t2V1));LCD::LcdDataWrite(' '); &lt;br /&gt;
      LCD::LcdDataWrite(t2L2);LCD::print(format(t2V2)); &lt;br /&gt;
}      &lt;br /&gt;
 &lt;br /&gt;
//arduino doesn't do well with types defined in a script as parameters, so have to pass as void * and use -&amp;gt; notation.      &lt;br /&gt;
void tDisplay( void * r){ //display trip functions.        &lt;br /&gt;
  Trip *t = (Trip *)r;      &lt;br /&gt;
  LCD::gotoXY(0,0);LCD::print(&amp;quot;MH&amp;quot;);LCD::print(format(t-&amp;gt;mph()));LCD::print(&amp;quot;MG&amp;quot;);LCD::print(format(t-&amp;gt;mpg()));      &lt;br /&gt;
  LCD::gotoXY(0,1);LCD::print(&amp;quot;MI&amp;quot;);LCD::print(format(t-&amp;gt;miles()));LCD::print(&amp;quot;GA&amp;quot;);LCD::print(format(t-&amp;gt;gallons()));      &lt;br /&gt;
}      &lt;br /&gt;
 &lt;br /&gt;
void rawDisplay(void * r){      &lt;br /&gt;
  Trip *t = (Trip *)r;      &lt;br /&gt;
  LCD::gotoXY(0,0);LCD::print(&amp;quot;IJ&amp;quot;);LCD::print(format(t-&amp;gt;injHiSec*1000));LCD::print(&amp;quot;uS&amp;quot;);LCD::print(format(t-&amp;gt;injHius*1000));      &lt;br /&gt;
  LCD::gotoXY(0,1);LCD::print(&amp;quot;IC&amp;quot;);LCD::print(format(t-&amp;gt;injPulses*1000));LCD::print(&amp;quot;VC&amp;quot;);LCD::print(format(t-&amp;gt;vssPulses*1000));      &lt;br /&gt;
}      &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
    &lt;br /&gt;
//x=0..16, y= 0..1      &lt;br /&gt;
void LCD::gotoXY(byte x, byte y){      &lt;br /&gt;
  byte dr=x+0x80;      &lt;br /&gt;
  if (y==1)       &lt;br /&gt;
    dr += 0x40;      &lt;br /&gt;
  if (y==2)       &lt;br /&gt;
    dr += 0x14;      &lt;br /&gt;
  if (y==3)       &lt;br /&gt;
    dr += 0x54;      &lt;br /&gt;
  LCD::LcdCommandWrite(dr);        &lt;br /&gt;
}      &lt;br /&gt;
 &lt;br /&gt;
void LCD::print(char * string){      &lt;br /&gt;
  byte x = 0;      &lt;br /&gt;
  char c = string[x];      &lt;br /&gt;
  while(c != 0){      &lt;br /&gt;
    LCD::LcdDataWrite(c);       &lt;br /&gt;
    x++;      &lt;br /&gt;
    c = string[x];      &lt;br /&gt;
  }      &lt;br /&gt;
}      &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
void LCD::init(){&lt;br /&gt;
  delay2(16);                    // wait for more than 15 msec&lt;br /&gt;
  pushNibble(B00110000);  // send (B0011) to DB7-4&lt;br /&gt;
  cmdWriteSet();&lt;br /&gt;
  tickleEnable();&lt;br /&gt;
  delay2(5);                     // wait for more than 4.1 msec&lt;br /&gt;
  pushNibble(B00110000);  // send (B0011) to DB7-4&lt;br /&gt;
  cmdWriteSet();&lt;br /&gt;
  tickleEnable();&lt;br /&gt;
  delay2(1);                     // wait for more than 100 usec&lt;br /&gt;
  pushNibble(B00110000);  // send (B0011) to DB7-4&lt;br /&gt;
  cmdWriteSet();&lt;br /&gt;
  tickleEnable();&lt;br /&gt;
  delay2(1);                     // wait for more than 100 usec&lt;br /&gt;
  pushNibble(B00100000);  // send (B0010) to DB7-4 for 4bit&lt;br /&gt;
  cmdWriteSet();&lt;br /&gt;
  tickleEnable();&lt;br /&gt;
  delay2(1);                     // wait for more than 100 usec&lt;br /&gt;
  // ready to use normal LcdCommandWrite() function now!&lt;br /&gt;
  LcdCommandWrite(B00101000);   // 4-bit interface, 2 display lines, 5x8 font&lt;br /&gt;
  LcdCommandWrite(B00001100);   // display control:&lt;br /&gt;
  LcdCommandWrite(B00000110);   // entry mode set: increment automatically, no display shift&lt;br /&gt;
&lt;br /&gt;
//creating the custom fonts:&lt;br /&gt;
  LcdCommandWrite(B01001000);  // set cgram&lt;br /&gt;
  static byte chars[] PROGMEM ={&lt;br /&gt;
    B11111,B00000,B11111,B11111,B00000,&lt;br /&gt;
    B11111,B00000,B11111,B11111,B00000,&lt;br /&gt;
    B11111,B00000,B11111,B11111,B00000,&lt;br /&gt;
    B00000,B00000,B00000,B11111,B00000,&lt;br /&gt;
    B00000,B00000,B00000,B11111,B00000,&lt;br /&gt;
    B00000,B11111,B11111,B11111,B01110,&lt;br /&gt;
    B00000,B11111,B11111,B11111,B01110,&lt;br /&gt;
    B00000,B11111,B11111,B11111,B01110};&lt;br /&gt;
&lt;br /&gt;
    for(byte x=0;x&amp;lt;5;x++)&lt;br /&gt;
      for(byte y=0;y&amp;lt;8;y++)&lt;br /&gt;
          LcdDataWrite(pgm_read_byte(&amp;amp;chars[y*5+x])); //write the character data to the character generator ram&lt;br /&gt;
&lt;br /&gt;
  LcdCommandWrite(B00000001);  // clear display, set cursor position to zero&lt;br /&gt;
  LcdCommandWrite(B10000000);  // set dram to zero&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
void  LCD::tickleEnable(){       &lt;br /&gt;
  // send a pulse to enable       &lt;br /&gt;
  digitalWrite(EnablePin,HIGH);       &lt;br /&gt;
  delayMicroseconds2(1);  // pause 1 ms according to datasheet       &lt;br /&gt;
  digitalWrite(EnablePin,LOW);       &lt;br /&gt;
  delayMicroseconds2(1);  // pause 1 ms according to datasheet       &lt;br /&gt;
}        &lt;br /&gt;
 &lt;br /&gt;
void LCD::cmdWriteSet(){       &lt;br /&gt;
  digitalWrite(EnablePin,LOW);       &lt;br /&gt;
  delayMicroseconds2(1);  // pause 1 ms according to datasheet       &lt;br /&gt;
  digitalWrite(DIPin,0);       &lt;br /&gt;
}       &lt;br /&gt;
 &lt;br /&gt;
byte LCD::pushNibble(byte value){       &lt;br /&gt;
  digitalWrite(DB7Pin, value &amp;amp; 128);       &lt;br /&gt;
  value &amp;lt;&amp;lt;= 1;       &lt;br /&gt;
  digitalWrite(DB6Pin, value &amp;amp; 128);       &lt;br /&gt;
  value &amp;lt;&amp;lt;= 1;       &lt;br /&gt;
  digitalWrite(DB5Pin, value &amp;amp; 128);       &lt;br /&gt;
  value &amp;lt;&amp;lt;= 1;       &lt;br /&gt;
  digitalWrite(DB4Pin, value &amp;amp; 128);       &lt;br /&gt;
  value &amp;lt;&amp;lt;= 1;       &lt;br /&gt;
  return value;      &lt;br /&gt;
}      &lt;br /&gt;
 &lt;br /&gt;
void LCD::LcdCommandWrite(byte value){       &lt;br /&gt;
  value=pushNibble(value);      &lt;br /&gt;
  cmdWriteSet();       &lt;br /&gt;
  tickleEnable();       &lt;br /&gt;
  value=pushNibble(value);      &lt;br /&gt;
  cmdWriteSet();       &lt;br /&gt;
  tickleEnable();       &lt;br /&gt;
  delay2(5);       &lt;br /&gt;
}       &lt;br /&gt;
 &lt;br /&gt;
void LCD::LcdDataWrite(byte value){       &lt;br /&gt;
  digitalWrite(DIPin, HIGH);       &lt;br /&gt;
  value=pushNibble(value);      &lt;br /&gt;
  tickleEnable();       &lt;br /&gt;
  value=pushNibble(value);      &lt;br /&gt;
  tickleEnable();       &lt;br /&gt;
  delay2(5);       &lt;br /&gt;
}       &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
// this function will return the number of bytes currently free in RAM      &lt;br /&gt;
extern int  __bss_end; &lt;br /&gt;
extern int  *__brkval; &lt;br /&gt;
int memoryTest(){ &lt;br /&gt;
  int free_memory; &lt;br /&gt;
  if((int)__brkval == 0) &lt;br /&gt;
    free_memory = ((int)&amp;amp;free_memory) - ((int)&amp;amp;__bss_end); &lt;br /&gt;
  else &lt;br /&gt;
    free_memory = ((int)&amp;amp;free_memory) - ((int)__brkval); &lt;br /&gt;
  return free_memory; &lt;br /&gt;
} &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
Trip::Trip(){      &lt;br /&gt;
}      &lt;br /&gt;
 &lt;br /&gt;
//for display computing&lt;br /&gt;
unsigned long tmp1[2];&lt;br /&gt;
unsigned long tmp2[2];&lt;br /&gt;
unsigned long tmp3[2];&lt;br /&gt;
&lt;br /&gt;
unsigned long instantmph(){      &lt;br /&gt;
  cli();&lt;br /&gt;
  unsigned long vssPulseTimeuS = (lastVSS1 + lastVSS2) / 2;&lt;br /&gt;
  sei();&lt;br /&gt;
  init64(tmp1,0,1000000000ul);&lt;br /&gt;
  init64(tmp2,0,parms[vssPulsesPerMileIdx]);&lt;br /&gt;
  div64(tmp1,tmp2);&lt;br /&gt;
  init64(tmp2,0,3600);&lt;br /&gt;
  mul64(tmp1,tmp2);&lt;br /&gt;
  init64(tmp2,0,vssPulseTimeuS);&lt;br /&gt;
  div64(tmp1,tmp2);&lt;br /&gt;
  return tmp1[1];&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
unsigned long instantmpg(){      &lt;br /&gt;
  cli();&lt;br /&gt;
  unsigned long vssPulseTimeuS = (lastVSS1 + lastVSS2) / 2;&lt;br /&gt;
  sei();&lt;br /&gt;
  init64(tmp1,0,1000000000ul); &lt;br /&gt;
  init64(tmp2,0,parms[vssPulsesPerMileIdx]);&lt;br /&gt;
  div64(tmp1,tmp2);&lt;br /&gt;
  init64(tmp2,0,3600);&lt;br /&gt;
  mul64(tmp1,tmp2);&lt;br /&gt;
  init64(tmp2,0,vssPulseTimeuS);&lt;br /&gt;
  div64(tmp1,tmp2);&lt;br /&gt;
//  return tmp1[1];&lt;br /&gt;
  &lt;br /&gt;
  &lt;br /&gt;
    init64(tmp1,0,instant.injHiSec);&lt;br /&gt;
  init64(tmp2,0,1000000);&lt;br /&gt;
  mul64(tmp1,tmp2);&lt;br /&gt;
  init64(tmp2,0,instant.injHius);&lt;br /&gt;
  add64(tmp1,tmp2); &lt;br /&gt;
  init64(tmp2,0,1000);&lt;br /&gt;
  mul64(tmp1,tmp2);&lt;br /&gt;
  init64(tmp2,0,parms[microSecondsPerGallonIdx]);&lt;br /&gt;
  div64(tmp1,tmp2);&lt;br /&gt;
  return tmp1[1];      &lt;br /&gt;
&lt;br /&gt;
  &lt;br /&gt;
  &lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
unsigned long Trip::miles(){      &lt;br /&gt;
  init64(tmp1,0,vssPulses);&lt;br /&gt;
  init64(tmp2,0,1000);&lt;br /&gt;
  mul64(tmp1,tmp2);&lt;br /&gt;
  init64(tmp2,0,parms[vssPulsesPerMileIdx]);&lt;br /&gt;
  div64(tmp1,tmp2);&lt;br /&gt;
  return tmp1[1];      &lt;br /&gt;
}      &lt;br /&gt;
 &lt;br /&gt;
unsigned long Trip::mph(){      &lt;br /&gt;
  if(loopCount == 0)     &lt;br /&gt;
     return 0;     &lt;br /&gt;
  init64(tmp1,0,loopsPerSecond);&lt;br /&gt;
  init64(tmp2,0,vssPulses);&lt;br /&gt;
  mul64(tmp1,tmp2);&lt;br /&gt;
  init64(tmp2,0,3600000);&lt;br /&gt;
  mul64(tmp1,tmp2);&lt;br /&gt;
  init64(tmp2,0,parms[vssPulsesPerMileIdx]);&lt;br /&gt;
  div64(tmp1,tmp2);&lt;br /&gt;
  init64(tmp2,0,loopCount);&lt;br /&gt;
  div64(tmp1,tmp2);&lt;br /&gt;
  return tmp1[1];      &lt;br /&gt;
}      &lt;br /&gt;
 &lt;br /&gt;
unsigned long  Trip::gallons(){      &lt;br /&gt;
  init64(tmp1,0,injHiSec);&lt;br /&gt;
  init64(tmp2,0,1000000);&lt;br /&gt;
  mul64(tmp1,tmp2);&lt;br /&gt;
  init64(tmp2,0,injHius);&lt;br /&gt;
  add64(tmp1,tmp2);&lt;br /&gt;
  init64(tmp2,0,1000);&lt;br /&gt;
  mul64(tmp1,tmp2);&lt;br /&gt;
  init64(tmp2,0,parms[microSecondsPerGallonIdx]);&lt;br /&gt;
  div64(tmp1,tmp2);&lt;br /&gt;
  return tmp1[1];      &lt;br /&gt;
}      &lt;br /&gt;
 &lt;br /&gt;
unsigned long  Trip::mpg(){      &lt;br /&gt;
  if(vssPulses==0) return 0;      &lt;br /&gt;
  if(injPulses==0) return 999999000; //who doesn't like to see 999999?  :)      &lt;br /&gt;
 &lt;br /&gt;
  init64(tmp1,0,injHiSec);&lt;br /&gt;
  init64(tmp3,0,1000000);&lt;br /&gt;
  mul64(tmp3,tmp1);&lt;br /&gt;
  init64(tmp1,0,injHius);&lt;br /&gt;
  add64(tmp3,tmp1);&lt;br /&gt;
  init64(tmp1,0,parms[vssPulsesPerMileIdx]);&lt;br /&gt;
  mul64(tmp3,tmp1);&lt;br /&gt;
 &lt;br /&gt;
  init64(tmp1,0,parms[microSecondsPerGallonIdx]);&lt;br /&gt;
  init64(tmp2,0,1000);&lt;br /&gt;
  mul64(tmp1,tmp2);&lt;br /&gt;
  init64(tmp2,0,vssPulses);&lt;br /&gt;
  mul64(tmp1,tmp2);&lt;br /&gt;
 &lt;br /&gt;
  div64(tmp1,tmp3);&lt;br /&gt;
  return tmp1[1];      &lt;br /&gt;
}      &lt;br /&gt;
 &lt;br /&gt;
//return the seconds as a time mmm.ss, eventually hhh:mm too      &lt;br /&gt;
unsigned long Trip::time(){      &lt;br /&gt;
//  return seconds*1000;      &lt;br /&gt;
  byte d = 60;      &lt;br /&gt;
  unsigned long seconds = loopCount/loopsPerSecond;     &lt;br /&gt;
//  if(seconds/60 &amp;gt; 999) d = 3600; //scale up to hours.minutes if we get past 999 minutes      &lt;br /&gt;
  return ((seconds/d)*1000) + ((seconds%d) * 10);       &lt;br /&gt;
}      &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
void Trip::reset(){      &lt;br /&gt;
  loopCount=0;      &lt;br /&gt;
  injPulses=0;      &lt;br /&gt;
  injHius=0;      &lt;br /&gt;
  injHiSec=0;      &lt;br /&gt;
  vssPulses=0;      &lt;br /&gt;
}      &lt;br /&gt;
 &lt;br /&gt;
void Trip::update(Trip t){     &lt;br /&gt;
  loopCount++;  //we call update once per loop     &lt;br /&gt;
  vssPulses+=t.vssPulses;      &lt;br /&gt;
  if(t.injPulses &amp;gt; 2 &amp;amp;&amp;amp; t.injHius&amp;lt;500000){//chasing ghosts      &lt;br /&gt;
    injPulses+=t.injPulses;      &lt;br /&gt;
    injHius+=t.injHius;      &lt;br /&gt;
    if (injHius&amp;gt;=1000000){  //rollover into the injHiSec counter      &lt;br /&gt;
      injHiSec++;      &lt;br /&gt;
      injHius-=1000000;      &lt;br /&gt;
    }      &lt;br /&gt;
  }      &lt;br /&gt;
}   &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
char bignumchars1[]={4,1,4,0, 1,4,32,0, 3,3,4,0, 1,3,4,0, 4,2,4,0,   4,3,3,0, 4,3,3,0, 1,1,4,0,   4,3,4,0, 4,3,4,0}; &lt;br /&gt;
char bignumchars2[]={4,2,4,0, 2,4,2,0,  4,2,2,0, 2,2,4,0, 32,32,4,0, 2,2,4,0, 4,2,4,0, 32,4,32,0, 4,2,4,0, 2,2,4,0};  &lt;br /&gt;
 &lt;br /&gt;
void bigNum (unsigned long t, char * txt1, char * txt2){      &lt;br /&gt;
//  unsigned long t = 98550ul;//number in thousandths &lt;br /&gt;
//  unsigned long t = 9855ul;//number in thousandths &lt;br /&gt;
//  char * txt1=&amp;quot;INST&amp;quot;; &lt;br /&gt;
//  char * txt2=&amp;quot;MPG &amp;quot;; &lt;br /&gt;
  char  dp = 32; &lt;br /&gt;
 &lt;br /&gt;
  char * r = &amp;quot;009.99&amp;quot;; //&amp;quot;009.99&amp;quot; &amp;quot;000.99&amp;quot; &amp;quot;000.09&amp;quot; &lt;br /&gt;
  if(t&amp;lt;=99500){ &lt;br /&gt;
    r=format(t/10); //009.86 &lt;br /&gt;
    dp=5; &lt;br /&gt;
  }else if(t&amp;lt;=999500){ &lt;br /&gt;
    r=format(t/100); //009.86 &lt;br /&gt;
  }   &lt;br /&gt;
 &lt;br /&gt;
  LCD::gotoXY(0,0); &lt;br /&gt;
  LCD::print(bignumchars1+(r[2]-'0')*4); &lt;br /&gt;
  LCD::print(&amp;quot; &amp;quot;); &lt;br /&gt;
  LCD::print(bignumchars1+(r[4]-'0')*4); &lt;br /&gt;
  LCD::print(&amp;quot; &amp;quot;); &lt;br /&gt;
  LCD::print(bignumchars1+(r[5]-'0')*4); &lt;br /&gt;
  LCD::print(&amp;quot; &amp;quot;); &lt;br /&gt;
  LCD::print(txt1); &lt;br /&gt;
 &lt;br /&gt;
  LCD::gotoXY(0,1); &lt;br /&gt;
  LCD::print(bignumchars2+(r[2]-'0')*4); &lt;br /&gt;
  LCD::print(&amp;quot; &amp;quot;); &lt;br /&gt;
  LCD::print(bignumchars2+(r[4]-'0')*4); &lt;br /&gt;
  LCD::LcdDataWrite(dp); &lt;br /&gt;
  LCD::print(bignumchars2+(r[5]-'0')*4); &lt;br /&gt;
  LCD::print(&amp;quot; &amp;quot;); &lt;br /&gt;
  LCD::print(txt2); &lt;br /&gt;
}      &lt;br /&gt;
 &lt;br /&gt;
//the standard 64 bit math brings in  5000+ bytes&lt;br /&gt;
//these bring in 1214 bytes, and everything is pass by reference&lt;br /&gt;
unsigned long zero64[]={0,0};&lt;br /&gt;
 &lt;br /&gt;
void init64(unsigned long  an[], unsigned long bigPart, unsigned long littlePart ){&lt;br /&gt;
  an[0]=bigPart;&lt;br /&gt;
  an[1]=littlePart;&lt;br /&gt;
}&lt;br /&gt;
 &lt;br /&gt;
//left shift 64 bit &amp;quot;number&amp;quot;&lt;br /&gt;
void shl64(unsigned long  an[]){&lt;br /&gt;
 an[0] &amp;lt;&amp;lt;= 1; &lt;br /&gt;
 if(an[1] &amp;amp; 0x80000000)&lt;br /&gt;
   an[0]++; &lt;br /&gt;
 an[1] &amp;lt;&amp;lt;= 1; &lt;br /&gt;
}&lt;br /&gt;
 &lt;br /&gt;
//right shift 64 bit &amp;quot;number&amp;quot;&lt;br /&gt;
void shr64(unsigned long  an[]){&lt;br /&gt;
 an[1] &amp;gt;&amp;gt;= 1; &lt;br /&gt;
 if(an[0] &amp;amp; 0x1)&lt;br /&gt;
   an[1]+=0x80000000; &lt;br /&gt;
 an[0] &amp;gt;&amp;gt;= 1; &lt;br /&gt;
}&lt;br /&gt;
 &lt;br /&gt;
//add ann to an&lt;br /&gt;
void add64(unsigned long  an[], unsigned long  ann[]){&lt;br /&gt;
  an[0]+=ann[0];&lt;br /&gt;
  if(an[1] + ann[1] &amp;lt; ann[1])&lt;br /&gt;
    an[0]++;&lt;br /&gt;
  an[1]+=ann[1];&lt;br /&gt;
}&lt;br /&gt;
 &lt;br /&gt;
//subtract ann from an&lt;br /&gt;
void sub64(unsigned long  an[], unsigned long  ann[]){&lt;br /&gt;
  an[0]-=ann[0];&lt;br /&gt;
  if(an[1] &amp;lt; ann[1]){&lt;br /&gt;
    an[0]--;&lt;br /&gt;
  }&lt;br /&gt;
  an[1]-= ann[1];&lt;br /&gt;
}&lt;br /&gt;
 &lt;br /&gt;
//true if an == ann&lt;br /&gt;
boolean eq64(unsigned long  an[], unsigned long  ann[]){&lt;br /&gt;
  return (an[0]==ann[0]) &amp;amp;&amp;amp; (an[1]==ann[1]);&lt;br /&gt;
}&lt;br /&gt;
 &lt;br /&gt;
//true if an &amp;lt; ann&lt;br /&gt;
boolean lt64(unsigned long  an[], unsigned long  ann[]){&lt;br /&gt;
  if(an[0]&amp;gt;ann[0]) return false;&lt;br /&gt;
  return (an[0]&amp;lt;ann[0]) || (an[1]&amp;lt;ann[1]);&lt;br /&gt;
}&lt;br /&gt;
 &lt;br /&gt;
//divide num by den&lt;br /&gt;
void div64(unsigned long num[], unsigned long den[]){&lt;br /&gt;
  unsigned long quot[2];&lt;br /&gt;
  unsigned long qbit[2];&lt;br /&gt;
  unsigned long tmp[2];&lt;br /&gt;
  init64(quot,0,0);&lt;br /&gt;
  init64(qbit,0,1);&lt;br /&gt;
 &lt;br /&gt;
  if (eq64(num, zero64)) {  //numerator 0, call it 0&lt;br /&gt;
    init64(num,0,0);&lt;br /&gt;
    return;        &lt;br /&gt;
  }&lt;br /&gt;
 &lt;br /&gt;
  if (eq64(den, zero64)) { //numerator not zero, denominator 0, infinity in my book.&lt;br /&gt;
    init64(num,0xffffffff,0xffffffff);&lt;br /&gt;
    return;        &lt;br /&gt;
  }&lt;br /&gt;
 &lt;br /&gt;
  init64(tmp,0x80000000,0);&lt;br /&gt;
  while(lt64(den,tmp)){&lt;br /&gt;
    shl64(den);&lt;br /&gt;
    shl64(qbit);&lt;br /&gt;
  } &lt;br /&gt;
 &lt;br /&gt;
  while(!eq64(qbit,zero64)){&lt;br /&gt;
    if(lt64(den,num) || eq64(den,num)){&lt;br /&gt;
      sub64(num,den);&lt;br /&gt;
      add64(quot,qbit);&lt;br /&gt;
    }&lt;br /&gt;
    shr64(den);&lt;br /&gt;
    shr64(qbit);&lt;br /&gt;
  }&lt;br /&gt;
 &lt;br /&gt;
  //remainder now in num, but using it to return quotient for now  &lt;br /&gt;
  init64(num,quot[0],quot[1]); &lt;br /&gt;
}&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
//multiply num by den&lt;br /&gt;
void mul64(unsigned long an[], unsigned long ann[]){&lt;br /&gt;
  unsigned long p[2] = {0,0};&lt;br /&gt;
  unsigned long y[2] = {ann[0], ann[1]};&lt;br /&gt;
  while(!eq64(y,zero64)) {&lt;br /&gt;
    if(y[1] &amp;amp; 1) &lt;br /&gt;
      add64(p,an);&lt;br /&gt;
    shl64(an);&lt;br /&gt;
    shr64(y);&lt;br /&gt;
  }&lt;br /&gt;
  init64(an,p[0],p[1]);&lt;br /&gt;
} &lt;br /&gt;
  &lt;br /&gt;
void save(){&lt;br /&gt;
  EEPROM.write(0,guinosig);&lt;br /&gt;
  byte p = 0;&lt;br /&gt;
  for(int x=4; p &amp;lt; parmsLength; x+= 4){&lt;br /&gt;
    unsigned long v = parms[p];&lt;br /&gt;
    EEPROM.write(x ,(v&amp;gt;&amp;gt;24)&amp;amp;255);&lt;br /&gt;
    EEPROM.write(x + 1,(v&amp;gt;&amp;gt;16)&amp;amp;255);&lt;br /&gt;
    EEPROM.write(x + 2,(v&amp;gt;&amp;gt;8)&amp;amp;255);&lt;br /&gt;
    EEPROM.write(x + 3,(v)&amp;amp;255);&lt;br /&gt;
    p++;&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
byte load(){ //return 1 if loaded ok&lt;br /&gt;
  byte b = EEPROM.read(0);&lt;br /&gt;
  if(b == guinosig){&lt;br /&gt;
    byte p = 0;&lt;br /&gt;
&lt;br /&gt;
    for(int x=4; p &amp;lt; parmsLength; x+= 4){&lt;br /&gt;
      unsigned long v = EEPROM.read(x);&lt;br /&gt;
      v = (v &amp;lt;&amp;lt; 8) + EEPROM.read(x+1);&lt;br /&gt;
      v = (v &amp;lt;&amp;lt; 8) + EEPROM.read(x+2);&lt;br /&gt;
      v = (v &amp;lt;&amp;lt; 8) + EEPROM.read(x+3);&lt;br /&gt;
      parms[p]=v;&lt;br /&gt;
      p++;&lt;br /&gt;
    }&lt;br /&gt;
    return 1;&lt;br /&gt;
  }&lt;br /&gt;
  return 0;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
char * uformat(unsigned long val){ &lt;br /&gt;
  unsigned long d = 1000000000ul;&lt;br /&gt;
  for(byte p = 0; p &amp;lt; 10 ; p++){&lt;br /&gt;
    mBuff[p]='0' + (val/d);&lt;br /&gt;
    val=val-(val/d*d);&lt;br /&gt;
    d/=10;&lt;br /&gt;
  }&lt;br /&gt;
  mBuff[10]=0;&lt;br /&gt;
  return mBuff;&lt;br /&gt;
} &lt;br /&gt;
&lt;br /&gt;
unsigned long rformat(char * val){ &lt;br /&gt;
  unsigned long d = 1000000000ul;&lt;br /&gt;
  unsigned long v = 0ul;&lt;br /&gt;
  for(byte p = 0; p &amp;lt; 10 ; p++){&lt;br /&gt;
    v=v+(d*(val[p]-'0'));&lt;br /&gt;
    d/=10;&lt;br /&gt;
  }&lt;br /&gt;
  return v;&lt;br /&gt;
} &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
void editParm(byte parmIdx){&lt;br /&gt;
  unsigned long v = parms[parmIdx];&lt;br /&gt;
  byte p=9;  //right end of 10 digit number&lt;br /&gt;
  //display label on top line&lt;br /&gt;
  //set cursor visible&lt;br /&gt;
  //set pos = 0&lt;br /&gt;
  //display v&lt;br /&gt;
&lt;br /&gt;
    LCD::gotoXY(8,0);        &lt;br /&gt;
    LCD::print(&amp;quot;        &amp;quot;);&lt;br /&gt;
    LCD::gotoXY(0,0);        &lt;br /&gt;
    LCD::print(parmLabels[parmIdx]);&lt;br /&gt;
    LCD::gotoXY(0,1);    &lt;br /&gt;
    char * fmtv=    uformat(v);&lt;br /&gt;
    LCD::print(fmtv);&lt;br /&gt;
    LCD::print(&amp;quot; OK XX&amp;quot;);&lt;br /&gt;
    LCD::LcdCommandWrite(B00001110);&lt;br /&gt;
&lt;br /&gt;
    for(int x=9 ; x&amp;gt;=0 ;x--){ //do a nice thing and put the cursor at the first non zero number&lt;br /&gt;
      if(fmtv[x] != '0')&lt;br /&gt;
         p=x; &lt;br /&gt;
    }&lt;br /&gt;
  byte keyLock=1;    &lt;br /&gt;
  while(true){&lt;br /&gt;
&lt;br /&gt;
    if(p&amp;lt;10)&lt;br /&gt;
      LCD::gotoXY(p,1);   &lt;br /&gt;
    if(p==10)     &lt;br /&gt;
      LCD::gotoXY(11,1);   &lt;br /&gt;
    if(p==11)     &lt;br /&gt;
      LCD::gotoXY(14,1);   &lt;br /&gt;
&lt;br /&gt;
     if(keyLock == 0){ &lt;br /&gt;
       if(!(buttonState&amp;amp;lbuttonBit)){// left&lt;br /&gt;
            p=p-1;&lt;br /&gt;
            if(p==255)p=11;&lt;br /&gt;
        }else if(!(buttonState&amp;amp;rbuttonBit)){// right&lt;br /&gt;
             p=p+1;&lt;br /&gt;
            if(p==12)p=0;&lt;br /&gt;
        }else if(!(buttonState&amp;amp;mbuttonBit)){// middle&lt;br /&gt;
             if(p==11){  //cancel selected&lt;br /&gt;
                LCD::LcdCommandWrite(B00001100);&lt;br /&gt;
                return;&lt;br /&gt;
             }&lt;br /&gt;
             if(p==10){  //ok selected&lt;br /&gt;
                LCD::LcdCommandWrite(B00001100);&lt;br /&gt;
                parms[parmIdx]=rformat(fmtv);&lt;br /&gt;
                return;&lt;br /&gt;
             }&lt;br /&gt;
             &lt;br /&gt;
             byte n = fmtv[p]-'0';&lt;br /&gt;
             n++;&lt;br /&gt;
             if (n &amp;gt; 9) n=0;&lt;br /&gt;
             if(p==0 &amp;amp;&amp;amp; n &amp;gt; 3) n=0;&lt;br /&gt;
             fmtv[p]='0'+ n;&lt;br /&gt;
             LCD::gotoXY(0,1);        &lt;br /&gt;
             LCD::print(fmtv);&lt;br /&gt;
             LCD::gotoXY(p,1);        &lt;br /&gt;
             if(parmIdx==contrastIdx)//adjust contrast dynamically&lt;br /&gt;
                 analogWrite(ContrastPin,rformat(fmtv));  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
      if(buttonState!=buttonsUp)&lt;br /&gt;
         keyLock=1;&lt;br /&gt;
     }else{&lt;br /&gt;
        keyLock=0;&lt;br /&gt;
     }&lt;br /&gt;
      buttonState=buttonsUp;&lt;br /&gt;
      delay2(125);&lt;br /&gt;
  }      &lt;br /&gt;
  &lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
void initGuino(){ //edit all the parameters&lt;br /&gt;
  for(int x = 0;x&amp;lt;parmsLength;x++)&lt;br /&gt;
    editParm(x);&lt;br /&gt;
  save();&lt;br /&gt;
  holdDisplay=1;&lt;br /&gt;
}  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
unsigned long millis2(){&lt;br /&gt;
	return timer2_overflow_count * 64UL * 2 / (16000000UL / 128000UL);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
void delay2(unsigned long ms){&lt;br /&gt;
	unsigned long start = millis2();&lt;br /&gt;
	while (millis2() - start &amp;lt; ms);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
/* Delay for the given number of microseconds.  Assumes a 16 MHz clock. &lt;br /&gt;
 * Disables interrupts, which will disrupt the millis2() function if used&lt;br /&gt;
 * too frequently. */&lt;br /&gt;
void delayMicroseconds2(unsigned int us){&lt;br /&gt;
	uint8_t oldSREG;&lt;br /&gt;
	if (--us == 0)	return;&lt;br /&gt;
	us &amp;lt;&amp;lt;= 2;&lt;br /&gt;
	us -= 2;&lt;br /&gt;
	oldSREG = SREG;&lt;br /&gt;
	cli();&lt;br /&gt;
	// busy wait&lt;br /&gt;
	__asm__ __volatile__ (&lt;br /&gt;
		&amp;quot;1: sbiw %0,1&amp;quot; &amp;quot;\n\t&amp;quot; // 2 cycles&lt;br /&gt;
		&amp;quot;brne 1b&amp;quot; : &amp;quot;=w&amp;quot; (us) : &amp;quot;0&amp;quot; (us) // 2 cycles&lt;br /&gt;
	);&lt;br /&gt;
	// reenable interrupts.&lt;br /&gt;
	SREG = oldSREG;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
void init2(){&lt;br /&gt;
	// this needs to be called before setup() or some functions won't&lt;br /&gt;
	// work there&lt;br /&gt;
	sei();&lt;br /&gt;
	&lt;br /&gt;
	// timer 0 is used for millis2() and delay2()&lt;br /&gt;
	timer2_overflow_count = 0;&lt;br /&gt;
	// on the ATmega168, timer 0 is also used for fast hardware pwm&lt;br /&gt;
	// (using phase-correct PWM would mean that timer 0 overflowed half as often&lt;br /&gt;
	// resulting in different millis2() behavior on the ATmega8 and ATmega168)&lt;br /&gt;
        TCCR2A=1&amp;lt;&amp;lt;WGM20|1&amp;lt;&amp;lt;WGM21;&lt;br /&gt;
	// set timer 2 prescale factor to 64&lt;br /&gt;
        TCCR2B=1&amp;lt;&amp;lt;CS22;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
//      TCCR2A=TCCR0A;&lt;br /&gt;
//      TCCR2B=TCCR0B;&lt;br /&gt;
	// enable timer 2 overflow interrupt&lt;br /&gt;
	TIMSK2|=1&amp;lt;&amp;lt;TOIE2;&lt;br /&gt;
	// disable timer 0 overflow interrupt&lt;br /&gt;
	TIMSK0&amp;amp;=!(1&amp;lt;&amp;lt;TOIE0);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
{{default}}&lt;/div&gt;</summary>
		<author><name>Combustor</name></author>	</entry>

	<entry>
		<id>http://combustory.com/wiki/index.php/Temperature_Controller</id>
		<title>Temperature Controller</title>
		<link rel="alternate" type="text/html" href="http://combustory.com/wiki/index.php/Temperature_Controller"/>
				<updated>2008-09-09T13:14:05Z</updated>
		
		<summary type="html">&lt;p&gt;Combustor: /* X9241A - Digital Potentiometer */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{default}}&lt;br /&gt;
== Warning ==&lt;br /&gt;
'''This page is in progress and none of the code can be considered good or complete. I am just using this as an alternate storage of the code for right now.'''&lt;br /&gt;
&lt;br /&gt;
== Summary ==&lt;br /&gt;
== Functional Description of the Method ==&lt;br /&gt;
== Requirements ==&lt;br /&gt;
== Example of Method ==&lt;br /&gt;
=== Quick Guide: ===&lt;br /&gt;
=== Detailed Guide: ===&lt;br /&gt;
=== I2C ===&lt;br /&gt;
==== X9241A - Digital Potentiometer ====&lt;br /&gt;
&lt;br /&gt;
There are basically only two functions that I am after right now which are both three byte instructions:&lt;br /&gt;
&lt;br /&gt;
* Read WCR(Wiper Control Register) for the four potentiometers 0-3 &lt;br /&gt;
** Send 1st byte - Address (binary - 1010 A0 A1 A2 A3) A values are actual pins set to high or low for an address.&lt;br /&gt;
** Send 2nd byte - Instruction (binary - 1001 (1/0)(1/0) 00) - The two bits are used to choose the potentiometer&lt;br /&gt;
** Read WCR requested Byte&lt;br /&gt;
* Write WCR for the four potentiometers 0-3&lt;br /&gt;
** Send 1st byte - Address (binary - 1010 A0 A1 A2 A3) A values are actual pins set to high or low for an address.&lt;br /&gt;
** Send 2nd byte - Instruction (binary - 1010 (1/0)(1/0) 00) - The two bits are used to choose the potentiometer&lt;br /&gt;
** Send WCR Byte - Potentiometer value (binary - 00 D5 D4 D3 D2 D1 D0) - D values are the 0-63 potentiometer positions&lt;br /&gt;
&lt;br /&gt;
==== DS1307 - Real Time Clock ====&lt;br /&gt;
&lt;br /&gt;
The code for this very useful chip came from the [[http://www.glacialwanderer.com/hobbyrobotics/?p=12 Glacial Wanderer]]&lt;br /&gt;
&lt;br /&gt;
==== A/C_Control_v.01 code ====&lt;br /&gt;
&lt;br /&gt;
''' While this says v.01, don't count on it being a released v.01, I am still working on v.01, this is a back up '''&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
/*&lt;br /&gt;
 * A/C Control v.01&lt;br /&gt;
 * by &amp;lt;http://www.combustory.com&amp;gt; John Vaughters&lt;br /&gt;
 * Credit to:&lt;br /&gt;
 * Maurice Ribble - http://www.glacialwanderer.com/hobbyrobotics for RTC DS1307 code&lt;br /&gt;
 *&lt;br /&gt;
 * Turns on an LED for temperatures from analog pins 1-5 on&lt;br /&gt;
 * digital pins 2-6 when the temperature rises above the THRESHOLDS 1-5.&lt;br /&gt;
 * The program also implements a &lt;br /&gt;
 * Serial Communication method that utilizes a leading CHAR for each command Described below. &lt;br /&gt;
 * Commands:&lt;br /&gt;
 * T(1-4) - Temp1-5 Status ex. T1, T2, etc&lt;br /&gt;
 * C(1-4)(0-9) - Increment THRESHOLD1-4 by (1-9) ex. C15 increments THRESHOLD1 BY 5 (Note: C40 will give you a status of THRESHOLD4)&lt;br /&gt;
 * D(1-4)(0-9) - Decrement THRESHOLD1-4 by (1-9) ex. D59 decrements THRESHOLD5 BY 9 (Note: D10 will give you a status of THRESHOLD1)&lt;br /&gt;
 * A(0-1) - Manual AC on command A1 is AC on, A0 is AC off&lt;br /&gt;
 * F(0-1) - Manual AC on command A1 is FAN on, A0 is FAN off &lt;br /&gt;
 * Q - Q Sets the date of the RTC DS1307 Chip&lt;br /&gt;
 */&lt;br /&gt;
&lt;br /&gt;
#include &amp;quot;Wire.h&amp;quot;&lt;br /&gt;
#define DS1307_I2C_ADDRESS 0x68&lt;br /&gt;
&lt;br /&gt;
// Global Variables&lt;br /&gt;
int val_cnt = 0;               // counter for the temp_val                   &lt;br /&gt;
int temp1Pin = 0;    // select the input pin for the Thermistor&lt;br /&gt;
int temp2Pin = 1;    // select the input pin for the Thermistor&lt;br /&gt;
int temp3Pin = 2;    // select the input pin for the Thermistor&lt;br /&gt;
int temp4Pin = 3;    // select the input pin for the Thermistor&lt;br /&gt;
int temp1_val[5] = {0,0,0,0,0};       // variable to store the value coming from the sensor&lt;br /&gt;
int temp2_val[5] = {0,0,0,0,0};       //           &lt;br /&gt;
int temp3_val[5] = {0,0,0,0,0};       //&lt;br /&gt;
int temp4_val[5] = {0,0,0,0,0};       //&lt;br /&gt;
int temp1_avg;                   // average over poll time of the temp values&lt;br /&gt;
int temp2_avg;&lt;br /&gt;
int temp3_avg;&lt;br /&gt;
int temp4_avg;&lt;br /&gt;
int duct1 = 2;                   // Ducts open or close using a digital output&lt;br /&gt;
int duct2 = 3;&lt;br /&gt;
int duct3 = 4;&lt;br /&gt;
int duct4 = 5;&lt;br /&gt;
int THRESHOLD1 = 580;    // Default theshold values&lt;br /&gt;
int THRESHOLD2 = 580;&lt;br /&gt;
int THRESHOLD3 = 580;&lt;br /&gt;
int THRESHOLD4 = 580;&lt;br /&gt;
int ac_on = 13;&lt;br /&gt;
int fan_on = 12;&lt;br /&gt;
int command = 0;       // This is the command char, in ascii form, sent from the serial port     &lt;br /&gt;
long polltime = 1000;  // The time to Poll the tempPins&lt;br /&gt;
long previousMillis = 0;        // will store last time Temp was updated&lt;br /&gt;
long ac_on_start = 0;     // Start A/C delay timer&lt;br /&gt;
long ac_on_delay = 10000;   // Time to wait before checking the ducts again&lt;br /&gt;
byte second, minute, hour, dayOfWeek, dayOfMonth, month, year;&lt;br /&gt;
&lt;br /&gt;
  &lt;br /&gt;
// Convert normal decimal numbers to binary coded decimal&lt;br /&gt;
byte decToBcd(byte val)&lt;br /&gt;
{&lt;br /&gt;
  return ( (val/10*16) + (val%10) );&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
// Convert binary coded decimal to normal decimal numbers&lt;br /&gt;
byte bcdToDec(byte val)&lt;br /&gt;
{&lt;br /&gt;
  return ( (val/16*10) + (val%16) );&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
// 1) Sets the date and time on the ds1307&lt;br /&gt;
// 2) Starts the clock&lt;br /&gt;
// 3) Sets hour mode to 24 hour clock&lt;br /&gt;
// Assumes you're passing in valid numbers&lt;br /&gt;
// Watch for scope issues with Global Variables&lt;br /&gt;
/*void setDateDs1307(byte second,        // 0-59&lt;br /&gt;
                   byte minute,        // 0-59&lt;br /&gt;
                   byte hour,          // 1-23&lt;br /&gt;
                   byte dayOfWeek,     // 1-7&lt;br /&gt;
                   byte dayOfMonth,    // 1-28/29/30/31&lt;br /&gt;
                   byte month,         // 1-12&lt;br /&gt;
                   byte year)          // 0-99*/&lt;br /&gt;
void setDateDs1307()                &lt;br /&gt;
{&lt;br /&gt;
   Wire.beginTransmission(DS1307_I2C_ADDRESS);&lt;br /&gt;
   Wire.send(0);&lt;br /&gt;
   Wire.send(decToBcd(second));    // 0 to bit 7 starts the clock&lt;br /&gt;
   Wire.send(decToBcd(minute));&lt;br /&gt;
   Wire.send(decToBcd(hour));      // If you want 12 hour am/pm you need to set&lt;br /&gt;
                                   // bit 6 (also need to change readDateDs1307)&lt;br /&gt;
   Wire.send(decToBcd(dayOfWeek));&lt;br /&gt;
   Wire.send(decToBcd(dayOfMonth));&lt;br /&gt;
   Wire.send(decToBcd(month));&lt;br /&gt;
   Wire.send(decToBcd(year));&lt;br /&gt;
   Wire.endTransmission();&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
// Gets the date and time from the ds1307 and prints result&lt;br /&gt;
// Watch for scope issues with Global Variables&lt;br /&gt;
void getDateDs1307()&lt;br /&gt;
{&lt;br /&gt;
  // Reset the register pointer&lt;br /&gt;
  Wire.beginTransmission(DS1307_I2C_ADDRESS);&lt;br /&gt;
  Wire.send(0);&lt;br /&gt;
  Wire.endTransmission();&lt;br /&gt;
&lt;br /&gt;
  Wire.requestFrom(DS1307_I2C_ADDRESS, 7);&lt;br /&gt;
&lt;br /&gt;
  // A few of these need masks because certain bits are control bits&lt;br /&gt;
  second     = bcdToDec(Wire.receive() &amp;amp; 0x7f);&lt;br /&gt;
  minute     = bcdToDec(Wire.receive());&lt;br /&gt;
  hour       = bcdToDec(Wire.receive() &amp;amp; 0x3f);  // Need to change this if 12 hour am/pm&lt;br /&gt;
  dayOfWeek  = bcdToDec(Wire.receive());&lt;br /&gt;
  dayOfMonth = bcdToDec(Wire.receive());&lt;br /&gt;
  month      = bcdToDec(Wire.receive());&lt;br /&gt;
  year       = bcdToDec(Wire.receive());&lt;br /&gt;
  &lt;br /&gt;
  Serial.print(hour, DEC);&lt;br /&gt;
  Serial.print(&amp;quot;:&amp;quot;);&lt;br /&gt;
  Serial.print(minute, DEC);&lt;br /&gt;
  Serial.print(&amp;quot;:&amp;quot;);&lt;br /&gt;
  Serial.print(second, DEC);&lt;br /&gt;
  Serial.print(&amp;quot;  &amp;quot;);&lt;br /&gt;
  Serial.print(month, DEC);&lt;br /&gt;
  Serial.print(&amp;quot;/&amp;quot;);&lt;br /&gt;
  Serial.print(dayOfMonth, DEC);&lt;br /&gt;
  Serial.print(&amp;quot;/&amp;quot;);&lt;br /&gt;
  Serial.print(year, DEC);&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
void setup() {&lt;br /&gt;
  Wire.begin();&lt;br /&gt;
  Serial.begin(57600);&lt;br /&gt;
  pinMode(duct1, OUTPUT);&lt;br /&gt;
  pinMode(duct2, OUTPUT);&lt;br /&gt;
  pinMode(duct3, OUTPUT);&lt;br /&gt;
  pinMode(duct4, OUTPUT);&lt;br /&gt;
  pinMode(ac_on, OUTPUT);&lt;br /&gt;
  pinMode(fan_on, OUTPUT);&lt;br /&gt;
  // Initialize Date/Time to update RTC DS1307 - You need to run the Q command right after you download this program&lt;br /&gt;
  // This is temporary until a more complex date time command is finished&lt;br /&gt;
  second = 15;&lt;br /&gt;
  minute = 41;&lt;br /&gt;
  hour = 12;&lt;br /&gt;
  dayOfWeek = 5;&lt;br /&gt;
  dayOfMonth = 5;&lt;br /&gt;
  month = 9;&lt;br /&gt;
  year = 8;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
void loop() {&lt;br /&gt;
  if (millis() - previousMillis &amp;gt; polltime) {&lt;br /&gt;
    previousMillis = millis();   // remember the last time&lt;br /&gt;
    if (millis() - ac_on_start &amp;gt; ac_on_delay) { &lt;br /&gt;
      if (digitalRead(duct1) || digitalRead(duct2) || digitalRead(duct3) || digitalRead(duct4)){  // If any ducts are turned on turn on the A/C&lt;br /&gt;
       if (digitalRead(ac_on) != HIGH) { // Check ac_on state&lt;br /&gt;
        digitalWrite(ac_on,HIGH);&lt;br /&gt;
        getDateDs1307();&lt;br /&gt;
        Serial.println(&amp;quot; - AC ON&amp;quot;);&lt;br /&gt;
       }&lt;br /&gt;
       ac_on_start = millis();&lt;br /&gt;
      } &lt;br /&gt;
      else if (digitalRead(ac_on) != LOW){ //Check ac_on state&lt;br /&gt;
       digitalWrite(ac_on,LOW);&lt;br /&gt;
       getDateDs1307();&lt;br /&gt;
       Serial.println(&amp;quot; - AC OFF&amp;quot;);&lt;br /&gt;
      }&lt;br /&gt;
    }&lt;br /&gt;
    temp1_val[val_cnt] = analogRead(temp1Pin);    // read the value from the sensors&lt;br /&gt;
    temp2_val[val_cnt] = analogRead(temp2Pin);&lt;br /&gt;
    temp3_val[val_cnt] = analogRead(temp3Pin);&lt;br /&gt;
    temp4_val[val_cnt] = analogRead(temp4Pin);&lt;br /&gt;
    val_cnt ++;&lt;br /&gt;
    if (val_cnt == 5) {&lt;br /&gt;
      val_cnt = 0;&lt;br /&gt;
    }&lt;br /&gt;
    temp1_avg = (temp1_val[0] + temp1_val[1] + temp1_val[2] + temp1_val[3] + temp1_val[4])/5;&lt;br /&gt;
    temp2_avg = (temp2_val[0] + temp2_val[1] + temp2_val[2] + temp2_val[3] + temp2_val[4])/5;&lt;br /&gt;
    temp3_avg = (temp3_val[0] + temp3_val[1] + temp3_val[2] + temp3_val[3] + temp3_val[4])/5;&lt;br /&gt;
    temp4_avg = (temp4_val[0] + temp4_val[1] + temp4_val[2] + temp4_val[3] + temp4_val[4])/5;&lt;br /&gt;
// Check Thresholds against the Temperatures and set the ducts HIGH or LOW    &lt;br /&gt;
    if (temp1_avg &amp;gt;= THRESHOLD1) {digitalWrite(duct1, HIGH);}&lt;br /&gt;
    else {digitalWrite(duct1, LOW);}&lt;br /&gt;
    if (temp2_avg &amp;gt;= THRESHOLD2) {digitalWrite(duct2, HIGH);}&lt;br /&gt;
    else {digitalWrite(duct2, LOW);}&lt;br /&gt;
    if (temp3_avg &amp;gt;= THRESHOLD3) {digitalWrite(duct3, HIGH);}&lt;br /&gt;
    else {digitalWrite(duct3, LOW);}&lt;br /&gt;
    if (temp4_avg &amp;gt;= THRESHOLD4) {digitalWrite(duct4, HIGH);}&lt;br /&gt;
    else {digitalWrite(duct4, LOW);}&lt;br /&gt;
    if (Serial.available()) {      // Look for char in serial que and process if found&lt;br /&gt;
      command = Serial.read();&lt;br /&gt;
      if (command == 84) {          // If command = &amp;quot;T&amp;quot; &lt;br /&gt;
        command = Serial.read();&lt;br /&gt;
        if (command == 49) {          // If command = &amp;quot;1&amp;quot; print the Temp1&lt;br /&gt;
         Serial.print(&amp;quot;Temp1 = &amp;quot;);&lt;br /&gt;
         Serial.print(temp1_avg);           // &lt;br /&gt;
         Serial.print(&amp;quot; &amp;quot;);&lt;br /&gt;
        }&lt;br /&gt;
        else if (command == 50) {      // If command = &amp;quot;2&amp;quot; print the Temp2&lt;br /&gt;
         Serial.print(&amp;quot;Temp2 = &amp;quot;);&lt;br /&gt;
         Serial.print(temp2_avg);           // &lt;br /&gt;
         Serial.print(&amp;quot; &amp;quot;);&lt;br /&gt;
        }&lt;br /&gt;
        else if (command == 51) {      // If command = &amp;quot;3&amp;quot; print the Temp3&lt;br /&gt;
         Serial.print(&amp;quot;Temp3 = &amp;quot;);&lt;br /&gt;
         Serial.print(temp3_avg);           // &lt;br /&gt;
         Serial.print(&amp;quot; &amp;quot;);&lt;br /&gt;
        }&lt;br /&gt;
        else if (command == 52) {      // If command = &amp;quot;4&amp;quot; print the Temp4&lt;br /&gt;
         Serial.print(&amp;quot;Temp4 = &amp;quot;);&lt;br /&gt;
         Serial.print(temp4_avg);           // &lt;br /&gt;
         Serial.print(&amp;quot; &amp;quot;);&lt;br /&gt;
         }&lt;br /&gt;
       }&lt;br /&gt;
      else if (command == 67) {      //If command = &amp;quot;C&amp;quot; Change Temp Threshhold&lt;br /&gt;
        if (Serial.available()) {&lt;br /&gt;
         command = Serial.read();&lt;br /&gt;
         if (command == 49) {        // If command = &amp;quot;1&amp;quot; print the THRESHOLD1&lt;br /&gt;
           command = Serial.read();&lt;br /&gt;
           if (command &amp;gt; 47 &amp;amp;&amp;amp; command &amp;lt; 58) {          // If command is between 0-9 Increment the Threshold by number sent&lt;br /&gt;
             THRESHOLD1 += command - 48;                 // ASCII math to get value sent   &lt;br /&gt;
                  Serial.print(&amp;quot;THRESHOLD1 = &amp;quot;);&lt;br /&gt;
                  Serial.print(THRESHOLD1);           // &lt;br /&gt;
                  Serial.print(&amp;quot; &amp;quot;);&lt;br /&gt;
           }&lt;br /&gt;
         }  &lt;br /&gt;
         else if (command == 50) {     // If command = &amp;quot;2&amp;quot; print the THRESHOLD2&lt;br /&gt;
           command = Serial.read();&lt;br /&gt;
           if (command &amp;gt; 47 &amp;amp;&amp;amp; command &amp;lt; 58) {          // If command is between 0-9 Increment the Threshold by number sent&lt;br /&gt;
             THRESHOLD2 += command - 48;                 // ASCII math to get value sent   &lt;br /&gt;
                  Serial.print(&amp;quot;THRESHOLD2 = &amp;quot;);&lt;br /&gt;
                  Serial.print(THRESHOLD2);           // &lt;br /&gt;
                  Serial.print(&amp;quot; &amp;quot;);&lt;br /&gt;
           }&lt;br /&gt;
         }&lt;br /&gt;
         else if (command == 51) {             // If command = &amp;quot;3&amp;quot; print the THRESHOLD3&lt;br /&gt;
           command = Serial.read();&lt;br /&gt;
           if (command &amp;gt; 47 &amp;amp;&amp;amp; command &amp;lt; 58) {          // If command is between 0-9 Increment the Threshold by number sent&lt;br /&gt;
             THRESHOLD3 += command - 48;                 // ASCII math to get value sent   &lt;br /&gt;
                  Serial.print(&amp;quot;THRESHOLD3 = &amp;quot;);&lt;br /&gt;
                  Serial.print(THRESHOLD3);           // &lt;br /&gt;
                  Serial.print(&amp;quot; &amp;quot;);&lt;br /&gt;
           }&lt;br /&gt;
         }&lt;br /&gt;
         else if (command == 52) {             // If command = &amp;quot;4&amp;quot; print the THRESHOLD4&lt;br /&gt;
           command = Serial.read();&lt;br /&gt;
           if (command &amp;gt; 47 &amp;amp;&amp;amp; command &amp;lt; 58) {          // If command is between 0-9 Increment the Threshold by number sent&lt;br /&gt;
             THRESHOLD4 += command - 48;                 // ASCII math to get value sent   &lt;br /&gt;
                  Serial.print(&amp;quot;THRESHOLD4 = &amp;quot;);&lt;br /&gt;
                  Serial.print(THRESHOLD4);           // &lt;br /&gt;
                  Serial.print(&amp;quot; &amp;quot;);&lt;br /&gt;
           }&lt;br /&gt;
         }          &lt;br /&gt;
        }  &lt;br /&gt;
      }&lt;br /&gt;
      else if (command == 68) {      //If command = &amp;quot;D&amp;quot; Change Temp Threshhold&lt;br /&gt;
        if (Serial.available()) {&lt;br /&gt;
         command = Serial.read();&lt;br /&gt;
         if (command == 49) {           // If command = &amp;quot;1&amp;quot; print the THRESHOLD1&lt;br /&gt;
           command = Serial.read();&lt;br /&gt;
           if (command &amp;gt; 47 &amp;amp;&amp;amp; command &amp;lt; 58) {          // If command is between 0-9 Decrement the Threshold by number sent&lt;br /&gt;
             THRESHOLD1 -= command - 48;                 // ASCII math to get value sent   &lt;br /&gt;
                  Serial.print(&amp;quot;THRESHOLD1 = &amp;quot;);&lt;br /&gt;
                  Serial.print(THRESHOLD1);           // &lt;br /&gt;
                  Serial.print(&amp;quot; &amp;quot;);&lt;br /&gt;
           }&lt;br /&gt;
         }  &lt;br /&gt;
         else if (command == 50) {               // If command = &amp;quot;2&amp;quot; print the THRESHOLD2&lt;br /&gt;
           command = Serial.read();&lt;br /&gt;
           if (command &amp;gt; 47 &amp;amp;&amp;amp; command &amp;lt; 58) {          // If command is between 0-9 Decrement the Threshold by number sent&lt;br /&gt;
             THRESHOLD2 -= command - 48;                 // ASCII math to get value sent   &lt;br /&gt;
                  Serial.print(&amp;quot;THRESHOLD2 = &amp;quot;);&lt;br /&gt;
                  Serial.print(THRESHOLD2);           // &lt;br /&gt;
                  Serial.print(&amp;quot; &amp;quot;);&lt;br /&gt;
           }&lt;br /&gt;
         }&lt;br /&gt;
         else if (command == 51) {              // If command = &amp;quot;3&amp;quot; print the THRESHOLD3&lt;br /&gt;
           command = Serial.read();&lt;br /&gt;
           if (command &amp;gt; 47 &amp;amp;&amp;amp; command &amp;lt; 58) {          // If command is between 0-9 Decrement the Threshold by number sent&lt;br /&gt;
             THRESHOLD3 -= command - 48;                 // ASCII math to get value sent   &lt;br /&gt;
                  Serial.print(&amp;quot;THRESHOLD3 = &amp;quot;);&lt;br /&gt;
                  Serial.print(THRESHOLD3);           // &lt;br /&gt;
                  Serial.print(&amp;quot; &amp;quot;);&lt;br /&gt;
           }&lt;br /&gt;
         }&lt;br /&gt;
         else if (command == 52) {                    // If command = &amp;quot;4&amp;quot; print the THRESHOLD4&lt;br /&gt;
           command = Serial.read();&lt;br /&gt;
           if (command &amp;gt; 47 &amp;amp;&amp;amp; command &amp;lt; 58) {          // If command is between 0-9 Decrement the Threshold by number sent&lt;br /&gt;
             THRESHOLD4 -= command - 48;                 // ASCII math to get value sent   &lt;br /&gt;
                  Serial.print(&amp;quot;THRESHOLD4 = &amp;quot;);&lt;br /&gt;
                  Serial.print(THRESHOLD4);           // &lt;br /&gt;
                  Serial.print(&amp;quot; &amp;quot;);&lt;br /&gt;
           }&lt;br /&gt;
         }           &lt;br /&gt;
        }  &lt;br /&gt;
      }&lt;br /&gt;
//****************  Warning - This is a potential for problem - Consider a manual lock out feature to lock out manual commands &lt;br /&gt;
//****************  Possibly create a command to open up manual commands for a certian time period then shut them off again automatically&lt;br /&gt;
      else if (command == 65) {      //If command = &amp;quot;A&amp;quot; Change Temp Threshhold&lt;br /&gt;
       if (Serial.available()) {&lt;br /&gt;
        command = Serial.read();&lt;br /&gt;
        if (command == 49) {        // If command = &amp;quot;1&amp;quot; print the AC ON message&lt;br /&gt;
         getDateDs1307();&lt;br /&gt;
         Serial.print(&amp;quot; - Manual AC ON &amp;quot;);&lt;br /&gt;
         ac_on_start = millis();   // Set the AC to a delay before it can be turned off again&lt;br /&gt;
         digitalWrite(ac_on,HIGH);&lt;br /&gt;
        }&lt;br /&gt;
        else if (command == 48) {        // If command = &amp;quot;0&amp;quot; print the AC OFF message&lt;br /&gt;
         getDateDs1307();&lt;br /&gt;
         Serial.print(&amp;quot; - Manual AC OFF &amp;quot;);&lt;br /&gt;
         digitalWrite(ac_on,LOW);&lt;br /&gt;
        }&lt;br /&gt;
       } &lt;br /&gt;
      } &lt;br /&gt;
      else if (command == 70) {      //If command = &amp;quot;F&amp;quot; Change Temp Threshhold&lt;br /&gt;
       if (Serial.available()) {&lt;br /&gt;
        command = Serial.read();&lt;br /&gt;
        if (command == 49) {        // If command = &amp;quot;1&amp;quot; print the FAN ON message&lt;br /&gt;
         getDateDs1307();&lt;br /&gt;
         Serial.print(&amp;quot; - Manual FAN ON &amp;quot;);&lt;br /&gt;
         ac_on_start = millis();&lt;br /&gt;
         digitalWrite(fan_on,HIGH);&lt;br /&gt;
        }&lt;br /&gt;
        else if (command == 48) {        // If command = &amp;quot;0&amp;quot; print the FAN OFF message&lt;br /&gt;
         getDateDs1307();&lt;br /&gt;
         Serial.print(&amp;quot; - Manual FAN OFF &amp;quot;);&lt;br /&gt;
         digitalWrite(fan_on,LOW);&lt;br /&gt;
        }&lt;br /&gt;
       } &lt;br /&gt;
      }&lt;br /&gt;
//********************** End of Warning Zone *******************************&lt;br /&gt;
&lt;br /&gt;
// ***************  This Section Will list the Staus of the Controller&lt;br /&gt;
      else if (command == 83) {      //If command = &amp;quot;S&amp;quot; Print Controller Status&lt;br /&gt;
        getDateDs1307();&lt;br /&gt;
        Serial.println(&amp;quot; &amp;quot;);&lt;br /&gt;
        Serial.println(&amp;quot; &amp;quot;);&lt;br /&gt;
        Serial.print(&amp;quot;Temp1 = &amp;quot;);&lt;br /&gt;
        Serial.println(temp1_avg);   &lt;br /&gt;
        Serial.print(&amp;quot;Temp2 = &amp;quot;);&lt;br /&gt;
        Serial.println(temp2_avg);&lt;br /&gt;
        Serial.print(&amp;quot;Temp3 = &amp;quot;);&lt;br /&gt;
        Serial.println(temp3_avg);   &lt;br /&gt;
        Serial.print(&amp;quot;Temp4 = &amp;quot;);&lt;br /&gt;
        Serial.println(temp4_avg);   &lt;br /&gt;
        Serial.println(&amp;quot; &amp;quot;);&lt;br /&gt;
        Serial.print(&amp;quot;THRESHOLD1 = &amp;quot;);&lt;br /&gt;
        Serial.println(THRESHOLD1);   &lt;br /&gt;
        Serial.print(&amp;quot;THRESHOLD2 = &amp;quot;);&lt;br /&gt;
        Serial.println(THRESHOLD2); &lt;br /&gt;
        Serial.print(&amp;quot;THRESHOLD3 = &amp;quot;);&lt;br /&gt;
        Serial.println(THRESHOLD3); &lt;br /&gt;
        Serial.print(&amp;quot;THRESHOLD4 = &amp;quot;);&lt;br /&gt;
        Serial.println(THRESHOLD4);&lt;br /&gt;
        Serial.println(&amp;quot; &amp;quot;);&lt;br /&gt;
        if (digitalRead(duct1) == HIGH) {Serial.println(&amp;quot;duct1 ON&amp;quot;);}&lt;br /&gt;
        else{Serial.println(&amp;quot;duct1 OFF&amp;quot;);}&lt;br /&gt;
        if (digitalRead(duct2) == HIGH) {Serial.println(&amp;quot;duct2 ON&amp;quot;);}&lt;br /&gt;
        else{Serial.println(&amp;quot;duct2 OFF&amp;quot;);}&lt;br /&gt;
        if (digitalRead(duct3) == HIGH) {Serial.println(&amp;quot;duct3 ON&amp;quot;);}&lt;br /&gt;
        else{Serial.println(&amp;quot;duct3 OFF&amp;quot;);}&lt;br /&gt;
        if (digitalRead(duct4) == HIGH) {Serial.println(&amp;quot;duct4 ON&amp;quot;);}&lt;br /&gt;
        else{Serial.println(&amp;quot;duct4 OFF&amp;quot;);}&lt;br /&gt;
        Serial.println(&amp;quot; &amp;quot;);&lt;br /&gt;
        if (digitalRead(fan_on) == HIGH) {Serial.println(&amp;quot;Fan ON&amp;quot;);}&lt;br /&gt;
        else{Serial.println(&amp;quot;Fan OFF&amp;quot;);}&lt;br /&gt;
        if (digitalRead(ac_on) == HIGH) {Serial.println(&amp;quot;AC  ON&amp;quot;);}&lt;br /&gt;
        else{Serial.println(&amp;quot;AC  OFF&amp;quot;);}&lt;br /&gt;
        Serial.print(&amp;quot;A/C Delay (millisec) = &amp;quot;);&lt;br /&gt;
        Serial.println(ac_on_delay);&lt;br /&gt;
        Serial.print(&amp;quot;Temp Polling (millisec) = &amp;quot;);&lt;br /&gt;
        Serial.println(polltime);          &lt;br /&gt;
        Serial.println(&amp;quot; &amp;quot;);&lt;br /&gt;
        &lt;br /&gt;
      }&lt;br /&gt;
      else if (command == 81) {      //If command = &amp;quot;Q&amp;quot; Set Date&lt;br /&gt;
       setDateDs1307();&lt;br /&gt;
       getDateDs1307();&lt;br /&gt;
       Serial.println(&amp;quot; &amp;quot;);&lt;br /&gt;
      }&lt;br /&gt;
      Serial.println(command);     // Echo command char found in serial que&lt;br /&gt;
      command = 0;                 // reset command &lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
//*****************************************************The End***********************&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== A/C_Control_v.01 User Guide ==&lt;br /&gt;
==== Commands ====&lt;br /&gt;
== Troubleshooting ==&lt;br /&gt;
=== Summary ===&lt;br /&gt;
When Troubleshooting a multi-functional issue, it is best practice to break down the issue into pieces and test each piece as a separate system.  However, we will first run through a quick test to see if we can find any obvious issues first.&lt;br /&gt;
=== Quick Test ===&lt;/div&gt;</summary>
		<author><name>Combustor</name></author>	</entry>

	<entry>
		<id>http://combustory.com/wiki/index.php/Temperature_Controller</id>
		<title>Temperature Controller</title>
		<link rel="alternate" type="text/html" href="http://combustory.com/wiki/index.php/Temperature_Controller"/>
				<updated>2008-09-09T00:58:24Z</updated>
		
		<summary type="html">&lt;p&gt;Combustor: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{default}}&lt;br /&gt;
== Warning ==&lt;br /&gt;
'''This page is in progress and none of the code can be considered good or complete. I am just using this as an alternate storage of the code for right now.'''&lt;br /&gt;
&lt;br /&gt;
== Summary ==&lt;br /&gt;
== Functional Description of the Method ==&lt;br /&gt;
== Requirements ==&lt;br /&gt;
== Example of Method ==&lt;br /&gt;
=== Quick Guide: ===&lt;br /&gt;
=== Detailed Guide: ===&lt;br /&gt;
=== I2C ===&lt;br /&gt;
==== X9241A - Digital Potentiometer ====&lt;br /&gt;
&lt;br /&gt;
There are basically only two functions that I am after right now which are both three byte instructions:&lt;br /&gt;
&lt;br /&gt;
* Read WCR(Wiper Control Register) for the four potentiometers 0-3 &lt;br /&gt;
** Send 1st byte - Address (binary - 1010 A0 A1 A2 A3) A values are actual pins set to high or low for an address.&lt;br /&gt;
** Send 2nd byte - Instruction (binary - 1001 (1/0)(1/0) 00) - The two bits are used to choose the potentiometer&lt;br /&gt;
** Read WCR requested Byte&lt;br /&gt;
* Write WCR for the four potentiometers 0-3&lt;br /&gt;
** Send 1st byte - Address (binary - 1010 A0 A1 A2 A3) A values are actual pins set to high or low for an address.&lt;br /&gt;
** Send 2nd byte - Instruction (binary - 1010 (1/0)(1/0) 00) - The two bits are used to choose the potentiometer&lt;br /&gt;
** Send WCR Byte - Potentiometer value (00 D5 D4 D3 D2 D1 D0) - D values are the 0-63 potentiometer positions&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== DS1307 - Real Time Clock ====&lt;br /&gt;
&lt;br /&gt;
The code for this very useful chip came from the [[http://www.glacialwanderer.com/hobbyrobotics/?p=12 Glacial Wanderer]]&lt;br /&gt;
&lt;br /&gt;
==== A/C_Control_v.01 code ====&lt;br /&gt;
&lt;br /&gt;
''' While this says v.01, don't count on it being a released v.01, I am still working on v.01, this is a back up '''&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
/*&lt;br /&gt;
 * A/C Control v.01&lt;br /&gt;
 * by &amp;lt;http://www.combustory.com&amp;gt; John Vaughters&lt;br /&gt;
 * Credit to:&lt;br /&gt;
 * Maurice Ribble - http://www.glacialwanderer.com/hobbyrobotics for RTC DS1307 code&lt;br /&gt;
 *&lt;br /&gt;
 * Turns on an LED for temperatures from analog pins 1-5 on&lt;br /&gt;
 * digital pins 2-6 when the temperature rises above the THRESHOLDS 1-5.&lt;br /&gt;
 * The program also implements a &lt;br /&gt;
 * Serial Communication method that utilizes a leading CHAR for each command Described below. &lt;br /&gt;
 * Commands:&lt;br /&gt;
 * T(1-4) - Temp1-5 Status ex. T1, T2, etc&lt;br /&gt;
 * C(1-4)(0-9) - Increment THRESHOLD1-4 by (1-9) ex. C15 increments THRESHOLD1 BY 5 (Note: C40 will give you a status of THRESHOLD4)&lt;br /&gt;
 * D(1-4)(0-9) - Decrement THRESHOLD1-4 by (1-9) ex. D59 decrements THRESHOLD5 BY 9 (Note: D10 will give you a status of THRESHOLD1)&lt;br /&gt;
 * A(0-1) - Manual AC on command A1 is AC on, A0 is AC off&lt;br /&gt;
 * F(0-1) - Manual AC on command A1 is FAN on, A0 is FAN off &lt;br /&gt;
 * Q - Q Sets the date of the RTC DS1307 Chip&lt;br /&gt;
 */&lt;br /&gt;
&lt;br /&gt;
#include &amp;quot;Wire.h&amp;quot;&lt;br /&gt;
#define DS1307_I2C_ADDRESS 0x68&lt;br /&gt;
&lt;br /&gt;
// Global Variables&lt;br /&gt;
int val_cnt = 0;               // counter for the temp_val                   &lt;br /&gt;
int temp1Pin = 0;    // select the input pin for the Thermistor&lt;br /&gt;
int temp2Pin = 1;    // select the input pin for the Thermistor&lt;br /&gt;
int temp3Pin = 2;    // select the input pin for the Thermistor&lt;br /&gt;
int temp4Pin = 3;    // select the input pin for the Thermistor&lt;br /&gt;
int temp1_val[5] = {0,0,0,0,0};       // variable to store the value coming from the sensor&lt;br /&gt;
int temp2_val[5] = {0,0,0,0,0};       //           &lt;br /&gt;
int temp3_val[5] = {0,0,0,0,0};       //&lt;br /&gt;
int temp4_val[5] = {0,0,0,0,0};       //&lt;br /&gt;
int temp1_avg;                   // average over poll time of the temp values&lt;br /&gt;
int temp2_avg;&lt;br /&gt;
int temp3_avg;&lt;br /&gt;
int temp4_avg;&lt;br /&gt;
int duct1 = 2;                   // Ducts open or close using a digital output&lt;br /&gt;
int duct2 = 3;&lt;br /&gt;
int duct3 = 4;&lt;br /&gt;
int duct4 = 5;&lt;br /&gt;
int THRESHOLD1 = 580;    // Default theshold values&lt;br /&gt;
int THRESHOLD2 = 580;&lt;br /&gt;
int THRESHOLD3 = 580;&lt;br /&gt;
int THRESHOLD4 = 580;&lt;br /&gt;
int ac_on = 13;&lt;br /&gt;
int fan_on = 12;&lt;br /&gt;
int command = 0;       // This is the command char, in ascii form, sent from the serial port     &lt;br /&gt;
long polltime = 1000;  // The time to Poll the tempPins&lt;br /&gt;
long previousMillis = 0;        // will store last time Temp was updated&lt;br /&gt;
long ac_on_start = 0;     // Start A/C delay timer&lt;br /&gt;
long ac_on_delay = 10000;   // Time to wait before checking the ducts again&lt;br /&gt;
byte second, minute, hour, dayOfWeek, dayOfMonth, month, year;&lt;br /&gt;
&lt;br /&gt;
  &lt;br /&gt;
// Convert normal decimal numbers to binary coded decimal&lt;br /&gt;
byte decToBcd(byte val)&lt;br /&gt;
{&lt;br /&gt;
  return ( (val/10*16) + (val%10) );&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
// Convert binary coded decimal to normal decimal numbers&lt;br /&gt;
byte bcdToDec(byte val)&lt;br /&gt;
{&lt;br /&gt;
  return ( (val/16*10) + (val%16) );&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
// 1) Sets the date and time on the ds1307&lt;br /&gt;
// 2) Starts the clock&lt;br /&gt;
// 3) Sets hour mode to 24 hour clock&lt;br /&gt;
// Assumes you're passing in valid numbers&lt;br /&gt;
// Watch for scope issues with Global Variables&lt;br /&gt;
/*void setDateDs1307(byte second,        // 0-59&lt;br /&gt;
                   byte minute,        // 0-59&lt;br /&gt;
                   byte hour,          // 1-23&lt;br /&gt;
                   byte dayOfWeek,     // 1-7&lt;br /&gt;
                   byte dayOfMonth,    // 1-28/29/30/31&lt;br /&gt;
                   byte month,         // 1-12&lt;br /&gt;
                   byte year)          // 0-99*/&lt;br /&gt;
void setDateDs1307()                &lt;br /&gt;
{&lt;br /&gt;
   Wire.beginTransmission(DS1307_I2C_ADDRESS);&lt;br /&gt;
   Wire.send(0);&lt;br /&gt;
   Wire.send(decToBcd(second));    // 0 to bit 7 starts the clock&lt;br /&gt;
   Wire.send(decToBcd(minute));&lt;br /&gt;
   Wire.send(decToBcd(hour));      // If you want 12 hour am/pm you need to set&lt;br /&gt;
                                   // bit 6 (also need to change readDateDs1307)&lt;br /&gt;
   Wire.send(decToBcd(dayOfWeek));&lt;br /&gt;
   Wire.send(decToBcd(dayOfMonth));&lt;br /&gt;
   Wire.send(decToBcd(month));&lt;br /&gt;
   Wire.send(decToBcd(year));&lt;br /&gt;
   Wire.endTransmission();&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
// Gets the date and time from the ds1307 and prints result&lt;br /&gt;
// Watch for scope issues with Global Variables&lt;br /&gt;
void getDateDs1307()&lt;br /&gt;
{&lt;br /&gt;
  // Reset the register pointer&lt;br /&gt;
  Wire.beginTransmission(DS1307_I2C_ADDRESS);&lt;br /&gt;
  Wire.send(0);&lt;br /&gt;
  Wire.endTransmission();&lt;br /&gt;
&lt;br /&gt;
  Wire.requestFrom(DS1307_I2C_ADDRESS, 7);&lt;br /&gt;
&lt;br /&gt;
  // A few of these need masks because certain bits are control bits&lt;br /&gt;
  second     = bcdToDec(Wire.receive() &amp;amp; 0x7f);&lt;br /&gt;
  minute     = bcdToDec(Wire.receive());&lt;br /&gt;
  hour       = bcdToDec(Wire.receive() &amp;amp; 0x3f);  // Need to change this if 12 hour am/pm&lt;br /&gt;
  dayOfWeek  = bcdToDec(Wire.receive());&lt;br /&gt;
  dayOfMonth = bcdToDec(Wire.receive());&lt;br /&gt;
  month      = bcdToDec(Wire.receive());&lt;br /&gt;
  year       = bcdToDec(Wire.receive());&lt;br /&gt;
  &lt;br /&gt;
  Serial.print(hour, DEC);&lt;br /&gt;
  Serial.print(&amp;quot;:&amp;quot;);&lt;br /&gt;
  Serial.print(minute, DEC);&lt;br /&gt;
  Serial.print(&amp;quot;:&amp;quot;);&lt;br /&gt;
  Serial.print(second, DEC);&lt;br /&gt;
  Serial.print(&amp;quot;  &amp;quot;);&lt;br /&gt;
  Serial.print(month, DEC);&lt;br /&gt;
  Serial.print(&amp;quot;/&amp;quot;);&lt;br /&gt;
  Serial.print(dayOfMonth, DEC);&lt;br /&gt;
  Serial.print(&amp;quot;/&amp;quot;);&lt;br /&gt;
  Serial.print(year, DEC);&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
void setup() {&lt;br /&gt;
  Wire.begin();&lt;br /&gt;
  Serial.begin(57600);&lt;br /&gt;
  pinMode(duct1, OUTPUT);&lt;br /&gt;
  pinMode(duct2, OUTPUT);&lt;br /&gt;
  pinMode(duct3, OUTPUT);&lt;br /&gt;
  pinMode(duct4, OUTPUT);&lt;br /&gt;
  pinMode(ac_on, OUTPUT);&lt;br /&gt;
  pinMode(fan_on, OUTPUT);&lt;br /&gt;
  // Initialize Date/Time to update RTC DS1307 - You need to run the Q command right after you download this program&lt;br /&gt;
  // This is temporary until a more complex date time command is finished&lt;br /&gt;
  second = 15;&lt;br /&gt;
  minute = 41;&lt;br /&gt;
  hour = 12;&lt;br /&gt;
  dayOfWeek = 5;&lt;br /&gt;
  dayOfMonth = 5;&lt;br /&gt;
  month = 9;&lt;br /&gt;
  year = 8;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
void loop() {&lt;br /&gt;
  if (millis() - previousMillis &amp;gt; polltime) {&lt;br /&gt;
    previousMillis = millis();   // remember the last time&lt;br /&gt;
    if (millis() - ac_on_start &amp;gt; ac_on_delay) { &lt;br /&gt;
      if (digitalRead(duct1) || digitalRead(duct2) || digitalRead(duct3) || digitalRead(duct4)){  // If any ducts are turned on turn on the A/C&lt;br /&gt;
       if (digitalRead(ac_on) != HIGH) { // Check ac_on state&lt;br /&gt;
        digitalWrite(ac_on,HIGH);&lt;br /&gt;
        getDateDs1307();&lt;br /&gt;
        Serial.println(&amp;quot; - AC ON&amp;quot;);&lt;br /&gt;
       }&lt;br /&gt;
       ac_on_start = millis();&lt;br /&gt;
      } &lt;br /&gt;
      else if (digitalRead(ac_on) != LOW){ //Check ac_on state&lt;br /&gt;
       digitalWrite(ac_on,LOW);&lt;br /&gt;
       getDateDs1307();&lt;br /&gt;
       Serial.println(&amp;quot; - AC OFF&amp;quot;);&lt;br /&gt;
      }&lt;br /&gt;
    }&lt;br /&gt;
    temp1_val[val_cnt] = analogRead(temp1Pin);    // read the value from the sensors&lt;br /&gt;
    temp2_val[val_cnt] = analogRead(temp2Pin);&lt;br /&gt;
    temp3_val[val_cnt] = analogRead(temp3Pin);&lt;br /&gt;
    temp4_val[val_cnt] = analogRead(temp4Pin);&lt;br /&gt;
    val_cnt ++;&lt;br /&gt;
    if (val_cnt == 5) {&lt;br /&gt;
      val_cnt = 0;&lt;br /&gt;
    }&lt;br /&gt;
    temp1_avg = (temp1_val[0] + temp1_val[1] + temp1_val[2] + temp1_val[3] + temp1_val[4])/5;&lt;br /&gt;
    temp2_avg = (temp2_val[0] + temp2_val[1] + temp2_val[2] + temp2_val[3] + temp2_val[4])/5;&lt;br /&gt;
    temp3_avg = (temp3_val[0] + temp3_val[1] + temp3_val[2] + temp3_val[3] + temp3_val[4])/5;&lt;br /&gt;
    temp4_avg = (temp4_val[0] + temp4_val[1] + temp4_val[2] + temp4_val[3] + temp4_val[4])/5;&lt;br /&gt;
// Check Thresholds against the Temperatures and set the ducts HIGH or LOW    &lt;br /&gt;
    if (temp1_avg &amp;gt;= THRESHOLD1) {digitalWrite(duct1, HIGH);}&lt;br /&gt;
    else {digitalWrite(duct1, LOW);}&lt;br /&gt;
    if (temp2_avg &amp;gt;= THRESHOLD2) {digitalWrite(duct2, HIGH);}&lt;br /&gt;
    else {digitalWrite(duct2, LOW);}&lt;br /&gt;
    if (temp3_avg &amp;gt;= THRESHOLD3) {digitalWrite(duct3, HIGH);}&lt;br /&gt;
    else {digitalWrite(duct3, LOW);}&lt;br /&gt;
    if (temp4_avg &amp;gt;= THRESHOLD4) {digitalWrite(duct4, HIGH);}&lt;br /&gt;
    else {digitalWrite(duct4, LOW);}&lt;br /&gt;
    if (Serial.available()) {      // Look for char in serial que and process if found&lt;br /&gt;
      command = Serial.read();&lt;br /&gt;
      if (command == 84) {          // If command = &amp;quot;T&amp;quot; &lt;br /&gt;
        command = Serial.read();&lt;br /&gt;
        if (command == 49) {          // If command = &amp;quot;1&amp;quot; print the Temp1&lt;br /&gt;
         Serial.print(&amp;quot;Temp1 = &amp;quot;);&lt;br /&gt;
         Serial.print(temp1_avg);           // &lt;br /&gt;
         Serial.print(&amp;quot; &amp;quot;);&lt;br /&gt;
        }&lt;br /&gt;
        else if (command == 50) {      // If command = &amp;quot;2&amp;quot; print the Temp2&lt;br /&gt;
         Serial.print(&amp;quot;Temp2 = &amp;quot;);&lt;br /&gt;
         Serial.print(temp2_avg);           // &lt;br /&gt;
         Serial.print(&amp;quot; &amp;quot;);&lt;br /&gt;
        }&lt;br /&gt;
        else if (command == 51) {      // If command = &amp;quot;3&amp;quot; print the Temp3&lt;br /&gt;
         Serial.print(&amp;quot;Temp3 = &amp;quot;);&lt;br /&gt;
         Serial.print(temp3_avg);           // &lt;br /&gt;
         Serial.print(&amp;quot; &amp;quot;);&lt;br /&gt;
        }&lt;br /&gt;
        else if (command == 52) {      // If command = &amp;quot;4&amp;quot; print the Temp4&lt;br /&gt;
         Serial.print(&amp;quot;Temp4 = &amp;quot;);&lt;br /&gt;
         Serial.print(temp4_avg);           // &lt;br /&gt;
         Serial.print(&amp;quot; &amp;quot;);&lt;br /&gt;
         }&lt;br /&gt;
       }&lt;br /&gt;
      else if (command == 67) {      //If command = &amp;quot;C&amp;quot; Change Temp Threshhold&lt;br /&gt;
        if (Serial.available()) {&lt;br /&gt;
         command = Serial.read();&lt;br /&gt;
         if (command == 49) {        // If command = &amp;quot;1&amp;quot; print the THRESHOLD1&lt;br /&gt;
           command = Serial.read();&lt;br /&gt;
           if (command &amp;gt; 47 &amp;amp;&amp;amp; command &amp;lt; 58) {          // If command is between 0-9 Increment the Threshold by number sent&lt;br /&gt;
             THRESHOLD1 += command - 48;                 // ASCII math to get value sent   &lt;br /&gt;
                  Serial.print(&amp;quot;THRESHOLD1 = &amp;quot;);&lt;br /&gt;
                  Serial.print(THRESHOLD1);           // &lt;br /&gt;
                  Serial.print(&amp;quot; &amp;quot;);&lt;br /&gt;
           }&lt;br /&gt;
         }  &lt;br /&gt;
         else if (command == 50) {     // If command = &amp;quot;2&amp;quot; print the THRESHOLD2&lt;br /&gt;
           command = Serial.read();&lt;br /&gt;
           if (command &amp;gt; 47 &amp;amp;&amp;amp; command &amp;lt; 58) {          // If command is between 0-9 Increment the Threshold by number sent&lt;br /&gt;
             THRESHOLD2 += command - 48;                 // ASCII math to get value sent   &lt;br /&gt;
                  Serial.print(&amp;quot;THRESHOLD2 = &amp;quot;);&lt;br /&gt;
                  Serial.print(THRESHOLD2);           // &lt;br /&gt;
                  Serial.print(&amp;quot; &amp;quot;);&lt;br /&gt;
           }&lt;br /&gt;
         }&lt;br /&gt;
         else if (command == 51) {             // If command = &amp;quot;3&amp;quot; print the THRESHOLD3&lt;br /&gt;
           command = Serial.read();&lt;br /&gt;
           if (command &amp;gt; 47 &amp;amp;&amp;amp; command &amp;lt; 58) {          // If command is between 0-9 Increment the Threshold by number sent&lt;br /&gt;
             THRESHOLD3 += command - 48;                 // ASCII math to get value sent   &lt;br /&gt;
                  Serial.print(&amp;quot;THRESHOLD3 = &amp;quot;);&lt;br /&gt;
                  Serial.print(THRESHOLD3);           // &lt;br /&gt;
                  Serial.print(&amp;quot; &amp;quot;);&lt;br /&gt;
           }&lt;br /&gt;
         }&lt;br /&gt;
         else if (command == 52) {             // If command = &amp;quot;4&amp;quot; print the THRESHOLD4&lt;br /&gt;
           command = Serial.read();&lt;br /&gt;
           if (command &amp;gt; 47 &amp;amp;&amp;amp; command &amp;lt; 58) {          // If command is between 0-9 Increment the Threshold by number sent&lt;br /&gt;
             THRESHOLD4 += command - 48;                 // ASCII math to get value sent   &lt;br /&gt;
                  Serial.print(&amp;quot;THRESHOLD4 = &amp;quot;);&lt;br /&gt;
                  Serial.print(THRESHOLD4);           // &lt;br /&gt;
                  Serial.print(&amp;quot; &amp;quot;);&lt;br /&gt;
           }&lt;br /&gt;
         }          &lt;br /&gt;
        }  &lt;br /&gt;
      }&lt;br /&gt;
      else if (command == 68) {      //If command = &amp;quot;D&amp;quot; Change Temp Threshhold&lt;br /&gt;
        if (Serial.available()) {&lt;br /&gt;
         command = Serial.read();&lt;br /&gt;
         if (command == 49) {           // If command = &amp;quot;1&amp;quot; print the THRESHOLD1&lt;br /&gt;
           command = Serial.read();&lt;br /&gt;
           if (command &amp;gt; 47 &amp;amp;&amp;amp; command &amp;lt; 58) {          // If command is between 0-9 Decrement the Threshold by number sent&lt;br /&gt;
             THRESHOLD1 -= command - 48;                 // ASCII math to get value sent   &lt;br /&gt;
                  Serial.print(&amp;quot;THRESHOLD1 = &amp;quot;);&lt;br /&gt;
                  Serial.print(THRESHOLD1);           // &lt;br /&gt;
                  Serial.print(&amp;quot; &amp;quot;);&lt;br /&gt;
           }&lt;br /&gt;
         }  &lt;br /&gt;
         else if (command == 50) {               // If command = &amp;quot;2&amp;quot; print the THRESHOLD2&lt;br /&gt;
           command = Serial.read();&lt;br /&gt;
           if (command &amp;gt; 47 &amp;amp;&amp;amp; command &amp;lt; 58) {          // If command is between 0-9 Decrement the Threshold by number sent&lt;br /&gt;
             THRESHOLD2 -= command - 48;                 // ASCII math to get value sent   &lt;br /&gt;
                  Serial.print(&amp;quot;THRESHOLD2 = &amp;quot;);&lt;br /&gt;
                  Serial.print(THRESHOLD2);           // &lt;br /&gt;
                  Serial.print(&amp;quot; &amp;quot;);&lt;br /&gt;
           }&lt;br /&gt;
         }&lt;br /&gt;
         else if (command == 51) {              // If command = &amp;quot;3&amp;quot; print the THRESHOLD3&lt;br /&gt;
           command = Serial.read();&lt;br /&gt;
           if (command &amp;gt; 47 &amp;amp;&amp;amp; command &amp;lt; 58) {          // If command is between 0-9 Decrement the Threshold by number sent&lt;br /&gt;
             THRESHOLD3 -= command - 48;                 // ASCII math to get value sent   &lt;br /&gt;
                  Serial.print(&amp;quot;THRESHOLD3 = &amp;quot;);&lt;br /&gt;
                  Serial.print(THRESHOLD3);           // &lt;br /&gt;
                  Serial.print(&amp;quot; &amp;quot;);&lt;br /&gt;
           }&lt;br /&gt;
         }&lt;br /&gt;
         else if (command == 52) {                    // If command = &amp;quot;4&amp;quot; print the THRESHOLD4&lt;br /&gt;
           command = Serial.read();&lt;br /&gt;
           if (command &amp;gt; 47 &amp;amp;&amp;amp; command &amp;lt; 58) {          // If command is between 0-9 Decrement the Threshold by number sent&lt;br /&gt;
             THRESHOLD4 -= command - 48;                 // ASCII math to get value sent   &lt;br /&gt;
                  Serial.print(&amp;quot;THRESHOLD4 = &amp;quot;);&lt;br /&gt;
                  Serial.print(THRESHOLD4);           // &lt;br /&gt;
                  Serial.print(&amp;quot; &amp;quot;);&lt;br /&gt;
           }&lt;br /&gt;
         }           &lt;br /&gt;
        }  &lt;br /&gt;
      }&lt;br /&gt;
//****************  Warning - This is a potential for problem - Consider a manual lock out feature to lock out manual commands &lt;br /&gt;
//****************  Possibly create a command to open up manual commands for a certian time period then shut them off again automatically&lt;br /&gt;
      else if (command == 65) {      //If command = &amp;quot;A&amp;quot; Change Temp Threshhold&lt;br /&gt;
       if (Serial.available()) {&lt;br /&gt;
        command = Serial.read();&lt;br /&gt;
        if (command == 49) {        // If command = &amp;quot;1&amp;quot; print the AC ON message&lt;br /&gt;
         getDateDs1307();&lt;br /&gt;
         Serial.print(&amp;quot; - Manual AC ON &amp;quot;);&lt;br /&gt;
         ac_on_start = millis();   // Set the AC to a delay before it can be turned off again&lt;br /&gt;
         digitalWrite(ac_on,HIGH);&lt;br /&gt;
        }&lt;br /&gt;
        else if (command == 48) {        // If command = &amp;quot;0&amp;quot; print the AC OFF message&lt;br /&gt;
         getDateDs1307();&lt;br /&gt;
         Serial.print(&amp;quot; - Manual AC OFF &amp;quot;);&lt;br /&gt;
         digitalWrite(ac_on,LOW);&lt;br /&gt;
        }&lt;br /&gt;
       } &lt;br /&gt;
      } &lt;br /&gt;
      else if (command == 70) {      //If command = &amp;quot;F&amp;quot; Change Temp Threshhold&lt;br /&gt;
       if (Serial.available()) {&lt;br /&gt;
        command = Serial.read();&lt;br /&gt;
        if (command == 49) {        // If command = &amp;quot;1&amp;quot; print the FAN ON message&lt;br /&gt;
         getDateDs1307();&lt;br /&gt;
         Serial.print(&amp;quot; - Manual FAN ON &amp;quot;);&lt;br /&gt;
         ac_on_start = millis();&lt;br /&gt;
         digitalWrite(fan_on,HIGH);&lt;br /&gt;
        }&lt;br /&gt;
        else if (command == 48) {        // If command = &amp;quot;0&amp;quot; print the FAN OFF message&lt;br /&gt;
         getDateDs1307();&lt;br /&gt;
         Serial.print(&amp;quot; - Manual FAN OFF &amp;quot;);&lt;br /&gt;
         digitalWrite(fan_on,LOW);&lt;br /&gt;
        }&lt;br /&gt;
       } &lt;br /&gt;
      }&lt;br /&gt;
//********************** End of Warning Zone *******************************&lt;br /&gt;
&lt;br /&gt;
// ***************  This Section Will list the Staus of the Controller&lt;br /&gt;
      else if (command == 83) {      //If command = &amp;quot;S&amp;quot; Print Controller Status&lt;br /&gt;
        getDateDs1307();&lt;br /&gt;
        Serial.println(&amp;quot; &amp;quot;);&lt;br /&gt;
        Serial.println(&amp;quot; &amp;quot;);&lt;br /&gt;
        Serial.print(&amp;quot;Temp1 = &amp;quot;);&lt;br /&gt;
        Serial.println(temp1_avg);   &lt;br /&gt;
        Serial.print(&amp;quot;Temp2 = &amp;quot;);&lt;br /&gt;
        Serial.println(temp2_avg);&lt;br /&gt;
        Serial.print(&amp;quot;Temp3 = &amp;quot;);&lt;br /&gt;
        Serial.println(temp3_avg);   &lt;br /&gt;
        Serial.print(&amp;quot;Temp4 = &amp;quot;);&lt;br /&gt;
        Serial.println(temp4_avg);   &lt;br /&gt;
        Serial.println(&amp;quot; &amp;quot;);&lt;br /&gt;
        Serial.print(&amp;quot;THRESHOLD1 = &amp;quot;);&lt;br /&gt;
        Serial.println(THRESHOLD1);   &lt;br /&gt;
        Serial.print(&amp;quot;THRESHOLD2 = &amp;quot;);&lt;br /&gt;
        Serial.println(THRESHOLD2); &lt;br /&gt;
        Serial.print(&amp;quot;THRESHOLD3 = &amp;quot;);&lt;br /&gt;
        Serial.println(THRESHOLD3); &lt;br /&gt;
        Serial.print(&amp;quot;THRESHOLD4 = &amp;quot;);&lt;br /&gt;
        Serial.println(THRESHOLD4);&lt;br /&gt;
        Serial.println(&amp;quot; &amp;quot;);&lt;br /&gt;
        if (digitalRead(duct1) == HIGH) {Serial.println(&amp;quot;duct1 ON&amp;quot;);}&lt;br /&gt;
        else{Serial.println(&amp;quot;duct1 OFF&amp;quot;);}&lt;br /&gt;
        if (digitalRead(duct2) == HIGH) {Serial.println(&amp;quot;duct2 ON&amp;quot;);}&lt;br /&gt;
        else{Serial.println(&amp;quot;duct2 OFF&amp;quot;);}&lt;br /&gt;
        if (digitalRead(duct3) == HIGH) {Serial.println(&amp;quot;duct3 ON&amp;quot;);}&lt;br /&gt;
        else{Serial.println(&amp;quot;duct3 OFF&amp;quot;);}&lt;br /&gt;
        if (digitalRead(duct4) == HIGH) {Serial.println(&amp;quot;duct4 ON&amp;quot;);}&lt;br /&gt;
        else{Serial.println(&amp;quot;duct4 OFF&amp;quot;);}&lt;br /&gt;
        Serial.println(&amp;quot; &amp;quot;);&lt;br /&gt;
        if (digitalRead(fan_on) == HIGH) {Serial.println(&amp;quot;Fan ON&amp;quot;);}&lt;br /&gt;
        else{Serial.println(&amp;quot;Fan OFF&amp;quot;);}&lt;br /&gt;
        if (digitalRead(ac_on) == HIGH) {Serial.println(&amp;quot;AC  ON&amp;quot;);}&lt;br /&gt;
        else{Serial.println(&amp;quot;AC  OFF&amp;quot;);}&lt;br /&gt;
        Serial.print(&amp;quot;A/C Delay (millisec) = &amp;quot;);&lt;br /&gt;
        Serial.println(ac_on_delay);&lt;br /&gt;
        Serial.print(&amp;quot;Temp Polling (millisec) = &amp;quot;);&lt;br /&gt;
        Serial.println(polltime);          &lt;br /&gt;
        Serial.println(&amp;quot; &amp;quot;);&lt;br /&gt;
        &lt;br /&gt;
      }&lt;br /&gt;
      else if (command == 81) {      //If command = &amp;quot;Q&amp;quot; Set Date&lt;br /&gt;
       setDateDs1307();&lt;br /&gt;
       getDateDs1307();&lt;br /&gt;
       Serial.println(&amp;quot; &amp;quot;);&lt;br /&gt;
      }&lt;br /&gt;
      Serial.println(command);     // Echo command char found in serial que&lt;br /&gt;
      command = 0;                 // reset command &lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
//*****************************************************The End***********************&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== A/C_Control_v.01 User Guide ==&lt;br /&gt;
==== Commands ====&lt;br /&gt;
== Troubleshooting ==&lt;br /&gt;
=== Summary ===&lt;br /&gt;
When Troubleshooting a multi-functional issue, it is best practice to break down the issue into pieces and test each piece as a separate system.  However, we will first run through a quick test to see if we can find any obvious issues first.&lt;br /&gt;
=== Quick Test ===&lt;/div&gt;</summary>
		<author><name>Combustor</name></author>	</entry>

	<entry>
		<id>http://combustory.com/wiki/index.php/Temperature_Controller</id>
		<title>Temperature Controller</title>
		<link rel="alternate" type="text/html" href="http://combustory.com/wiki/index.php/Temperature_Controller"/>
				<updated>2008-09-06T19:47:14Z</updated>
		
		<summary type="html">&lt;p&gt;Combustor: New page: {{default}} == Warning == '''This page is in progress and none of the code can be considered good or complete. I am just using this as an alternate storage of the code for right now.'''  =...&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{default}}&lt;br /&gt;
== Warning ==&lt;br /&gt;
'''This page is in progress and none of the code can be considered good or complete. I am just using this as an alternate storage of the code for right now.'''&lt;br /&gt;
&lt;br /&gt;
== Summary ==&lt;br /&gt;
== Functional Description of the Method ==&lt;br /&gt;
== Requirements ==&lt;br /&gt;
== Example of Method ==&lt;br /&gt;
=== Quick Guide: ===&lt;br /&gt;
=== Detailed Guide: ===&lt;br /&gt;
==== A/C_Control_v.01 code ====&lt;br /&gt;
&lt;br /&gt;
''' While this says v.01, don't count on it being a released v.01, I am still working on v.01, this is a back up '''&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
/*&lt;br /&gt;
 * A/C Control v.01&lt;br /&gt;
 * by &amp;lt;http://www.combustory.com&amp;gt; John Vaughters&lt;br /&gt;
 * Credit to:&lt;br /&gt;
 * Maurice Ribble - http://www.glacialwanderer.com/hobbyrobotics for RTC DS1307 code&lt;br /&gt;
 *&lt;br /&gt;
 * Turns on an LED for temperatures from analog pins 1-5 on&lt;br /&gt;
 * digital pins 2-6 when the temperature rises above the THRESHOLDS 1-5.&lt;br /&gt;
 * The program also implements a &lt;br /&gt;
 * Serial Communication method that utilizes a leading CHAR for each command Described below. &lt;br /&gt;
 * Commands:&lt;br /&gt;
 * T(1-4) - Temp1-5 Status ex. T1, T2, etc&lt;br /&gt;
 * C(1-4)(0-9) - Increment THRESHOLD1-4 by (1-9) ex. C15 increments THRESHOLD1 BY 5 (Note: C40 will give you a status of THRESHOLD4)&lt;br /&gt;
 * D(1-4)(0-9) - Decrement THRESHOLD1-4 by (1-9) ex. D59 decrements THRESHOLD5 BY 9 (Note: D10 will give you a status of THRESHOLD1)&lt;br /&gt;
 * A(0-1) - Manual AC on command A1 is AC on, A0 is AC off&lt;br /&gt;
 * F(0-1) - Manual AC on command A1 is FAN on, A0 is FAN off &lt;br /&gt;
 * Q - Q Sets the date of the RTC DS1307 Chip&lt;br /&gt;
 */&lt;br /&gt;
&lt;br /&gt;
#include &amp;quot;Wire.h&amp;quot;&lt;br /&gt;
#define DS1307_I2C_ADDRESS 0x68&lt;br /&gt;
&lt;br /&gt;
// Global Variables&lt;br /&gt;
int val_cnt = 0;               // counter for the temp_val                   &lt;br /&gt;
int temp1Pin = 0;    // select the input pin for the Thermistor&lt;br /&gt;
int temp2Pin = 1;    // select the input pin for the Thermistor&lt;br /&gt;
int temp3Pin = 2;    // select the input pin for the Thermistor&lt;br /&gt;
int temp4Pin = 3;    // select the input pin for the Thermistor&lt;br /&gt;
int temp1_val[5] = {0,0,0,0,0};       // variable to store the value coming from the sensor&lt;br /&gt;
int temp2_val[5] = {0,0,0,0,0};       //           &lt;br /&gt;
int temp3_val[5] = {0,0,0,0,0};       //&lt;br /&gt;
int temp4_val[5] = {0,0,0,0,0};       //&lt;br /&gt;
int temp1_avg;                   // average over poll time of the temp values&lt;br /&gt;
int temp2_avg;&lt;br /&gt;
int temp3_avg;&lt;br /&gt;
int temp4_avg;&lt;br /&gt;
int duct1 = 2;                   // Ducts open or close using a digital output&lt;br /&gt;
int duct2 = 3;&lt;br /&gt;
int duct3 = 4;&lt;br /&gt;
int duct4 = 5;&lt;br /&gt;
int THRESHOLD1 = 580;    // Default theshold values&lt;br /&gt;
int THRESHOLD2 = 580;&lt;br /&gt;
int THRESHOLD3 = 580;&lt;br /&gt;
int THRESHOLD4 = 580;&lt;br /&gt;
int ac_on = 13;&lt;br /&gt;
int fan_on = 12;&lt;br /&gt;
int command = 0;       // This is the command char, in ascii form, sent from the serial port     &lt;br /&gt;
long polltime = 1000;  // The time to Poll the tempPins&lt;br /&gt;
long previousMillis = 0;        // will store last time Temp was updated&lt;br /&gt;
long ac_on_start = 0;     // Start A/C delay timer&lt;br /&gt;
long ac_on_delay = 10000;   // Time to wait before checking the ducts again&lt;br /&gt;
byte second, minute, hour, dayOfWeek, dayOfMonth, month, year;&lt;br /&gt;
&lt;br /&gt;
  &lt;br /&gt;
// Convert normal decimal numbers to binary coded decimal&lt;br /&gt;
byte decToBcd(byte val)&lt;br /&gt;
{&lt;br /&gt;
  return ( (val/10*16) + (val%10) );&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
// Convert binary coded decimal to normal decimal numbers&lt;br /&gt;
byte bcdToDec(byte val)&lt;br /&gt;
{&lt;br /&gt;
  return ( (val/16*10) + (val%16) );&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
// 1) Sets the date and time on the ds1307&lt;br /&gt;
// 2) Starts the clock&lt;br /&gt;
// 3) Sets hour mode to 24 hour clock&lt;br /&gt;
// Assumes you're passing in valid numbers&lt;br /&gt;
// Watch for scope issues with Global Variables&lt;br /&gt;
/*void setDateDs1307(byte second,        // 0-59&lt;br /&gt;
                   byte minute,        // 0-59&lt;br /&gt;
                   byte hour,          // 1-23&lt;br /&gt;
                   byte dayOfWeek,     // 1-7&lt;br /&gt;
                   byte dayOfMonth,    // 1-28/29/30/31&lt;br /&gt;
                   byte month,         // 1-12&lt;br /&gt;
                   byte year)          // 0-99*/&lt;br /&gt;
void setDateDs1307()                &lt;br /&gt;
{&lt;br /&gt;
   Wire.beginTransmission(DS1307_I2C_ADDRESS);&lt;br /&gt;
   Wire.send(0);&lt;br /&gt;
   Wire.send(decToBcd(second));    // 0 to bit 7 starts the clock&lt;br /&gt;
   Wire.send(decToBcd(minute));&lt;br /&gt;
   Wire.send(decToBcd(hour));      // If you want 12 hour am/pm you need to set&lt;br /&gt;
                                   // bit 6 (also need to change readDateDs1307)&lt;br /&gt;
   Wire.send(decToBcd(dayOfWeek));&lt;br /&gt;
   Wire.send(decToBcd(dayOfMonth));&lt;br /&gt;
   Wire.send(decToBcd(month));&lt;br /&gt;
   Wire.send(decToBcd(year));&lt;br /&gt;
   Wire.endTransmission();&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
// Gets the date and time from the ds1307 and prints result&lt;br /&gt;
// Watch for scope issues with Global Variables&lt;br /&gt;
void getDateDs1307()&lt;br /&gt;
{&lt;br /&gt;
  // Reset the register pointer&lt;br /&gt;
  Wire.beginTransmission(DS1307_I2C_ADDRESS);&lt;br /&gt;
  Wire.send(0);&lt;br /&gt;
  Wire.endTransmission();&lt;br /&gt;
&lt;br /&gt;
  Wire.requestFrom(DS1307_I2C_ADDRESS, 7);&lt;br /&gt;
&lt;br /&gt;
  // A few of these need masks because certain bits are control bits&lt;br /&gt;
  second     = bcdToDec(Wire.receive() &amp;amp; 0x7f);&lt;br /&gt;
  minute     = bcdToDec(Wire.receive());&lt;br /&gt;
  hour       = bcdToDec(Wire.receive() &amp;amp; 0x3f);  // Need to change this if 12 hour am/pm&lt;br /&gt;
  dayOfWeek  = bcdToDec(Wire.receive());&lt;br /&gt;
  dayOfMonth = bcdToDec(Wire.receive());&lt;br /&gt;
  month      = bcdToDec(Wire.receive());&lt;br /&gt;
  year       = bcdToDec(Wire.receive());&lt;br /&gt;
  &lt;br /&gt;
  Serial.print(hour, DEC);&lt;br /&gt;
  Serial.print(&amp;quot;:&amp;quot;);&lt;br /&gt;
  Serial.print(minute, DEC);&lt;br /&gt;
  Serial.print(&amp;quot;:&amp;quot;);&lt;br /&gt;
  Serial.print(second, DEC);&lt;br /&gt;
  Serial.print(&amp;quot;  &amp;quot;);&lt;br /&gt;
  Serial.print(month, DEC);&lt;br /&gt;
  Serial.print(&amp;quot;/&amp;quot;);&lt;br /&gt;
  Serial.print(dayOfMonth, DEC);&lt;br /&gt;
  Serial.print(&amp;quot;/&amp;quot;);&lt;br /&gt;
  Serial.print(year, DEC);&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
void setup() {&lt;br /&gt;
  Wire.begin();&lt;br /&gt;
  Serial.begin(57600);&lt;br /&gt;
  pinMode(duct1, OUTPUT);&lt;br /&gt;
  pinMode(duct2, OUTPUT);&lt;br /&gt;
  pinMode(duct3, OUTPUT);&lt;br /&gt;
  pinMode(duct4, OUTPUT);&lt;br /&gt;
  pinMode(ac_on, OUTPUT);&lt;br /&gt;
  pinMode(fan_on, OUTPUT);&lt;br /&gt;
  // Initialize Date/Time to update RTC DS1307 - You need to run the Q command right after you download this program&lt;br /&gt;
  // This is temporary until a more complex date time command is finished&lt;br /&gt;
  second = 15;&lt;br /&gt;
  minute = 41;&lt;br /&gt;
  hour = 12;&lt;br /&gt;
  dayOfWeek = 5;&lt;br /&gt;
  dayOfMonth = 5;&lt;br /&gt;
  month = 9;&lt;br /&gt;
  year = 8;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
void loop() {&lt;br /&gt;
  if (millis() - previousMillis &amp;gt; polltime) {&lt;br /&gt;
    previousMillis = millis();   // remember the last time&lt;br /&gt;
    if (millis() - ac_on_start &amp;gt; ac_on_delay) { &lt;br /&gt;
      if (digitalRead(duct1) || digitalRead(duct2) || digitalRead(duct3) || digitalRead(duct4)){  // If any ducts are turned on turn on the A/C&lt;br /&gt;
       if (digitalRead(ac_on) != HIGH) { // Check ac_on state&lt;br /&gt;
        digitalWrite(ac_on,HIGH);&lt;br /&gt;
        getDateDs1307();&lt;br /&gt;
        Serial.println(&amp;quot; - AC ON&amp;quot;);&lt;br /&gt;
       }&lt;br /&gt;
       ac_on_start = millis();&lt;br /&gt;
      } &lt;br /&gt;
      else if (digitalRead(ac_on) != LOW){ //Check ac_on state&lt;br /&gt;
       digitalWrite(ac_on,LOW);&lt;br /&gt;
       getDateDs1307();&lt;br /&gt;
       Serial.println(&amp;quot; - AC OFF&amp;quot;);&lt;br /&gt;
      }&lt;br /&gt;
    }&lt;br /&gt;
    temp1_val[val_cnt] = analogRead(temp1Pin);    // read the value from the sensors&lt;br /&gt;
    temp2_val[val_cnt] = analogRead(temp2Pin);&lt;br /&gt;
    temp3_val[val_cnt] = analogRead(temp3Pin);&lt;br /&gt;
    temp4_val[val_cnt] = analogRead(temp4Pin);&lt;br /&gt;
    val_cnt ++;&lt;br /&gt;
    if (val_cnt == 5) {&lt;br /&gt;
      val_cnt = 0;&lt;br /&gt;
    }&lt;br /&gt;
    temp1_avg = (temp1_val[0] + temp1_val[1] + temp1_val[2] + temp1_val[3] + temp1_val[4])/5;&lt;br /&gt;
    temp2_avg = (temp2_val[0] + temp2_val[1] + temp2_val[2] + temp2_val[3] + temp2_val[4])/5;&lt;br /&gt;
    temp3_avg = (temp3_val[0] + temp3_val[1] + temp3_val[2] + temp3_val[3] + temp3_val[4])/5;&lt;br /&gt;
    temp4_avg = (temp4_val[0] + temp4_val[1] + temp4_val[2] + temp4_val[3] + temp4_val[4])/5;&lt;br /&gt;
// Check Thresholds against the Temperatures and set the ducts HIGH or LOW    &lt;br /&gt;
    if (temp1_avg &amp;gt;= THRESHOLD1) {digitalWrite(duct1, HIGH);}&lt;br /&gt;
    else {digitalWrite(duct1, LOW);}&lt;br /&gt;
    if (temp2_avg &amp;gt;= THRESHOLD2) {digitalWrite(duct2, HIGH);}&lt;br /&gt;
    else {digitalWrite(duct2, LOW);}&lt;br /&gt;
    if (temp3_avg &amp;gt;= THRESHOLD3) {digitalWrite(duct3, HIGH);}&lt;br /&gt;
    else {digitalWrite(duct3, LOW);}&lt;br /&gt;
    if (temp4_avg &amp;gt;= THRESHOLD4) {digitalWrite(duct4, HIGH);}&lt;br /&gt;
    else {digitalWrite(duct4, LOW);}&lt;br /&gt;
    if (Serial.available()) {      // Look for char in serial que and process if found&lt;br /&gt;
      command = Serial.read();&lt;br /&gt;
      if (command == 84) {          // If command = &amp;quot;T&amp;quot; &lt;br /&gt;
        command = Serial.read();&lt;br /&gt;
        if (command == 49) {          // If command = &amp;quot;1&amp;quot; print the Temp1&lt;br /&gt;
         Serial.print(&amp;quot;Temp1 = &amp;quot;);&lt;br /&gt;
         Serial.print(temp1_avg);           // &lt;br /&gt;
         Serial.print(&amp;quot; &amp;quot;);&lt;br /&gt;
        }&lt;br /&gt;
        else if (command == 50) {      // If command = &amp;quot;2&amp;quot; print the Temp2&lt;br /&gt;
         Serial.print(&amp;quot;Temp2 = &amp;quot;);&lt;br /&gt;
         Serial.print(temp2_avg);           // &lt;br /&gt;
         Serial.print(&amp;quot; &amp;quot;);&lt;br /&gt;
        }&lt;br /&gt;
        else if (command == 51) {      // If command = &amp;quot;3&amp;quot; print the Temp3&lt;br /&gt;
         Serial.print(&amp;quot;Temp3 = &amp;quot;);&lt;br /&gt;
         Serial.print(temp3_avg);           // &lt;br /&gt;
         Serial.print(&amp;quot; &amp;quot;);&lt;br /&gt;
        }&lt;br /&gt;
        else if (command == 52) {      // If command = &amp;quot;4&amp;quot; print the Temp4&lt;br /&gt;
         Serial.print(&amp;quot;Temp4 = &amp;quot;);&lt;br /&gt;
         Serial.print(temp4_avg);           // &lt;br /&gt;
         Serial.print(&amp;quot; &amp;quot;);&lt;br /&gt;
         }&lt;br /&gt;
       }&lt;br /&gt;
      else if (command == 67) {      //If command = &amp;quot;C&amp;quot; Change Temp Threshhold&lt;br /&gt;
        if (Serial.available()) {&lt;br /&gt;
         command = Serial.read();&lt;br /&gt;
         if (command == 49) {        // If command = &amp;quot;1&amp;quot; print the THRESHOLD1&lt;br /&gt;
           command = Serial.read();&lt;br /&gt;
           if (command &amp;gt; 47 &amp;amp;&amp;amp; command &amp;lt; 58) {          // If command is between 0-9 Increment the Threshold by number sent&lt;br /&gt;
             THRESHOLD1 += command - 48;                 // ASCII math to get value sent   &lt;br /&gt;
                  Serial.print(&amp;quot;THRESHOLD1 = &amp;quot;);&lt;br /&gt;
                  Serial.print(THRESHOLD1);           // &lt;br /&gt;
                  Serial.print(&amp;quot; &amp;quot;);&lt;br /&gt;
           }&lt;br /&gt;
         }  &lt;br /&gt;
         else if (command == 50) {     // If command = &amp;quot;2&amp;quot; print the THRESHOLD2&lt;br /&gt;
           command = Serial.read();&lt;br /&gt;
           if (command &amp;gt; 47 &amp;amp;&amp;amp; command &amp;lt; 58) {          // If command is between 0-9 Increment the Threshold by number sent&lt;br /&gt;
             THRESHOLD2 += command - 48;                 // ASCII math to get value sent   &lt;br /&gt;
                  Serial.print(&amp;quot;THRESHOLD2 = &amp;quot;);&lt;br /&gt;
                  Serial.print(THRESHOLD2);           // &lt;br /&gt;
                  Serial.print(&amp;quot; &amp;quot;);&lt;br /&gt;
           }&lt;br /&gt;
         }&lt;br /&gt;
         else if (command == 51) {             // If command = &amp;quot;3&amp;quot; print the THRESHOLD3&lt;br /&gt;
           command = Serial.read();&lt;br /&gt;
           if (command &amp;gt; 47 &amp;amp;&amp;amp; command &amp;lt; 58) {          // If command is between 0-9 Increment the Threshold by number sent&lt;br /&gt;
             THRESHOLD3 += command - 48;                 // ASCII math to get value sent   &lt;br /&gt;
                  Serial.print(&amp;quot;THRESHOLD3 = &amp;quot;);&lt;br /&gt;
                  Serial.print(THRESHOLD3);           // &lt;br /&gt;
                  Serial.print(&amp;quot; &amp;quot;);&lt;br /&gt;
           }&lt;br /&gt;
         }&lt;br /&gt;
         else if (command == 52) {             // If command = &amp;quot;4&amp;quot; print the THRESHOLD4&lt;br /&gt;
           command = Serial.read();&lt;br /&gt;
           if (command &amp;gt; 47 &amp;amp;&amp;amp; command &amp;lt; 58) {          // If command is between 0-9 Increment the Threshold by number sent&lt;br /&gt;
             THRESHOLD4 += command - 48;                 // ASCII math to get value sent   &lt;br /&gt;
                  Serial.print(&amp;quot;THRESHOLD4 = &amp;quot;);&lt;br /&gt;
                  Serial.print(THRESHOLD4);           // &lt;br /&gt;
                  Serial.print(&amp;quot; &amp;quot;);&lt;br /&gt;
           }&lt;br /&gt;
         }          &lt;br /&gt;
        }  &lt;br /&gt;
      }&lt;br /&gt;
      else if (command == 68) {      //If command = &amp;quot;D&amp;quot; Change Temp Threshhold&lt;br /&gt;
        if (Serial.available()) {&lt;br /&gt;
         command = Serial.read();&lt;br /&gt;
         if (command == 49) {           // If command = &amp;quot;1&amp;quot; print the THRESHOLD1&lt;br /&gt;
           command = Serial.read();&lt;br /&gt;
           if (command &amp;gt; 47 &amp;amp;&amp;amp; command &amp;lt; 58) {          // If command is between 0-9 Decrement the Threshold by number sent&lt;br /&gt;
             THRESHOLD1 -= command - 48;                 // ASCII math to get value sent   &lt;br /&gt;
                  Serial.print(&amp;quot;THRESHOLD1 = &amp;quot;);&lt;br /&gt;
                  Serial.print(THRESHOLD1);           // &lt;br /&gt;
                  Serial.print(&amp;quot; &amp;quot;);&lt;br /&gt;
           }&lt;br /&gt;
         }  &lt;br /&gt;
         else if (command == 50) {               // If command = &amp;quot;2&amp;quot; print the THRESHOLD2&lt;br /&gt;
           command = Serial.read();&lt;br /&gt;
           if (command &amp;gt; 47 &amp;amp;&amp;amp; command &amp;lt; 58) {          // If command is between 0-9 Decrement the Threshold by number sent&lt;br /&gt;
             THRESHOLD2 -= command - 48;                 // ASCII math to get value sent   &lt;br /&gt;
                  Serial.print(&amp;quot;THRESHOLD2 = &amp;quot;);&lt;br /&gt;
                  Serial.print(THRESHOLD2);           // &lt;br /&gt;
                  Serial.print(&amp;quot; &amp;quot;);&lt;br /&gt;
           }&lt;br /&gt;
         }&lt;br /&gt;
         else if (command == 51) {              // If command = &amp;quot;3&amp;quot; print the THRESHOLD3&lt;br /&gt;
           command = Serial.read();&lt;br /&gt;
           if (command &amp;gt; 47 &amp;amp;&amp;amp; command &amp;lt; 58) {          // If command is between 0-9 Decrement the Threshold by number sent&lt;br /&gt;
             THRESHOLD3 -= command - 48;                 // ASCII math to get value sent   &lt;br /&gt;
                  Serial.print(&amp;quot;THRESHOLD3 = &amp;quot;);&lt;br /&gt;
                  Serial.print(THRESHOLD3);           // &lt;br /&gt;
                  Serial.print(&amp;quot; &amp;quot;);&lt;br /&gt;
           }&lt;br /&gt;
         }&lt;br /&gt;
         else if (command == 52) {                    // If command = &amp;quot;4&amp;quot; print the THRESHOLD4&lt;br /&gt;
           command = Serial.read();&lt;br /&gt;
           if (command &amp;gt; 47 &amp;amp;&amp;amp; command &amp;lt; 58) {          // If command is between 0-9 Decrement the Threshold by number sent&lt;br /&gt;
             THRESHOLD4 -= command - 48;                 // ASCII math to get value sent   &lt;br /&gt;
                  Serial.print(&amp;quot;THRESHOLD4 = &amp;quot;);&lt;br /&gt;
                  Serial.print(THRESHOLD4);           // &lt;br /&gt;
                  Serial.print(&amp;quot; &amp;quot;);&lt;br /&gt;
           }&lt;br /&gt;
         }           &lt;br /&gt;
        }  &lt;br /&gt;
      }&lt;br /&gt;
//****************  Warning - This is a potential for problem - Consider a manual lock out feature to lock out manual commands &lt;br /&gt;
//****************  Possibly create a command to open up manual commands for a certian time period then shut them off again automatically&lt;br /&gt;
      else if (command == 65) {      //If command = &amp;quot;A&amp;quot; Change Temp Threshhold&lt;br /&gt;
       if (Serial.available()) {&lt;br /&gt;
        command = Serial.read();&lt;br /&gt;
        if (command == 49) {        // If command = &amp;quot;1&amp;quot; print the AC ON message&lt;br /&gt;
         getDateDs1307();&lt;br /&gt;
         Serial.print(&amp;quot; - Manual AC ON &amp;quot;);&lt;br /&gt;
         ac_on_start = millis();   // Set the AC to a delay before it can be turned off again&lt;br /&gt;
         digitalWrite(ac_on,HIGH);&lt;br /&gt;
        }&lt;br /&gt;
        else if (command == 48) {        // If command = &amp;quot;0&amp;quot; print the AC OFF message&lt;br /&gt;
         getDateDs1307();&lt;br /&gt;
         Serial.print(&amp;quot; - Manual AC OFF &amp;quot;);&lt;br /&gt;
         digitalWrite(ac_on,LOW);&lt;br /&gt;
        }&lt;br /&gt;
       } &lt;br /&gt;
      } &lt;br /&gt;
      else if (command == 70) {      //If command = &amp;quot;F&amp;quot; Change Temp Threshhold&lt;br /&gt;
       if (Serial.available()) {&lt;br /&gt;
        command = Serial.read();&lt;br /&gt;
        if (command == 49) {        // If command = &amp;quot;1&amp;quot; print the FAN ON message&lt;br /&gt;
         getDateDs1307();&lt;br /&gt;
         Serial.print(&amp;quot; - Manual FAN ON &amp;quot;);&lt;br /&gt;
         ac_on_start = millis();&lt;br /&gt;
         digitalWrite(fan_on,HIGH);&lt;br /&gt;
        }&lt;br /&gt;
        else if (command == 48) {        // If command = &amp;quot;0&amp;quot; print the FAN OFF message&lt;br /&gt;
         getDateDs1307();&lt;br /&gt;
         Serial.print(&amp;quot; - Manual FAN OFF &amp;quot;);&lt;br /&gt;
         digitalWrite(fan_on,LOW);&lt;br /&gt;
        }&lt;br /&gt;
       } &lt;br /&gt;
      }&lt;br /&gt;
//********************** End of Warning Zone *******************************&lt;br /&gt;
&lt;br /&gt;
// ***************  This Section Will list the Staus of the Controller&lt;br /&gt;
      else if (command == 83) {      //If command = &amp;quot;S&amp;quot; Print Controller Status&lt;br /&gt;
        getDateDs1307();&lt;br /&gt;
        Serial.println(&amp;quot; &amp;quot;);&lt;br /&gt;
        Serial.println(&amp;quot; &amp;quot;);&lt;br /&gt;
        Serial.print(&amp;quot;Temp1 = &amp;quot;);&lt;br /&gt;
        Serial.println(temp1_avg);   &lt;br /&gt;
        Serial.print(&amp;quot;Temp2 = &amp;quot;);&lt;br /&gt;
        Serial.println(temp2_avg);&lt;br /&gt;
        Serial.print(&amp;quot;Temp3 = &amp;quot;);&lt;br /&gt;
        Serial.println(temp3_avg);   &lt;br /&gt;
        Serial.print(&amp;quot;Temp4 = &amp;quot;);&lt;br /&gt;
        Serial.println(temp4_avg);   &lt;br /&gt;
        Serial.println(&amp;quot; &amp;quot;);&lt;br /&gt;
        Serial.print(&amp;quot;THRESHOLD1 = &amp;quot;);&lt;br /&gt;
        Serial.println(THRESHOLD1);   &lt;br /&gt;
        Serial.print(&amp;quot;THRESHOLD2 = &amp;quot;);&lt;br /&gt;
        Serial.println(THRESHOLD2); &lt;br /&gt;
        Serial.print(&amp;quot;THRESHOLD3 = &amp;quot;);&lt;br /&gt;
        Serial.println(THRESHOLD3); &lt;br /&gt;
        Serial.print(&amp;quot;THRESHOLD4 = &amp;quot;);&lt;br /&gt;
        Serial.println(THRESHOLD4);&lt;br /&gt;
        Serial.println(&amp;quot; &amp;quot;);&lt;br /&gt;
        if (digitalRead(duct1) == HIGH) {Serial.println(&amp;quot;duct1 ON&amp;quot;);}&lt;br /&gt;
        else{Serial.println(&amp;quot;duct1 OFF&amp;quot;);}&lt;br /&gt;
        if (digitalRead(duct2) == HIGH) {Serial.println(&amp;quot;duct2 ON&amp;quot;);}&lt;br /&gt;
        else{Serial.println(&amp;quot;duct2 OFF&amp;quot;);}&lt;br /&gt;
        if (digitalRead(duct3) == HIGH) {Serial.println(&amp;quot;duct3 ON&amp;quot;);}&lt;br /&gt;
        else{Serial.println(&amp;quot;duct3 OFF&amp;quot;);}&lt;br /&gt;
        if (digitalRead(duct4) == HIGH) {Serial.println(&amp;quot;duct4 ON&amp;quot;);}&lt;br /&gt;
        else{Serial.println(&amp;quot;duct4 OFF&amp;quot;);}&lt;br /&gt;
        Serial.println(&amp;quot; &amp;quot;);&lt;br /&gt;
        if (digitalRead(fan_on) == HIGH) {Serial.println(&amp;quot;Fan ON&amp;quot;);}&lt;br /&gt;
        else{Serial.println(&amp;quot;Fan OFF&amp;quot;);}&lt;br /&gt;
        if (digitalRead(ac_on) == HIGH) {Serial.println(&amp;quot;AC  ON&amp;quot;);}&lt;br /&gt;
        else{Serial.println(&amp;quot;AC  OFF&amp;quot;);}&lt;br /&gt;
        Serial.print(&amp;quot;A/C Delay (millisec) = &amp;quot;);&lt;br /&gt;
        Serial.println(ac_on_delay);&lt;br /&gt;
        Serial.print(&amp;quot;Temp Polling (millisec) = &amp;quot;);&lt;br /&gt;
        Serial.println(polltime);          &lt;br /&gt;
        Serial.println(&amp;quot; &amp;quot;);&lt;br /&gt;
        &lt;br /&gt;
      }&lt;br /&gt;
      else if (command == 81) {      //If command = &amp;quot;Q&amp;quot; Set Date&lt;br /&gt;
       setDateDs1307();&lt;br /&gt;
       getDateDs1307();&lt;br /&gt;
       Serial.println(&amp;quot; &amp;quot;);&lt;br /&gt;
      }&lt;br /&gt;
      Serial.println(command);     // Echo command char found in serial que&lt;br /&gt;
      command = 0;                 // reset command &lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
//*****************************************************The End***********************&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== A/C_Control_v.01 User Guide ==&lt;br /&gt;
==== Commands ====&lt;br /&gt;
== Troubleshooting ==&lt;br /&gt;
=== Summary ===&lt;br /&gt;
When Troubleshooting a multi-functional issue, it is best practice to break down the issue into pieces and test each piece as a separate system.  However, we will first run through a quick test to see if we can find any obvious issues first.&lt;br /&gt;
=== Quick Test ===&lt;/div&gt;</summary>
		<author><name>Combustor</name></author>	</entry>

	<entry>
		<id>http://combustory.com/wiki/index.php/Arduino_Communications</id>
		<title>Arduino Communications</title>
		<link rel="alternate" type="text/html" href="http://combustory.com/wiki/index.php/Arduino_Communications"/>
				<updated>2008-09-06T19:31:11Z</updated>
		
		<summary type="html">&lt;p&gt;Combustor: /* ''command'' file */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{default}}&lt;br /&gt;
&lt;br /&gt;
'''Check out this awesome Arduino application - [[MPGuino]] - An MPG gauge for fuel efficiency.'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Summary ==&lt;br /&gt;
&lt;br /&gt;
In my search for methods to communicate with the Arduino board, I found lots of ways that required me to learn new languages or learn serial communication programming.  I do want to eventually pick up these skills, but I found a quicker way for my needs.  I have learned over time that you can always find a better way to solve a problem, but I realize that the amount of time to learn that better way is sometimes greater than the project time-frame, and therefore just solve it in the best way you can with the tools you have.  I believe that the solution below encompasses that spirit.  Here you will find a quick, dirty yet effective solution for communicating with the Arduino.&lt;br /&gt;
&lt;br /&gt;
This solution met my goals, but it may not meet yours.  It is limited in the effect that a transfer in a message may take as long as 5 sec.  This fits fine for my needs where I am just looking to form a distributed network of smart sensors/controllers that allow the setting of certain variables and the reporting of alarms and/or useful tracking information from the individual controllers.&lt;br /&gt;
&lt;br /&gt;
'''Note: I owe a BIG debt of gratitude to all the Arduino hackers that provided me with the tools/code/knowledge to allow this solution'''&lt;br /&gt;
&lt;br /&gt;
== Functional Description of the Method ==&lt;br /&gt;
&lt;br /&gt;
This method creates a log file that is created by an Arduino board using serial communications that is sent to a terminal which is redirected to a file.  The file can then be used by any software you desire to process the messages from the Arduino board. To send messages to the Arduino board the use of Arduino-Serial (a command line utility) is placed in a BASH script that is used to constantly poll for the existence of a ''command'' file.  When a ''command'' file is found, the BASH script will send the commands in the file to the Arduino board.  The response by the Arduino is to follow the command input and print response data out to the terminal, which is sent to the log file.&lt;br /&gt;
&lt;br /&gt;
If your brain just got scrambled, join the club.  There were several technical hurdles I was concerned about as soon as I thought of this method.  I did not even think this would work at first, but it turns out to function just fine. (Until Further Notice! `,~)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In this diagram you will find the basic idea behind the method. This diagram is based on the example I provide below.&lt;br /&gt;
&lt;br /&gt;
[[Image:Arduino_Com_diagram.jpg | 400px]]&lt;br /&gt;
&lt;br /&gt;
== Requirements ==&lt;br /&gt;
&lt;br /&gt;
'''The method requires the following hardware/knowledge:'''&lt;br /&gt;
&lt;br /&gt;
* An Arduino Board or equivalent &lt;br /&gt;
* Linux computer that is able to communicate with the Arduino &lt;br /&gt;
* Your favorite development language &lt;br /&gt;
* Basic Linux operational skill&lt;br /&gt;
* Knowledge of ''samba'' or ''NFS'' if networking is desired &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''This example requires the following hardware/knowledge:'''&lt;br /&gt;
&lt;br /&gt;
* An Arduino Board or equivalent (I used an actual Arduino Board with the USB connection)&lt;br /&gt;
* Linux computer that is able to communicate with the Arduino (I used an Ubuntu 8.x box)&lt;br /&gt;
* A Windows computer that is able to support AutoIT (I used an XP box)&lt;br /&gt;
* A network between the two computers&lt;br /&gt;
* Development languages - BASH scripting for Linux and AutoIT for windows&lt;br /&gt;
* Knowledge of ''samba'' for sharing folders over the network&lt;br /&gt;
&lt;br /&gt;
== Example of Method ==&lt;br /&gt;
=== Quick Guide: ===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Step 1 -''' Buy an Arduino Board - http://www.arduino.cc/en/Main/Buy&lt;br /&gt;
&lt;br /&gt;
'''Step 2 -''' Load the Arduino software on your linux box - http://www.arduino.cc/playground/Learning/Linux&lt;br /&gt;
               &lt;br /&gt;
'''Step 3 -''' Load the sample Arduino code (see Step 3 below) into your Arduino board - http://www.arduino.cc/en/Guide/HomePage&lt;br /&gt;
&lt;br /&gt;
'''Step 4 -''' Create a Folder on the Linux box and share the Folder over the network using ''samba'' - http://us1.samba.org/samba/&lt;br /&gt;
&lt;br /&gt;
'''Step 5 -''' Compile the Arduino-Serial software and place the executable in the shared folder from Step 4 - http://todbot.com/blog/2006/12/06/arduino-serial-c-code-to-talk-to-arduino/&lt;br /&gt;
&lt;br /&gt;
'''Step 6 -''' Load the sample BASH scripting text (see Step 6 below) into an executable file in your shared folder from Step 4 on the Linux box - http://www.gnu.org/software/bash/&lt;br /&gt;
&lt;br /&gt;
'''Step 7 -''' Build your Thermistor circuit based on the diagram (see Step 7 below) or something similar&lt;br /&gt;
&lt;br /&gt;
'''Step 8 -''' Map your 'samba' shared folder on your linux box to a windows drive &lt;br /&gt;
&lt;br /&gt;
'''Step 9 -''' Load AutoIT on your windows box - http://www.autoitscript.com/autoit3/&lt;br /&gt;
&lt;br /&gt;
'''Step 10 -''' Use the sample AutoIT script (see Step 10 below) to test the solution&lt;br /&gt;
&lt;br /&gt;
'''Step 11 -''' Revel in your new found capability to conquer the world, well the Arduino world anyway! `,~)&lt;br /&gt;
=== Detailed Guide: ===&lt;br /&gt;
&lt;br /&gt;
==== Step 1 ====&lt;br /&gt;
'''Buy an Arduino Board - ''' There are lots of options to buy a board. I chose the standard USB version from the guidance of this [http://www.arduino.cc/en/Main/Buy Arduino link]. If you follow this [http://www.freeduino.org/buy.html Freeduino link] you will find many options including my favorite the Bare Bones Board from [http://moderndevice.com/ moderndevice.com] and [http://wulfden.org/freeduino/freeduino.shtml wulfden.com].  Check out the [http://www.moderndevice.com/RBBB_revB.shtml RBBB assembly]. These options are super cheap and I will definitely be buying my next Arduino based board from these sites.  These folks have knocked down the price of micro-controller development boards.&lt;br /&gt;
==== Step 2 ====&lt;br /&gt;
'''Load the Arduino software on your linux box - ''' Here are the [http://www.arduino.cc/playground/Learning/Linux Linux Instructions]. For my Arduino, I used Ubuntu 8.x.  I also recommend you do a google search of Arduino and your linux type to find any type of specific hiccups that inevitably find there way into installs.  The Ubuntu instuctions I ended up using was from [http://principialabs.com/running-arduino-on-ubuntu/ principialabs.com] and after all was said and done these instructions worked without a single problem for me.&lt;br /&gt;
&lt;br /&gt;
==== Step 3 ====&lt;br /&gt;
''' Load the sample Arduino code into your Arduino board - ''' Here is the code I used.  I will not claim it to be pretty, but it does work as a test for this method. Most likely you will have to modify some of the numbers around the input.  I will give you my schematic, but I am sure that your set up will vary somewhat and that will change the Threshold and Voltage reading numbers.&lt;br /&gt;
&lt;br /&gt;
 /*&lt;br /&gt;
 * AnalogInput with Thermistor&lt;br /&gt;
 * by DojoDave &amp;lt;http://www.0j0.org&amp;gt; and John Vaughters &amp;lt;http://www.combustory.com&amp;gt;&lt;br /&gt;
 *&lt;br /&gt;
 * Turns on a light emitting diode(LED) connected to digital  &lt;br /&gt;
 * pin 13 when the temperature rises above the threshold. The value obtained by analogRead(). &lt;br /&gt;
 * In the easiest case we connect a thermistor to analog pin 5.  The program also implements a &lt;br /&gt;
 * Serial Communication method that utilizes a char and a # ie. A0...A9, B0...B9, etc. Each Command will implement &lt;br /&gt;
 * a specific action in the Arduino.&lt;br /&gt;
 * &lt;br /&gt;
 */ &lt;br /&gt;
 int tempPin = 5;    // select the input pin for the Thermistor&lt;br /&gt;
 int ledPin = 13;   // select the pin for the LED&lt;br /&gt;
 int val = 0;       // variable to store the value coming from the sensor&lt;br /&gt;
 int THRESHOLD = 580;&lt;br /&gt;
 int statePin = HIGH;  // variable used to store the last LED status, to toggle the light&lt;br /&gt;
 int command = 0;       // This is the command char, in ascii form, sent from the serial port     &lt;br /&gt;
 long polTime = 1000;  // The time to Pol the tempPin&lt;br /&gt;
 long previousMillis = 0;        // will store last time Temp was updated&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 void setup() {&lt;br /&gt;
   Serial.begin(57600);&lt;br /&gt;
   pinMode(ledPin, OUTPUT);  // declare the ledPin as an OUTPUT&lt;br /&gt;
   pinMode(12, OUTPUT);      // Test Com Reset issue  &lt;br /&gt;
   digitalWrite(12,HIGH);&lt;br /&gt;
   delay(5000);&lt;br /&gt;
   digitalWrite(12,LOW);&lt;br /&gt;
 } &lt;br /&gt;
 &lt;br /&gt;
 void loop() {&lt;br /&gt;
   if (millis() - previousMillis &amp;gt; polTime) {&lt;br /&gt;
     previousMillis = millis();   // remember the last time&lt;br /&gt;
     val = analogRead(tempPin);    // read the value from the sensor&lt;br /&gt;
      if (val &amp;gt;= THRESHOLD) {&lt;br /&gt;
       //statePin = !statePin;           // toggle the status of the ledPin (this trick doesn't use time cycles)&lt;br /&gt;
       digitalWrite(ledPin, statePin); // turn the led on or off&lt;br /&gt;
       Serial.print(&amp;quot;~@ Hot &amp;quot;);          // send the string &amp;quot;Hot&amp;quot; back to the computer, followed by newline&lt;br /&gt;
       Serial.print(&amp;quot;Temp = &amp;quot;);&lt;br /&gt;
       Serial.println(val);           // &lt;br /&gt;
      }&lt;br /&gt;
     else {&lt;br /&gt;
       digitalWrite(ledPin, LOW);&lt;br /&gt;
     }&lt;br /&gt;
     if (Serial.available()) {      // Look for char in serial que and process if found&lt;br /&gt;
       command = Serial.read();&lt;br /&gt;
       if (command == 84) {          // If command = &amp;quot;T&amp;quot; print the Temp&lt;br /&gt;
         Serial.print(&amp;quot;~&amp;amp; Temp = &amp;quot;);&lt;br /&gt;
         Serial.print(val);           // &lt;br /&gt;
         Serial.print(&amp;quot; &amp;quot;);&lt;br /&gt;
         delay(100);&lt;br /&gt;
       }&lt;br /&gt;
       else if (command == 67) {      //If command = &amp;quot;C&amp;quot; Change Temp Threshhold&lt;br /&gt;
         if (Serial.available()) {&lt;br /&gt;
           command = Serial.read();&lt;br /&gt;
           if (command &amp;gt; 47 &amp;amp;&amp;amp; command &amp;lt; 58) {          // If command is between 0-9 Increment the Threshold by number sent&lt;br /&gt;
             THRESHOLD += command - 48;                 // ASII math to get value sent   &lt;br /&gt;
                   Serial.print(&amp;quot;~# THRESHOLD = &amp;quot;);&lt;br /&gt;
                   Serial.print(THRESHOLD);           // &lt;br /&gt;
                   Serial.print(&amp;quot; &amp;quot;);&lt;br /&gt;
                   delay(100);&lt;br /&gt;
           }  &lt;br /&gt;
         }  &lt;br /&gt;
       }&lt;br /&gt;
       else if (command == 68) {      //If command = &amp;quot;D&amp;quot; Change Temp Threshhold&lt;br /&gt;
         if (Serial.available()) {&lt;br /&gt;
           command = Serial.read();&lt;br /&gt;
           if (command &amp;gt; 47 &amp;amp;&amp;amp; command &amp;lt; 58) {          // If command is between 0-9 Decrement the Threshold by number sent&lt;br /&gt;
             THRESHOLD -= command - 48;                 // ASII math to get value sent   &lt;br /&gt;
                   Serial.print(&amp;quot;~# THRESHOLD = &amp;quot;);&lt;br /&gt;
                   Serial.print(THRESHOLD);           // &lt;br /&gt;
                   Serial.print(&amp;quot; &amp;quot;);&lt;br /&gt;
                   delay(100);&lt;br /&gt;
           }  &lt;br /&gt;
         }  &lt;br /&gt;
       }&lt;br /&gt;
       delay(100);&lt;br /&gt;
       Serial.println(command);     // Echo command char found in serial que&lt;br /&gt;
       command = 0;                 // reset command &lt;br /&gt;
     }&lt;br /&gt;
   }&lt;br /&gt;
 }&lt;br /&gt;
 //*****************************************************The End***********************&lt;br /&gt;
==== Step 4 ====&lt;br /&gt;
''' Create a Folder on the Linux box and share the Folder over the network using ''samba'' - '''  There is not much to say here other than learn your ''samba'' and make it happen.  There are literally tons of info on this subject on the web. Other than that make sure that the permissions are set on the shared folder to allow creating and writing files.&lt;br /&gt;
&lt;br /&gt;
==== Step 5 ====&lt;br /&gt;
''' Compile the Arduino-Serial software and place the executable in the shared folder from Step 4 - ''' This step gave me a little bit of an issue. I had to comment out a few baud speed lines.  It was not that difficult to figure out, because the compiler gave pretty clear error messages and these [http://todbot.com/blog/2006/12/06/arduino-serial-c-code-to-talk-to-arduino/  Arduino-Serial] instructions even mentioned this as an issue and even though it is mentioned and supposedly fixed, there is still one more line he did not comment out. Make sure any line that looks like this:&lt;br /&gt;
&lt;br /&gt;
 case 28800:  brate=B28800;  break;  &lt;br /&gt;
&lt;br /&gt;
Looks like this:&lt;br /&gt;
&lt;br /&gt;
 //case 28800:  brate=B28800;  break;&lt;br /&gt;
&lt;br /&gt;
==== Step 6 ====&lt;br /&gt;
''' Load the sample BASH scripting text into an executable file in your shared folder from Step 4 on the Linux box - ''' Here is the BASH script.  It is a script that goes into an infinite loop and constantly polls for two files, a ''command'' file and a ''clear_log'' file.  When it sees those files it takes action to either send commands or clear the log file.  The files are sent from some other application that are used to control the communication to the Arduino.  In this example I use AutoIT as the controlling software (See Step 9).  I will leave it to the reader to decode these commands.  &lt;br /&gt;
&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
 # File name CommandPoll&lt;br /&gt;
 # This Script is used to control the communication to an Arduino board via the Arduino-Serial command line utility and the dev/ttyUSB0 terminal&lt;br /&gt;
 # Written by John Vaughters &amp;lt;http://www.combustory.com&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
 # Set the terminal to match the Arduino Serial Communications&lt;br /&gt;
 stty -F /dev/ttyUSB0 cs8 57600 ignbrk -brkint -icrnl -imaxbel -opost -onlcr -isig -icanon -iexten -echo -echoe -echok -echoctl -echoke noflsh -ixon -crtscts&lt;br /&gt;
 &lt;br /&gt;
 # Kill any existing tail commands logging the terminal&lt;br /&gt;
 exec  ps ax | grep &amp;quot;tail -f /dev/ttyUSB0&amp;quot; | grep ? | awk '{system(&amp;quot;kill &amp;quot; $1)}'&lt;br /&gt;
 # Connect the terminal to a tail logging to a file by appending&lt;br /&gt;
 exec tail -f /dev/ttyUSB0 &amp;gt;&amp;gt; /home/jvaughters/arduino-0011/sketchbook/ArduinoSerial/arduino_log &amp;amp;&lt;br /&gt;
 &lt;br /&gt;
 # create an infinite loop to test for files that will prompt action&lt;br /&gt;
 while [ 1 ]&lt;br /&gt;
 do&lt;br /&gt;
   if [ -f command ] 								     # Does the command file exist&lt;br /&gt;
     then&lt;br /&gt;
     cat command | awk '{system(&amp;quot;./arduino-serial -b 57600 -p /dev/ttyUSB0 -s &amp;quot; $1)}' # Send the commands in the command file via Arduino-Serial utility&lt;br /&gt;
     rm command									     # remove the command file&lt;br /&gt;
   fi&lt;br /&gt;
   if [ -f clear_log ] 								     # Does the clear_log file exist&lt;br /&gt;
     then&lt;br /&gt;
     echo &amp;gt; arduino_log&lt;br /&gt;
     rm clear_log&lt;br /&gt;
   fi&lt;br /&gt;
   if [ -f exit_poll ] 								     # Does the exit_poll file exist&lt;br /&gt;
     then&lt;br /&gt;
     # Kill any tail commands logging the terminal&lt;br /&gt;
     exec  ps ax | grep &amp;quot;tail -f /dev/ttyUSB0&amp;quot; | grep ? | awk '{system(&amp;quot;kill &amp;quot; $1)}'&lt;br /&gt;
     rm exit_poll                                                                 &lt;br /&gt;
     exit 0                                                                          # Exit CommandPoll script   &lt;br /&gt;
   fi&lt;br /&gt;
   sleep 1 									     # Sleep for one second or your processor will run 100% (optional)&lt;br /&gt;
 done&lt;br /&gt;
 exit 0&lt;br /&gt;
&lt;br /&gt;
==== Step 7 ====&lt;br /&gt;
''' Build your Thermistor and LED circuits based on the diagrams or something similar - ''' That's it, just follow the diagrams or create a comparable solution. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:arduino_com_circuit.jpg]]&lt;br /&gt;
&lt;br /&gt;
==== Step 8 ====&lt;br /&gt;
''' Map your ''samba'' linux shared folder to a windows drive - ''' For this example you have to map a drive on your windows box.  I think I will leave the details on how to accomplish this task to a google search on mapping drives in windows. It is fairly straight forward. I mapped my drive to P: for no particular reason, but what ever you map it to, you will be able to select the drive from within the AutoIT GUI.&lt;br /&gt;
&lt;br /&gt;
==== Step 9 ====&lt;br /&gt;
''' Load AutoIT on your windows box - ''' Go to the [http://www.autoitscript.com/autoit3/ AutoIT] site and load this very powerful and free software.  This software has been around for a while and it has a fairly active development crew, which creates constant improvements, extensions and user libraries.  It is a very powerful GUI scripting tool and it is very easy to create a GUI application as well.  I have created many great utilities using this software. It is not for super powerful software needs, but with today's computers, it does quite a bit.  LOVE this tool.  &lt;br /&gt;
==== Step 10 ====&lt;br /&gt;
''' Use the sample AutoIT script to test the solution - ''' This code is a utility that will allow you to select the mapped shared windows drive/path and a working directory. There is a drop down menu with four commands that that will make the Arduino respond.  This program will create a ''command'' file, fill it with the command string and place it in the Network Dir. The Software will wait 5 seconds and then retrieve the results and place it in the text window. Then the program will place the ''clear_log'' file in the Network Dir. I will not cover the use of this software here, refer to the User Guide section.  For now just get this loaded into AutoIT and hit F5 to get it to run. You can run AutoIT programs interpreted or compiled. Pressing F5 runs it as interpreted.&lt;br /&gt;
&lt;br /&gt;
 ; Arduino Communications and Control&lt;br /&gt;
 ; File name: Arduino_Com_v.01.au3&lt;br /&gt;
 ; 31 Jul 2008 - John Vaughters &amp;lt;http://www.combustory.com&amp;gt;&lt;br /&gt;
 ; This is a Utility to Communicate with the Arduino Control board&lt;br /&gt;
 &lt;br /&gt;
 #include &amp;lt;GuiConstants.au3&amp;gt;&lt;br /&gt;
 #include &amp;lt;GuiEdit.au3&amp;gt; &lt;br /&gt;
 #include &amp;lt;file.au3&amp;gt;&lt;br /&gt;
 #include &amp;lt;Date.au3&amp;gt;&lt;br /&gt;
 #include &amp;lt;IE.au3&amp;gt; &lt;br /&gt;
  &lt;br /&gt;
 ;*************&lt;br /&gt;
 ;  _Load_Results() loads the temp file into the desired control then deletes the temp file&lt;br /&gt;
 ; $w_dir is the working directory where the file exists&lt;br /&gt;
 ; $ctl_to_load is the place to load the file contents&lt;br /&gt;
 ; $temp_file is the temporary file to load the data from&lt;br /&gt;
 ; The function returns the number of lines loaded from the file&lt;br /&gt;
 &lt;br /&gt;
 Func _Load_Results ($w_dir, $ctl_load_to, $temp_file)&lt;br /&gt;
 	Dim $aRecords&lt;br /&gt;
 	If Not _FileReadToArray($w_dir &amp;amp; $temp_file,$aRecords) Then&lt;br /&gt;
 			MsgBox(4096,&amp;quot;Error&amp;quot;, &amp;quot; Error reading log to Array     error:&amp;quot; &amp;amp; @error)&lt;br /&gt;
 			 Exit&lt;br /&gt;
 		EndIf&lt;br /&gt;
 		&lt;br /&gt;
 		For $x = 1 to $aRecords[0]&lt;br /&gt;
 			if StringLen($aRecords[$x]) &amp;gt; 0 then GuiCtrlSetData($ctl_load_to, $aRecords[$x] &amp;amp; @CRLF, 1)&lt;br /&gt;
 		Next&lt;br /&gt;
 		;Delete the temporary file&lt;br /&gt;
 		RunWait(@ComSpec &amp;amp; &amp;quot; /c &amp;quot; &amp;amp; &amp;quot;del &amp;quot; &amp;amp; $temp_file, $w_dir &amp;amp; &amp;quot;&amp;quot;,@SW_HIDE)&lt;br /&gt;
 		Return ($aRecords[0]-1)&lt;br /&gt;
 EndFunc&lt;br /&gt;
 &lt;br /&gt;
 ;Initialize Variable Defaults&lt;br /&gt;
 $working_dir = @DesktopDir &amp;amp; &amp;quot;\&amp;quot;&lt;br /&gt;
 $working_file = &amp;quot;arduino_log&amp;quot;&lt;br /&gt;
 $poll_delay = 5000                             ; This is the delay the program waits before collecting the command  results&lt;br /&gt;
 $network_dir = &amp;quot;P:\&amp;quot;                           ; Default network directory&lt;br /&gt;
 $process_results = False ;Processing Flag&lt;br /&gt;
 $command_get_begin = TimerInit() ;Initialize Timer&lt;br /&gt;
 ; GUI&lt;br /&gt;
 GuiCreate(&amp;quot; Arduino Communications and Control&amp;quot;, 700, 600)&lt;br /&gt;
 &lt;br /&gt;
 ; MENU &lt;br /&gt;
 $filemenu = GuiCtrlCreateMenu(&amp;quot;&amp;amp;File&amp;quot;)&lt;br /&gt;
 $fileitem = GUICtrlCreateMenuitem (&amp;quot;Open&amp;quot;,$filemenu)&lt;br /&gt;
 GUICtrlSetState(-1,$GUI_DEFBUTTON)&lt;br /&gt;
 $exititem = GUICtrlCreateMenuitem (&amp;quot;Exit&amp;quot;,$filemenu)&lt;br /&gt;
 $helpmenu = GuiCtrlCreateMenu(&amp;quot;Help&amp;quot;)&lt;br /&gt;
 $infoitem = GUICtrlCreateMenuitem (&amp;quot;Info&amp;quot;,$helpmenu)&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 ; LOGO PIC&lt;br /&gt;
 GuiCtrlCreatePic(&amp;quot;logo.jpg&amp;quot;,0,0, 100,140)&lt;br /&gt;
 &lt;br /&gt;
 ; AVI for letting the user know the system is processing&lt;br /&gt;
 $processing = GuiCtrlCreateAvi(&amp;quot;sampleAVI.avi&amp;quot;,0, 405, 140, 32, 32)&lt;br /&gt;
 &lt;br /&gt;
 ; Tabbed Result Window&lt;br /&gt;
 $tab_result_start_x = 20&lt;br /&gt;
 $tab_result_start_y = 175&lt;br /&gt;
 $tab_result_size_x = 650&lt;br /&gt;
 $tab_result_size_y = 400&lt;br /&gt;
 $tab_result_title_2 = &amp;quot;Command Results&amp;quot;&lt;br /&gt;
 $tab_result_title_4 = &amp;quot;Sys Info&amp;quot;&lt;br /&gt;
 GuiCtrlCreateTab($tab_result_start_x, $tab_result_start_y, $tab_result_size_x , $tab_result_size_y)&lt;br /&gt;
 GuiCtrlCreateTabItem($tab_result_title_2)&lt;br /&gt;
 $edit_ctl_tab2 = GuiCtrlCreateEdit(@CRLF &amp;amp; &amp;quot;&amp;quot;, $tab_result_start_x + 10 , $tab_result_start_y + 40, $tab_result_size_x - 20, $tab_result_size_y - 50)&lt;br /&gt;
 GuiCtrlCreateTabItem($tab_result_title_4)&lt;br /&gt;
 $edit_ctl_tab4 = GuiCtrlCreateEdit(@CRLF &amp;amp; &amp;quot;&amp;quot;, $tab_result_start_x + 10 , $tab_result_start_y + 40, $tab_result_size_x - 20, $tab_result_size_y - 50)&lt;br /&gt;
 GuiCtrlCreateTabItem(&amp;quot;&amp;quot;)&lt;br /&gt;
 &lt;br /&gt;
 ; Combo Arduino Command File Type&lt;br /&gt;
 $combo_ctl_search_file = GuiCtrlCreatecombo(&amp;quot;*&amp;quot;, 240, 145, 120, 100)&lt;br /&gt;
 GUICtrlSetData(-1,&amp;quot;C5|D5|T1|&amp;quot;,&amp;quot;C5&amp;quot;) ; add other item snd set a new default&lt;br /&gt;
 GuiCtrlCreateLabel(&amp;quot;Arduino Command&amp;quot;, 245, 170, 150, 20)&lt;br /&gt;
 &lt;br /&gt;
 ; Current Working Directory Label&lt;br /&gt;
 $combo_ctl_working_dir = GuiCtrlCreateLabel($working_dir, 240, 80, 450, 22,$WS_DLGFRAME)&lt;br /&gt;
 GUICtrlSetBkColor(-1,0xffffff)&lt;br /&gt;
 GuiCtrlCreateLabel(&amp;quot;Working Directory&amp;quot;, 245, 105, 200, 20)&lt;br /&gt;
 &lt;br /&gt;
 ; Current Network Directory Label&lt;br /&gt;
 $combo_ctl_network_dir = GuiCtrlCreateLabel($network_dir, 240, 20, 450, 22,$WS_DLGFRAME)&lt;br /&gt;
 GUICtrlSetBkColor(-1,0xffffff)&lt;br /&gt;
 GuiCtrlCreateLabel(&amp;quot;Network Directory&amp;quot;, 245, 45, 200, 20)&lt;br /&gt;
 &lt;br /&gt;
 ; BUTTON&lt;br /&gt;
 $search_btn = GuiCtrlCreateButton(&amp;quot;Go&amp;quot;, 370, 143, 25, 25)&lt;br /&gt;
 $file_btn = GuiCtrlCreateButton(&amp;quot;Working Dir&amp;quot;, 125, 77, 100, 25)&lt;br /&gt;
 $network_btn = GuiCtrlCreateButton(&amp;quot;Network Dir&amp;quot;, 125, 18, 100, 25)&lt;br /&gt;
 $site_btn = GuiCtrlCreateButton(&amp;quot;www.combustory.com&amp;quot;, 0, 145, 135, 22)&lt;br /&gt;
 $clear_btn = GuiCtrlCreateButton(&amp;quot;Clear&amp;quot;, 620, 170, 50, 22)&lt;br /&gt;
 &lt;br /&gt;
 ; List System Info&lt;br /&gt;
 GuiCtrlSetData($edit_ctl_tab4, &amp;quot;Computer:             &amp;quot; &amp;amp; @CRLF &amp;amp; _&lt;br /&gt;
 								&amp;quot;----------------------------------------------------------&amp;quot; &amp;amp; @CRLF &amp;amp; _&lt;br /&gt;
 								&amp;quot;IP Address:             &amp;quot; &amp;amp; @IPAddress1 &amp;amp; @CRLF &amp;amp; _&lt;br /&gt;
 								&amp;quot;Computer Name:     &amp;quot; &amp;amp; @ComputerName &amp;amp; @CRLF &amp;amp; _&lt;br /&gt;
    								&amp;quot;OS:                         &amp;quot; &amp;amp; @OSVersion &amp;amp; @CRLF &amp;amp; _&lt;br /&gt;
 								&amp;quot;Sys Dir:                   &amp;quot; &amp;amp; @SystemDir &amp;amp; @CRLF &amp;amp; @CRLF)&lt;br /&gt;
 ; GUI MESSAGE LOOP&lt;br /&gt;
 GuiSetState()&lt;br /&gt;
 &lt;br /&gt;
 ; Main Event Loop&lt;br /&gt;
 While 1&lt;br /&gt;
   ; After every loop check if the user clicked something in the GUI window&lt;br /&gt;
    $msg = GUIGetMsg()&lt;br /&gt;
     if $process_results = True Then&lt;br /&gt;
 		if $poll_delay &amp;lt; TimerDiff($command_get_begin) Then&lt;br /&gt;
 			RunWait(@ComSpec &amp;amp; &amp;quot; /c &amp;quot; &amp;amp; &amp;quot;type arduino_log&amp;gt;results.txt&amp;quot;, $network_dir,@SW_HIDE)&lt;br /&gt;
 			; Load command results into Command Results tab&lt;br /&gt;
 			GuiCtrlSetData($edit_ctl_tab2, &amp;quot;------------------------------------------------------------------&amp;quot; &amp;amp; @CRLF,1)&lt;br /&gt;
 			GuiCtrlSetData($edit_ctl_tab2, &amp;quot;Command:  &amp;quot; &amp;amp; GUICtrlRead($combo_ctl_search_file) &amp;amp; @CRLF,1)&lt;br /&gt;
 			GuiCtrlSetData($edit_ctl_tab2, &amp;quot;Results:  &amp;quot; &amp;amp; @CRLF,1)&lt;br /&gt;
 			_Load_Results ($network_dir, $edit_ctl_tab2, &amp;quot;results.txt&amp;quot;)&lt;br /&gt;
 			GuiCtrlSetData($edit_ctl_tab2, &amp;quot;******************************************************************&amp;quot; &amp;amp; @CRLF,1)&lt;br /&gt;
 			$process_results = False&lt;br /&gt;
 			RunWait(@ComSpec &amp;amp; &amp;quot; /c &amp;quot; &amp;amp; &amp;quot;echo&amp;gt;clear_log&amp;quot;, $network_dir,@SW_HIDE) ; Send message to Linux polling script to clear the log&lt;br /&gt;
 			GUICtrlSetState ($processing, 0)&lt;br /&gt;
 		EndIf&lt;br /&gt;
 	EndIf	&lt;br /&gt;
    Select&lt;br /&gt;
    &lt;br /&gt;
     ; Check if user clicked on the close button &lt;br /&gt;
 	Case $msg = $GUI_EVENT_CLOSE Or $msg = $exititem&lt;br /&gt;
         ; Destroy the GUI including the controls&lt;br /&gt;
          GUIDelete()&lt;br /&gt;
        ; Exit the script&lt;br /&gt;
          Exit&lt;br /&gt;
          &lt;br /&gt;
 	; Check if user clicked on the File Open button&lt;br /&gt;
 	Case $msg = $fileitem&lt;br /&gt;
 		$working_dir = FileSelectFolder(&amp;quot;Choose Folder...&amp;quot;,&amp;quot;&amp;quot;,4,&amp;quot;&amp;quot;) &amp;amp; &amp;quot;\&amp;quot;&lt;br /&gt;
 		GuiCtrlSetData($combo_ctl_working_dir, $working_dir)&lt;br /&gt;
 	&lt;br /&gt;
 	; Check if user clicked on the Help Info button&lt;br /&gt;
 	Case $msg = $infoitem&lt;br /&gt;
 		MsgBox(64, &amp;quot;Info&amp;quot;, &amp;quot;Arduino Communications Control v0.1&amp;quot; &amp;amp; @CRLF &amp;amp; &amp;quot;By: John Vaughters&amp;quot;)&lt;br /&gt;
 	&lt;br /&gt;
 	; Check if user clicked on the &amp;quot;File&amp;quot; button&lt;br /&gt;
 	Case $msg = $file_btn&lt;br /&gt;
 		$working_dir = FileSelectFolder(&amp;quot;Choose Folder...&amp;quot;,&amp;quot;&amp;quot;,4,&amp;quot;&amp;quot;) &amp;amp; &amp;quot;\&amp;quot;&lt;br /&gt;
 		GuiCtrlSetData($combo_ctl_working_dir, $working_dir)&lt;br /&gt;
 			&lt;br /&gt;
 	Case $msg = $network_btn&lt;br /&gt;
 		$network_dir = FileSelectFolder(&amp;quot;Choose Folder...&amp;quot;,&amp;quot;&amp;quot;,4,&amp;quot;&amp;quot;) &amp;amp; &amp;quot;\&amp;quot;&lt;br /&gt;
 		GuiCtrlSetData($combo_ctl_network_dir, $network_dir)&lt;br /&gt;
 &lt;br /&gt;
 	Case $msg = $search_btn&lt;br /&gt;
 		&lt;br /&gt;
 		; Start processing AVI &lt;br /&gt;
 		GUICtrlSetState ($processing, 1)&lt;br /&gt;
 		&lt;br /&gt;
 		$file = FileOpen($working_dir &amp;amp; &amp;quot;command&amp;quot;, 2)&lt;br /&gt;
 		; Check if file opened for reading OK&lt;br /&gt;
 		If $file = -1 Then&lt;br /&gt;
 			MsgBox(0, &amp;quot;Error&amp;quot;, &amp;quot;Unable to open file.&amp;quot;)&lt;br /&gt;
 			Exit&lt;br /&gt;
 		EndIf&lt;br /&gt;
 		&lt;br /&gt;
 		; Set File Type&lt;br /&gt;
 		$working_file = GUICtrlRead($combo_ctl_search_file)&lt;br /&gt;
 		FileWrite($file, $working_file)&lt;br /&gt;
 		FileClose($file)  ; The File must be closed before you can copy it anywhere&lt;br /&gt;
 		RunWait(@ComSpec &amp;amp; &amp;quot; /c &amp;quot; &amp;amp; &amp;quot;copy command &amp;quot; &amp;amp; $network_dir, $working_dir,@SW_HIDE)&lt;br /&gt;
 		$command_get_begin = TimerInit() ;Start the timer until you can retrieve your results&lt;br /&gt;
 		$process_results = True ; Set Processing flag&lt;br /&gt;
 			&lt;br /&gt;
 		&lt;br /&gt;
 	Case $msg = $site_btn&lt;br /&gt;
 		_IECreate (&amp;quot;www.combustory.com&amp;quot;)&lt;br /&gt;
 		&lt;br /&gt;
 	Case $msg = $clear_btn&lt;br /&gt;
 		_GUICtrlEdit_SetSel ($edit_ctl_tab2, 0, -1) &lt;br /&gt;
 		_GUICtrlEdit_ReplaceSel ($edit_ctl_tab2, &amp;quot;&amp;quot;)&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
    EndSelect&lt;br /&gt;
 &lt;br /&gt;
 WEnd&lt;br /&gt;
&lt;br /&gt;
==== Step 11 ====&lt;br /&gt;
''' Put all the steps together and see if it works - ''' Well ok! I deviated from the quick guide, but if you follow this step and it WORKS! then you can revel. `,~)  Now we just want to get it all to work.  Check list of things that need to be in place:&lt;br /&gt;
* Make sure the Arduino is plugged into the linux box and that the Serial monitor on the Arduino environment is not connected&lt;br /&gt;
* Make sure you have loaded the Arduino program from Step 3&lt;br /&gt;
* Now you are ready to start the ''CommandPoll'' script from Step 6&lt;br /&gt;
* Make sure your Windows box can browse to the mapped drive and you can see the files on your linux box&lt;br /&gt;
* Start the ''Arduino_Com_v.01.au3'' program by pressing F5 and set the Network Dir to your mapped drive&lt;br /&gt;
* Change the Working Dir if you do not want to use the Desktop (optional)&lt;br /&gt;
* Now click the GO button and see if you get a response (it takes about 5 sec to respond)&lt;br /&gt;
&lt;br /&gt;
'''If all goes well it will look something like this:'''&lt;br /&gt;
&lt;br /&gt;
[[Image:arduino_com_pic_1.jpg]]&lt;br /&gt;
&lt;br /&gt;
== ''PollCommand'' User Guide ==&lt;br /&gt;
There is not much involved with the operation of this script. It basically looks for three files in the directory where it is started and responds to the existence of the file.&lt;br /&gt;
==== Requirements ====&lt;br /&gt;
This script requires that the ''Arduino-Serial'' program be compiled and in the same directory as the ''PollCommand'' script.&lt;br /&gt;
==== ''command'' file ====&lt;br /&gt;
When a ''command'' file is found in the directory, the script will send the contents of the file using the Arduino-Serial command to /dev/ttyUSB0. After the ''command'' file is sent, the script deletes the file. The basic usage is to copy a ''command'' file into the directory to be processed.&lt;br /&gt;
&lt;br /&gt;
==== ''clear_log'' file ====&lt;br /&gt;
When a ''clear_log'' file is found in the directory it will clear the ''arduino_log'' file and then delete the ''clear_log'' file. The basic usage is to copy a ''clear_log'' file into the directory to be processed.&lt;br /&gt;
==== ''exit_poll'' file ====&lt;br /&gt;
When an ''exit_poll'' file is found in the directory it will close the ''tail'' process, delete the ''exit_poll'' file and then exit the script. The basic usage is to copy an ''exit_poll'' file into the directory to be processed.&lt;br /&gt;
&lt;br /&gt;
== Arduino_Com_v.01 User Guide ==&lt;br /&gt;
&lt;br /&gt;
==== Network Dir ====&lt;br /&gt;
This is the place where you must find the Windows mapped drive and path to the folder where you placed the Arduino files on the Linux box. This location is where the ''PollCommand'' script is constantly polling for a command or clear_log file and this is where the the arduino_log file is located.&lt;br /&gt;
==== Working Dir ====&lt;br /&gt;
This particular path is fairly useless and you should be able to leave it as the desktop.  All that happens here is that a results file is created until it is read into the Arduino_Com_v.01 software and then it is deleted.  &lt;br /&gt;
==== Arduino Command ====&lt;br /&gt;
''Basic Commands - ''The Arduino Commands data box is set up as a drop down menu with the pre-filled commands, but you can put whatever command you want in the box and then press the GO button to send the command. The commands are worth further explanation.  The following commands will make the Arduino respond:&lt;br /&gt;
* C - will increment the Threshold value by the second digit. So a C5 will increment the Threshold by 5 points and a C9 will increment the Threshold by 9 points, and so on.  If the second Character after the C is not a number, it will not increment the Threshold. The C command also prints out the Current Threshold value.&lt;br /&gt;
* D - will decrement the Threshold value by the second digit. So a D5 will decrement the Threshold by 5 points and a D9 will decrement the Threshold by 9 points, and so on.  If the second Character after the D is not a number, it will not decrement the Threshold. The D command also prints out the Current Threshold value.&lt;br /&gt;
* T - will take a measurement of the current temperature and print out the current Temperature. A plain T will work without any second character. &lt;br /&gt;
&lt;br /&gt;
All other commands are ignored by the Arduino, but you will get a result of the ascii values of any characters you send to the Arduino. A nice little ascii converter that came in handy when programming.  Also you will notice several preceding characters and the last ascii character of each the command printed. These were for my testing and further development purposes.&lt;br /&gt;
&lt;br /&gt;
''Stacking Commands - '' You are also able to stack the commands together and they will be processed as individual commands. &lt;br /&gt;
&lt;br /&gt;
For instance this command:&lt;br /&gt;
 C5TD5&lt;br /&gt;
will result with:&lt;br /&gt;
 ------------------------------------------------------------------&lt;br /&gt;
 Command:  C5TD5&lt;br /&gt;
 Results:  &lt;br /&gt;
 ~# THRESHOLD = 585 53&lt;br /&gt;
 ~&amp;amp; Temp = 520 84&lt;br /&gt;
 ~# THRESHOLD = 580 53&lt;br /&gt;
 ******************************************************************&lt;br /&gt;
There can be no spaces in the commands. The command will only interpret the characters before the first space.&lt;br /&gt;
&lt;br /&gt;
==== Command Results ====&lt;br /&gt;
This text box is where the results of your command will be loaded. There is also a result that will occur when the Temperature exceeds the threshold. This is something I was playing around with on how to handle alarms from the Arduino.  So for this alarm you will get the results at the next command sent. &lt;br /&gt;
&lt;br /&gt;
For instance the following result was given after the T command was sent:&lt;br /&gt;
&lt;br /&gt;
 ------------------------------------------------------------------&lt;br /&gt;
 Command:  T&lt;br /&gt;
 Results:  &lt;br /&gt;
 ~@ Hot Temp = 580&lt;br /&gt;
 ~@ Hot Temp = 580&lt;br /&gt;
 ~@ Hot Temp = 580&lt;br /&gt;
 ~@ Hot Temp = 580&lt;br /&gt;
 ~@ Hot Temp = 580&lt;br /&gt;
 ~&amp;amp; Temp = 577 84&lt;br /&gt;
 ******************************************************************&lt;br /&gt;
This indicated that the threshold had been exceeded prior to the T command, and the Hot Temp alarms had been previously printed.  &lt;br /&gt;
==== Sys Info ====&lt;br /&gt;
This Tab in the results location is just a typical text box I create for some basic info about the computer. &lt;br /&gt;
==== Clear ====&lt;br /&gt;
The Clear button will clear the Command Results text box and only the command results box.&lt;br /&gt;
&lt;br /&gt;
== Troubleshooting ==&lt;br /&gt;
=== Summary ===&lt;br /&gt;
When Troubleshooting a multi-functional issue, it is best practice to break down the issue into pieces and test each piece as a separate system.  However, we will first run through a quick test to see if we can find any obvious issues first.&lt;br /&gt;
=== Quick Test ===&lt;br /&gt;
* '''Make sure the ''CommandPoll'' script is running - '''From the linux box, open up a terminal window and run the following command.&lt;br /&gt;
  ps ax | grep PollCommand&lt;br /&gt;
You should get a result similar to this if the ''CommandPoll'' script is running:&lt;br /&gt;
 11763 ?        S      0:00 /bin/bash /home/jvaughters/arduino-0011/sketchbook/ArduinoSerial/PollCommand&lt;br /&gt;
 11777 pts/0    S+     0:00 grep PollCommand&lt;br /&gt;
If it is not running you will only get:&lt;br /&gt;
 11777 pts/0    S+     0:00 grep PollCommand&lt;br /&gt;
If that is your result, then start the ''PollCommand'' script.  I prefer to start it from an Xwindow by double clicking and then clicking RUN.&lt;br /&gt;
&lt;br /&gt;
* '''Make sure the ''tail'' command is running as a process - '''From the terminal window type the following command.&lt;br /&gt;
  ps ax | grep tail&lt;br /&gt;
You should get a result similar to this if the ''tail'' command is running:&lt;br /&gt;
 11770 ?        S      0:00 tail -f /dev/ttyUSB0&lt;br /&gt;
 12312 pts/0    S+     0:00 grep tail&lt;br /&gt;
If it is not running you will only get:&lt;br /&gt;
 12312 pts/0    S+     0:00 grep tail&lt;br /&gt;
If ''PollCommand'' is running and ''tail'' is not, then we have a bigger problem that will need to be investigated. &lt;br /&gt;
&lt;br /&gt;
* '''Make sure your Arduino is using the /dev/ttyUSB0 terminal - '''  To check this open up your Arduino programming environment and go to the ''Tools&amp;gt;Serial Port'' menu and check for the /dev/ttyUSB0 entry. If it is not there then the best way to find out what serial port your system is using is to unplug the USB cable and then check the the ''Tools&amp;gt;Serial Port'' menu again, and one of the ports should have disappeared. Now put it back and look to see which new port is added.  I the port is different then /dev/ttyUSB0 then you need to replace it with your device path in every location of the ''PollCommand'' script.&lt;br /&gt;
&lt;br /&gt;
* '''Make sure your ''samba'' folder is shared and writable from windows - '''From your windows box browse to the ''samba'' shared drive and verify that you can copy a small file to that shared drive from windows. Also, make sure you have mapped the shared folder in windows to a drive and that you can browse and copy a file to that  drive as well.  If you cannot copy the small file to the shared drive, then check your folder permissions in linux as well as any possible restrictions in ''samba''.&lt;br /&gt;
=== Isolating the Problem ===&lt;br /&gt;
If everything checked out in the Quick Test and you are still having trouble getting results, then you probably need to isolate and test the individual components of the system.&lt;br /&gt;
==== Linux Server ====&lt;br /&gt;
On the Linux box we just want to make sure that we can get the ''PollCommand'' script to accomplish it's tasks.  Below we break down each part of the script and test them individually. Each test is somewhat successive, so I recommend starting from the top and working down.&lt;br /&gt;
===== Arduino Communication =====&lt;br /&gt;
Let's verify the communication between the Arduino and the linux box. We can do this from a nice utility in the Arduino programming environment called the Serial Monitor.  First we need to make sure the ''PollCommand'' script is not running.  Use this command to check:&lt;br /&gt;
&lt;br /&gt;
  ps ax | grep PollCommand&lt;br /&gt;
If you get a result similar to this, then the ''CommandPoll'' script is running:&lt;br /&gt;
 11763 ?        S      0:00 /bin/bash /home/jvaughters/arduino-0011/sketchbook/ArduinoSerial/PollCommand&lt;br /&gt;
 11777 pts/0    S+     0:00 grep PollCommand&lt;br /&gt;
If it is not running you will only get:&lt;br /&gt;
 11777 pts/0    S+     0:00 grep PollCommand&lt;br /&gt;
To stop the ''PollCommand'' script from running use this command in a terminal window and make sure you are in the same directory as the ''PollCommand'' script.&lt;br /&gt;
 touch exit_poll&lt;br /&gt;
This command will create the file ''exit_poll'' and the existence of that file will make the ''PollCommand'' script exit. Check again to make sure the ''PollCommand'' script is not running. Also make sure that there are no ''tail'' commands running using this command:&lt;br /&gt;
  ps ax | grep tail&lt;br /&gt;
You should get a result similar to this if the ''tail'' command is running:&lt;br /&gt;
 11770 ?        S      0:00 tail -f /dev/ttyUSB0&lt;br /&gt;
 12312 pts/0    S+     0:00 grep tail&lt;br /&gt;
If it is not running you will only get:&lt;br /&gt;
 12312 pts/0    S+     0:00 grep tail&lt;br /&gt;
To stop the ''tail'' commands from running try this command:&lt;br /&gt;
 ps ax | grep &amp;quot;tail -f&amp;quot; | awk '{system(&amp;quot;kill &amp;quot; $1)}'&lt;br /&gt;
This will kill all ''tail'' commands running, but unless you are using ''tail'' for some other reason it is safe to kill all the ''tail'' processes.&lt;br /&gt;
&lt;br /&gt;
Now that we have the ''PollCommand'' script and the ''tail'' commands stopped, we can start the Serial Monitor in the Arduino programming environment by clicking the upper left button. This will give you a window in the bottom of the environment that will allow you to send and receive data to the Arduino board. make sure the baud is set to 57600, because it defaults to 9600, and my example uses 57600. Now you can type in the SEND box and click SEND to send data to the Arduino. If you have properly downloaded my example program, then you should get responses to commands sent.  In the screen shot below I sent four commands: T, C5, D5, T (See description of commands in the User Guide section)&lt;br /&gt;
&lt;br /&gt;
[[Image:arduino_serial_monitor.png]]&lt;br /&gt;
&lt;br /&gt;
If you cannot get this to work, then change this line:&lt;br /&gt;
 Serial.begin(57600);&lt;br /&gt;
With this line in your Arduino program:&lt;br /&gt;
 Serial.begin(9600);&lt;br /&gt;
Now download the new program into the Arduino board, start the serial monitor again, and change the BAUD to 9600 and try the steps above again.  If 9600 works and the 57600 does NOT work, then you will need to change any 57600 text in the ''CommandPoll'' script to 9600. If that still does not work, then you have bigger problems and need to make sure your Arduino install was clean.&lt;br /&gt;
&lt;br /&gt;
===== ''arduino-serial'' Command Test =====&lt;br /&gt;
This step requires that you have successfully completed the Arduino Communications step above.  If you were able to communicate via the Serial Monitor, then the next step is to verify an ''arduino-Serial'' command works. Open a terminal window and make sure you are in the shared folders where all of you files for this example reside. You also need to have the Serial Monitor in the Arduino set up and responding to sent commands.  This time however, we will send the command from the command line in the terminal window using the ''arduino-serial'' command.  The result will pop up in the Serial Monitor screen just as if you sent it from the Serial Monitor. I like to have the terminal window side-by-side with the Arduino environment when I do this test. Try this command: (Note: change the 57600 to 9600 if you are using that BAUD)&lt;br /&gt;
&lt;br /&gt;
 ./arduino-serial -b 57600 -p /dev/ttyUSB0 -s T&lt;br /&gt;
&lt;br /&gt;
If this does not work, make sure you have a properly compiled ''arduino-serial'' program (See Step 5).  Also make sure the /dev/ttyUSB0 is the same device that your system is using to communicate with the Arduino (See the Quick Test section for a way check the device). Try again until you get this to work. &lt;br /&gt;
===== ''tail'' Command Test =====&lt;br /&gt;
This test will verify that you are able to connect the Arduino as a terminal in linux. You will need to close the Serial Monitor in the Arduino environment by just clicking the Serial monitor button again. You should not see the BAUD setting or the SEND box when the Serial Monitor is off.  You will need two terminal windows open and be in the directory where the example files are located. Again side-by-side is nice. Set the terminal settings with this command: (Note: change the 57600 to 9600 if you are using that BAUD)&lt;br /&gt;
 stty -F /dev/ttyUSB0 cs8 57600 ignbrk -brkint -icrnl -imaxbel -opost -onlcr -isig -icanon -iexten -echo -echoe -echok -echoctl -echoke noflsh -ixon -crtscts&lt;br /&gt;
Now do this command to test the ''tail'' command:&lt;br /&gt;
 tail -f /dev/tty/USB0&lt;br /&gt;
After you hit enter, it will appear as though nothing happened, but you should see a blinking cursor.  In any case go to the other terminal window and do this command:(Note: change the 57600 to 9600 if you are using that BAUD)&lt;br /&gt;
 ./arduino-serial -b 57600 -p /dev/ttyUSB0 -s T&lt;br /&gt;
You should now see that results in the terminal window where you typed the ''tail'' command. If this does not work, make sure the /dev/ttyUSB0 is the same device that your system is using to communicate with the Arduino (See the Quick Test section for a way check the device). Try again until you get this to work.&lt;br /&gt;
&lt;br /&gt;
To end the ''tail'' command just click into the terminal window where you typed the ''tail'' command and hit ctrl-c. &lt;br /&gt;
&lt;br /&gt;
Assuming that worked, the next step would be to redirect the ''tail '' command to a file. Use this command:&lt;br /&gt;
 tail -f /dev/ttyUSB0 &amp;gt;&amp;gt; arduino_log&lt;br /&gt;
Now use the arduino-serial command to send data again and then use this command to check if the file is recieving the data:&lt;br /&gt;
 cat arduino_log&lt;br /&gt;
To clear the arduino_log file use this command:&lt;br /&gt;
 echo &amp;gt; arduino_log&lt;br /&gt;
At this point I am going to point you to the ususal suspects for any issues, ie. BAUD and /dev/ttyUSB0&lt;br /&gt;
&lt;br /&gt;
You must be able to get this to work if you expect the overall system to work.&lt;br /&gt;
===== ''samba'' =====&lt;br /&gt;
Troubleshooting ''samba'' is way beyond the scope of this document. All I can say is that you need to make sure that the shared directory is set to Create and Delete permission for others.&lt;br /&gt;
&lt;br /&gt;
==== Windows Client ====&lt;br /&gt;
On the Windows box we will want to make sure we can see the shared folder and that the mapped drive is working. One important note is if your network drive is not connected, or you have not listed it correctly in the Network Dir, the Arduino_Com_v.01 will crash. You will need to be able to copy files to the shared folder and mapped drive. For this section the ''PollCommand'' script should NOT be running.  &lt;br /&gt;
==== File Copy/Write Tests ====&lt;br /&gt;
Open an explorer window or a command line window and go navigate to your mapped drive and path. Check the directory and make sure there is no ''command'' or ''clear_log'' files. Then start up the Arduino_Com_v.01 script and send a command.  Now check that mapped directory and make sure the files ''command'' and ''clear_log'' are in the proper shared directory.  If the Arduino_Com_v.01 script just shuts off, then it could not get to the Network Dir that you provided.  If you provided the correct Network Dir and it still crashes then try to re-map the drive again.  If the program does not shut down, and you do not see the files in the directory, then you probably have a valid location, but it is not the correct directory where the ''CommandPoll'' script is runs.&lt;br /&gt;
&lt;br /&gt;
[[Category:Electronics]]&lt;br /&gt;
&lt;br /&gt;
{{default}}&lt;/div&gt;</summary>
		<author><name>Combustor</name></author>	</entry>

	<entry>
		<id>http://combustory.com/wiki/index.php/Template:Basic_Article_Structure</id>
		<title>Template:Basic Article Structure</title>
		<link rel="alternate" type="text/html" href="http://combustory.com/wiki/index.php/Template:Basic_Article_Structure"/>
				<updated>2008-09-06T19:22:50Z</updated>
		
		<summary type="html">&lt;p&gt;Combustor: New page: == Summary == == Functional Description of the Method == == Requirements == == Example of Method == === Quick Guide: === === Detailed Guide: === == Arduino_Com_v.01 User Guide == ==== Ardu...&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Summary ==&lt;br /&gt;
== Functional Description of the Method ==&lt;br /&gt;
== Requirements ==&lt;br /&gt;
== Example of Method ==&lt;br /&gt;
=== Quick Guide: ===&lt;br /&gt;
=== Detailed Guide: ===&lt;br /&gt;
== Arduino_Com_v.01 User Guide ==&lt;br /&gt;
==== Arduino Command ====&lt;br /&gt;
== Troubleshooting ==&lt;br /&gt;
=== Summary ===&lt;br /&gt;
When Troubleshooting a multi-functional issue, it is best practice to break down the issue into pieces and test each piece as a separate system.  However, we will first run through a quick test to see if we can find any obvious issues first.&lt;br /&gt;
=== Quick Test ===&lt;/div&gt;</summary>
		<author><name>Combustor</name></author>	</entry>

	<entry>
		<id>http://combustory.com/wiki/index.php/Arduino_Electronics</id>
		<title>Arduino Electronics</title>
		<link rel="alternate" type="text/html" href="http://combustory.com/wiki/index.php/Arduino_Electronics"/>
				<updated>2008-09-06T19:14:54Z</updated>
		
		<summary type="html">&lt;p&gt;Combustor: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{default}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Summary ==&lt;br /&gt;
&lt;br /&gt;
Arduino is an open-source hardware platform.  It is a micro controller with a free development environment that is greatly simplified for programming the controller. Visit this website for further details, http://www.arduino.cc/&lt;br /&gt;
&lt;br /&gt;
== Topics ==&lt;br /&gt;
&lt;br /&gt;
* [[Arduino Communications]] - A distributed network approach&lt;br /&gt;
* [[Temperature Controller]] - A/C control for multi-room space with air duct throttling (ie. Smart Thermostat)&lt;br /&gt;
* [[MPGuino]] - An MPG gauge based on the Arduino Platform&lt;br /&gt;
* Suggestions Welcome&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Links ==&lt;br /&gt;
[[Category:Electronics]]&lt;/div&gt;</summary>
		<author><name>Combustor</name></author>	</entry>

	<entry>
		<id>http://combustory.com/wiki/index.php/Main_Page</id>
		<title>Main Page</title>
		<link rel="alternate" type="text/html" href="http://combustory.com/wiki/index.php/Main_Page"/>
				<updated>2008-08-26T18:00:44Z</updated>
		
		<summary type="html">&lt;p&gt;Combustor: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{default}}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--------------------------------Featured picture------------------------------&lt;br /&gt;
{| id=&amp;quot;mp-tfp&amp;quot; style=&amp;quot;margin:4px 0px 0px 0px; width:30%; background:none;&amp;quot;&lt;br /&gt;
|class=&amp;quot;MainPageBG&amp;quot; style=&amp;quot;width:30%; border:1px solid #ddcef2; background:#faf5ff; vertical-align:top; color:#000;&amp;quot;|&lt;br /&gt;
{| cellpadding=&amp;quot;2&amp;quot; cellspacing=&amp;quot;5&amp;quot; style=&amp;quot;vertical-align:top; background:#faf5ff; color:#000; width:30%&amp;quot;&lt;br /&gt;
! &amp;lt;h3  id=&amp;quot;mp-tfp-h2&amp;quot; style=&amp;quot;margin:0; background:#ddcef2; font-size:120%; font-weight:bold; border:1px solid #afa3bf; text-align:top; color:#000; padding:0.2em 0.4em&amp;quot;&amp;gt;Featured picture&amp;lt;/h3&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;color:#000;&amp;quot;| {{Featured Picture}}&lt;br /&gt;
|}&lt;br /&gt;
|}&amp;lt;!--&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;---------Interwiki strapline----------&amp;gt;&lt;br /&gt;
== Goal ==&lt;br /&gt;
&lt;br /&gt;
My original Goal was to create a website that is the most comprehensive website for Automobiles. However, as I soon found out while looking for a Domain Name that there were not many good choices related to cars.  Some how I came up with Combustory and it made me think of the History of Combustibles in general.  So I decided on a site that would include all machines dependent on Combustibles.  As you can see from the list below it is a fairly significant task that will require a world of help, so please feel free to join in the task by emailing me to create an account and start creating content. &lt;br /&gt;
&lt;br /&gt;
Contact: combustor@combustory.com&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;big&amp;gt;'''Categories'''&amp;lt;/big&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* [[Motorcycles]] (Coming)&lt;br /&gt;
* [[Cars]] &lt;br /&gt;
* [[Trucks]] (Coming)&lt;br /&gt;
* [[Tractors]] (Coming)&lt;br /&gt;
* [[Earth Movers]] (Coming)&lt;br /&gt;
* [[Tanks]] (Coming)&lt;br /&gt;
* [[Airplanes]] (Coming)&lt;br /&gt;
* [[Jets]] (Coming)&lt;br /&gt;
* [[Rockets]] (Coming)&lt;br /&gt;
* [[Helicopters]] (Coming)&lt;br /&gt;
* [[Locomotives]] (Coming)&lt;br /&gt;
* [[General Electronics]]&lt;br /&gt;
&lt;br /&gt;
== Creators Note ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Links ==&lt;/div&gt;</summary>
		<author><name>Combustor</name></author>	</entry>

	<entry>
		<id>http://combustory.com/wiki/index.php/Template:Default</id>
		<title>Template:Default</title>
		<link rel="alternate" type="text/html" href="http://combustory.com/wiki/index.php/Template:Default"/>
				<updated>2008-08-26T17:59:42Z</updated>
		
		<summary type="html">&lt;p&gt;Combustor: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;big&amp;gt;Welcome to [http://combustory.com Combustory]&amp;lt;/big&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--&amp;lt;google&amp;gt;&amp;lt;/google&amp;gt;&lt;br /&gt;
&amp;lt;google&amp;gt;CH02&amp;lt;/google&amp;gt;--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Any questions or comments:'''&lt;br /&gt;
* Go to the discussion tab above and add comments or questions&lt;br /&gt;
* Or, Send them to - combustor@combustory.com&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--{{Feature Articles}}--&amp;gt;&lt;/div&gt;</summary>
		<author><name>Combustor</name></author>	</entry>

	<entry>
		<id>http://combustory.com/wiki/index.php/Cars</id>
		<title>Cars</title>
		<link rel="alternate" type="text/html" href="http://combustory.com/wiki/index.php/Cars"/>
				<updated>2008-08-26T14:14:59Z</updated>
		
		<summary type="html">&lt;p&gt;Combustor: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{default}}&lt;br /&gt;
&lt;br /&gt;
== American Makers ==&lt;br /&gt;
&lt;br /&gt;
* [[GMC]](Coming)&lt;br /&gt;
* [[Buick]](Coming)&lt;br /&gt;
* [[Cadillac]](Coming)&lt;br /&gt;
* [[Oldsmobile]](Coming)&lt;br /&gt;
* [[Chevrolet]](Coming)&lt;br /&gt;
* [[Pontiac]](Coming)&lt;br /&gt;
* [[Saturn]](Coming)&lt;br /&gt;
* [[Ford]](Coming)&lt;br /&gt;
* [[Lincoln]](Coming)&lt;br /&gt;
* [[Mercury]](Coming)&lt;br /&gt;
* [[Chrysler]](Coming)&lt;br /&gt;
* [[Dodge]](Coming)&lt;br /&gt;
* [[Jeep]](Coming)&lt;br /&gt;
* [[AMC]](Coming)&lt;br /&gt;
* [[Auburn]](Coming)&lt;br /&gt;
* [[Studebaker]](Coming)&lt;br /&gt;
* [[Duesenberg]](Coming)&lt;br /&gt;
* [[Cord]](Coming)&lt;br /&gt;
&lt;br /&gt;
== European Makers ==&lt;br /&gt;
&lt;br /&gt;
* [[BMW]] (Coming)&lt;br /&gt;
* [[Mercedes]](Coming)&lt;br /&gt;
* [[Volkswagon]](Coming)&lt;br /&gt;
* [[Porsche]](Coming)&lt;br /&gt;
* [[Fiat]](Coming)&lt;br /&gt;
* [[Volvo]](Coming)&lt;br /&gt;
* [[MG]](Coming)&lt;br /&gt;
* [[Jaguar]](Coming)&lt;br /&gt;
* [[Fiat]](Coming)&lt;br /&gt;
* [[Audi]](Coming)&lt;br /&gt;
* [[Alpha Romeo]](Coming)&lt;br /&gt;
* [[Maserati]](Coming)&lt;br /&gt;
* [[Ferrari]](Coming)&lt;br /&gt;
* [[Bugati]](Coming)&lt;br /&gt;
* [[Lamborghini]](Coming)&lt;br /&gt;
* [[Saab]](Coming)&lt;br /&gt;
* [[Peugeot]](Coming)&lt;br /&gt;
* [[Renault]](Coming)&lt;br /&gt;
* [[Yugo]](Coming)&lt;br /&gt;
* [[Opel]](Coming)&lt;br /&gt;
* [[Rolls Royce]](Coming)&lt;br /&gt;
* [[Land Rover]](Coming)&lt;br /&gt;
&lt;br /&gt;
== Asian Makers ==&lt;br /&gt;
&lt;br /&gt;
* [[Nissan]](Coming)&lt;br /&gt;
* [[Infinity]](Coming)&lt;br /&gt;
* [[Datsun]](Coming)&lt;br /&gt;
* [[Toyota]](Coming)&lt;br /&gt;
* [[Lexus]](Coming)&lt;br /&gt;
* [[Scion]](Coming)&lt;br /&gt;
* [[Honda]](Coming)&lt;br /&gt;
* [[Accura]](Coming)&lt;br /&gt;
* [[Mazda]](Coming)&lt;br /&gt;
* [[Mitsubishi]](Coming)&lt;br /&gt;
* [[Hyundai]](Coming)&lt;br /&gt;
* [[Kia]](Coming)&lt;br /&gt;
* [[Subaru]](Coming)&lt;br /&gt;
* [[Isuzu]](Coming)&lt;br /&gt;
* [[Tata]](Coming)&lt;br /&gt;
* [[Chery]](Coming)&lt;br /&gt;
&lt;br /&gt;
== Creators Note ==&lt;/div&gt;</summary>
		<author><name>Combustor</name></author>	</entry>

	<entry>
		<id>http://combustory.com/wiki/index.php/MPGuino</id>
		<title>MPGuino</title>
		<link rel="alternate" type="text/html" href="http://combustory.com/wiki/index.php/MPGuino"/>
				<updated>2008-08-26T13:59:08Z</updated>
		
		<summary type="html">&lt;p&gt;Combustor: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{default}}&lt;br /&gt;
[[Image:MPGuino_Enclosure_mounted.jpg|right|thumb|400px|]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Summary ==&lt;br /&gt;
&lt;br /&gt;
This is an impressive use of the Arduino platform. One that will actually pay for itself too.  A small group of folks banded together and created an open platform called http://opengauge.googlecode.com where you will not really find much information concerning this device, but there are lots of information in a forum at http://www.ecomodder.com, where you will find tons of useful and fun ways on improving gas mileage for any car. To explain what these folks did for the average working Joe, who can't quite afford a car newer than 1995, is just amazing. It still works for just about any car with fuel injection, but for cars built before 1996, there is no [[OBD-II Diagnostic Tools | OBD-II]] option.&lt;br /&gt;
&lt;br /&gt;
They came up with a way to build a reasonably low-cost device that will gauge your MPG, even for cars that do not have an [[OBD-II Diagnostic Tools | OBD-II]] interface in there car. At the moment it is restricted to use in cars with fuel injection, but given enough time they may even find a way to gauge cars with carburetors.  To cut to the chase, this device uses inputs from the Vehicle Speed Sensor(VSS) and one fuel injector control wire, both of which are easily found in just about all fuel injected cars, minus mechanical fuel injection, which only Mercedes seemed to make reliably albeit expensively. So, sorry all those 300E owners, you can't play with this toy right now.&lt;br /&gt;
&lt;br /&gt;
The device sports an LCD screen with many display features that include Current,Instant and Tank MPG as well as Trip data for MPG, Mileage, and Tank Gallons. There are many other options and I recommend you reference the User Guide below for more detail.&lt;br /&gt;
&lt;br /&gt;
== Functional Description of the Solution ==&lt;br /&gt;
&lt;br /&gt;
To further detail the solution, the VSS provides a pulse input related to the speed and distance traveled, meaning from this sensor you know how fast the car is going from the pulse frequency and how far the car has traveled by counting the actual number of pulses. Pulses per mile vary from car to car and based on the forum I saw a range in the 4,000 - 10,000 pulses per mile. The injector control wire provides the fuel flow mass. By making the relation of the known flow rate of an injector and the amount of time that the injector is turned on, you can calculate the the actual fuel mass flow rate your car is using. &lt;br /&gt;
&lt;br /&gt;
On the electronics side they used the Arduino platform as the microprocessor and threw in some supporting components to prevent small fires that create anger and horrible smells.  I hate the smell of fried electronics, unfortunately I know it too well. The microprocessor polls the sensors in the micro-second realm, and writes the results to the LCD in the 1/2-1 sec. realm. This gives the user a near real time view of the actual data.&lt;br /&gt;
&lt;br /&gt;
There really is not much at the high level design function, but as they say, &amp;quot;The Devil is in the Details&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Theory of Operation ==  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Fuel Injectors'''&lt;br /&gt;
&lt;br /&gt;
To completely simplify a fuel injector, just imagine a water faucet valve. When the valve is open, the water flows out. The amount of water that flows out depends on the size of the faucet opening and the pressure of the water behind the faucet.  For a fuel injector, the manufacturers specify a lbs/hr of fuel flow by knowing the opening of the injector and specifying the constant pressure for which the injector supply is supposed to maintain. Therefore, if you provide the proper pressure to the injector as specified and you open the injector for one hour, you should get the specified pounds of fuel flowing out of the injector. For example, a 20 lb/hr injector will supply 20lbs of fuel if left turned on for one hour.&lt;br /&gt;
&lt;br /&gt;
This makes the calculation fairly simple to determine a fuel flow rate for your car by measuring the total amount the injector is open that comes from the Injector Sensor of the MPGuino and it is measured through the pulse width sent to the injector by the car computer. Also known as the injector pulse width. So the total time for each pulse width over a given time is the total time an injector is open.  This measurement is usually taken in a second time frame and an injector has a limitation known as a frequency response or a max number of pulses per second, which is related to the mechanical response time that the injector can open or close. The MPGuino measures the total time the injector is open, so we will just take that number as a known measured value.&lt;br /&gt;
&lt;br /&gt;
Ti = Time the injector is open as a ratio of a known time = For calculation purposes we will set it at usec/sec&lt;br /&gt;
&lt;br /&gt;
Fr = Fuel flow rate is a known from the manufacturer in lbs/hr&lt;br /&gt;
&lt;br /&gt;
Therefore:&lt;br /&gt;
&lt;br /&gt;
Fuel usage rate = Fr (lbs/hr) / 3600 (sec/hr) * Ti (usec/sec) /1000 = (lbs/sec)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math &amp;gt;Fu = \frac{Fr}{3600} * \frac {Ti}{1000}&amp;lt;/math &amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&lt;br /&gt;
Ti = 500 usec/sec as measured by MPGuino&lt;br /&gt;
&lt;br /&gt;
Fr = 20 lbs/hr as specified by manufacturer&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math &amp;gt; Fuel\ usage\ rate = \frac{20}{3600} * \frac{500}{1000} = 0.0028 (lbs/sec)&amp;lt;/math &amp;gt; &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''VSS - Vehicle Speed Sensor'''&lt;br /&gt;
&lt;br /&gt;
The VSS count is fairly straight forward.  There is a device on your car that rotates and creates a certain number of pulses per revolution. The sensor is usually attached to your transmission and it has a direct gear ratio to your tires that I will call the rolling ratio. This sensor is used to feed the vehicle computer the speed and distance data. The actual gear ratio has only one main variation, and that is the tire diameter. For the MPGuino to calculate the the MPG, this input is critical for determining the distance traveled. The VSS count is typically measured in counts per mile.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Theory vs. Reality'''&lt;br /&gt;
&lt;br /&gt;
As with any engineering of a product you will have fudge factors.  The important thing to realize is that you always design to get the fundamentals close and then expect to calibrate to meet the accuracy needed for the function.  For this product we will evaluate the best way to calibrate and adjust to improve the accuracy of the numbers.  This may not be necessary at all if your goal is to get feedback on your driving habits, then the accuracy does not matter, as long as you realize that the MPGuino is changing your driving habits to conserve gas AND best of all save you money.&lt;br /&gt;
&lt;br /&gt;
So first let's discuss the factors that will affect your accuracy. &lt;br /&gt;
&lt;br /&gt;
Factors NOT in our control:&lt;br /&gt;
&lt;br /&gt;
Is it possible to control or measure these factors? yes, is it practical? not in my opinion. So these factors will introduce errors that will need compensation in the fudging process. I feel it is a pretty safe assumption that over time these factors will average within a range that will permit fudging.&lt;br /&gt;
&lt;br /&gt;
''Injector Pressure'' - Your car has a pressure regulator to manage your fuel manifold pressure, and it will regulate to it's setting.  You could measure your pressure, but then you would have to know how that affects the fuel flow through the injector.  We also do not know how the pressure changes over time and this can affect your fuel flow.  &lt;br /&gt;
&lt;br /&gt;
''Injector Efficiency'' - Well, since MPGuino is a device that was targeted to older cars, then you have to expect that injectors tend to clog and become less efficient over time. The only way to calibrate that problem is to measure the actual flow through each injector.  Have fun if you want to tackle that project. `,~)&lt;br /&gt;
&lt;br /&gt;
''Rolling Ratio'' - The rolling ratio is a constant changing ratio that will affect your VSS counts per mile. The main reason it changes over time is due to tires. As a tire gets more worn your VSS counts per mile will increase. When you replace that old set of tires with new tires, you will have less counts per mile.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Fudging/Calibration process'''&lt;br /&gt;
&lt;br /&gt;
There are two areas I want to focus on to get this system as accurate as possible. Let's consider fudging the fuel flow rate and measuring the VSS counts per mile. I am taking this approach, because measuring the VSS counts is a practical option and it can be done with some accuracy.  In contrast the fuel flow rate used to calculate the total fuel usage is not very measurable and therefore should be fudged. &lt;br /&gt;
&lt;br /&gt;
To measure the VSS counts per mile get on the highway and find a mile marker and reset you VSS counts to zero.  Drive ten miles as marked by the mile markers and note your VSS counts. Divide by ten to get your VSS counts per mile.  Take an average of this process if you really want to nail it down, but I do not feel that is necessary. You may need to test this count every 6-12 months to readjust this number. You can compare your numbers to you odometer, but understand that the odometer does not take into account the tire diameter as accurately as your measurement, but it can be used as a verification that you are in the ball park. The best verification would be if you noticed that you have a fairly repeatable offset from the odometer and your calculation.&lt;br /&gt;
&lt;br /&gt;
To measure the fuel is much more difficult. Really the best way to do measure the fuel would be to drain the tank and run the tank dry of fuel. Now weigh the amount of fuel and put it in the tank. Run the tank dry again and compare the actual fuel usage with the MPGuino. Again do this multiple times and take the average. Personally I would not do this at all, but it is the only real way to get acuracy.  For a much more practical method, start a fuel usage log. Go to many different gas pumps and take an average over time. I have noticed that the cheapest gas stations tend to calibrate to the high side of the legal limit, if not actually outside the legal limit. Try to keep a standard procedure, like only filling to the first click off.  Compare your fuel usage average to your MPGuino fuel usage average and look for a trend. Now fudge the fuel usage to match.&lt;br /&gt;
&lt;br /&gt;
== Requirements and Knowledge ==&lt;br /&gt;
&lt;br /&gt;
* Basic soldering and electronic building skill&lt;br /&gt;
* The following parts list for the Arduino assembly&lt;br /&gt;
** 2 5.1v zener diodes&lt;br /&gt;
** 1 2n3906 PNP Transistor&lt;br /&gt;
** 1 220 ohm resistor&lt;br /&gt;
** 2 100k resistors&lt;br /&gt;
** 3 tactile switches&lt;br /&gt;
** 1 freeduino arduino clone (any arduino can probably be made to work) i.e. an iduino: http://spiffie.org/kits/iduino/ or a Freeduino&lt;br /&gt;
** 1 LCD (others might work as well, check pinout and chipset, etc). 16x2 LCD Module While Characters Blue Backlight Or a green one from sparkfun or mouser (a number of folks like the green ones better)&lt;br /&gt;
** Sufficient Perfboard&lt;br /&gt;
** A case to hold it all together&lt;br /&gt;
* Additional parts for the iDuino assembly&lt;br /&gt;
** 1 7805 Voltage Regulator &lt;br /&gt;
** 1 1n4004 diode&lt;br /&gt;
** 330 uf cap &lt;br /&gt;
** 1 .1uf cap.&lt;br /&gt;
* You will need to find the wires for the VSS on the vehicle computer or control unit.&lt;br /&gt;
* If you're lucky you won't need much troubleshooting skills&lt;br /&gt;
&lt;br /&gt;
== Assemble the Electronics  ==&lt;br /&gt;
&lt;br /&gt;
Here are the schematics. This should be enough for most of you. There are two assemblies that are possible to build. The Arduino or the iDuino. &lt;br /&gt;
&lt;br /&gt;
Notes: &lt;br /&gt;
&lt;br /&gt;
* The only two output leads for the VSS and the injector, other than that a 12vdc supply, and that is it.&lt;br /&gt;
* The Analog pins in this schematic show 0-5 are used as digital I/O, therefore, Analog pin 0 is Digital pin 14 then count up from there.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;big&amp;gt;'''Arduino Assembly Schematic'''&amp;lt;/big&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Image:MPGuino_Schematic.GIF]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;big&amp;gt;'''iDuino Assembly Schematic'''&amp;lt;/big&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Image:iDuino_Schematic.GIF]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Enclosures  ==&lt;br /&gt;
&lt;br /&gt;
{| Border=1&lt;br /&gt;
|+ &amp;lt;big&amp;gt;'''MPGuino Arduino Enclosure Pics - [http://www.hitechcontrols.com/hensel/polycarbonate/smooth/kf8040.htm KF 8040 - Polycarbonate Indoor/Outdoor Enclosures]]'''&amp;lt;/big&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
|[[Image:MPGuino_Enclosure_Front.jpg|thumb|400px|]]|| [[Image:MPGuino_Enclosure_Inside.jpg|thumb|400px|]] || [[Image:MPGuino_Enclosure_mounted.jpg|thumb|400px|]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{| Border=1&lt;br /&gt;
|+ &amp;lt;big&amp;gt;'''MPGuino iDuino Enclosure Pics - [[http://www.radioshack.com/product/index.jsp?productId=2062280&amp;amp;cp=&amp;amp;sr=1&amp;amp;origkw=project+box&amp;amp;kw=project+box&amp;amp;parentPage=search Radio Shack Enclosure]]'''&amp;lt;/big&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| [[Image:MPGuino_iDuino_Front.jpg|thumb|400px|]] || [[Image:MPGuino_iDuino_Inside_Front.jpg|thumb|400px|]] || [[Image:MPGuino_iDuino_Inside_Guts_Front.jpg|thumb|400px|]]&lt;br /&gt;
|-&lt;br /&gt;
| [[Image:MPGuino_iDuino_Back.jpg|thumb|400px|]] || [[Image:MPGuino_iDuino_Inside_Back.jpg|thumb|400px|]] || [[Image:MPGuino_iDuino_Inside_Guts.jpg|thumb|400px|]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== User Guide  ==&lt;br /&gt;
&lt;br /&gt;
'''Screens'''&lt;br /&gt;
&lt;br /&gt;
1. Instant MPG/Speed&lt;br /&gt;
Current MPG/Distance&lt;br /&gt;
&lt;br /&gt;
2. Instant MPG/Speed&lt;br /&gt;
Tank MPG/Distance&lt;br /&gt;
&lt;br /&gt;
3. Large font instant MPG&lt;br /&gt;
&lt;br /&gt;
4. Large font current MPG&lt;br /&gt;
&lt;br /&gt;
5. Large font tank MPG&lt;br /&gt;
&lt;br /&gt;
6. Current MPH, MPG, Miles, Gallons&lt;br /&gt;
&lt;br /&gt;
7. Tank MPH, MPG, Miles, Gallons&lt;br /&gt;
&lt;br /&gt;
8. Instant Raw Data (very useful for connection troubleshooting)&lt;br /&gt;
Injector open seconds, Injector open microSeconds,&lt;br /&gt;
Injector pulse count, Vehicle Speed Sensor pulse count&lt;br /&gt;
&lt;br /&gt;
9. Current trip Raw Data&lt;br /&gt;
Injector open seconds, Injector open microSeconds,&lt;br /&gt;
Injector pulse count, Vehicle Speed Sensor pulse count&lt;br /&gt;
&lt;br /&gt;
10. Tank trip Raw Data&lt;br /&gt;
Injector open seconds, Injector open microSeconds,&lt;br /&gt;
Injector pulse count, Vehicle Speed Sensor pulse count&lt;br /&gt;
&lt;br /&gt;
11. CPU Monitor&lt;br /&gt;
Max CPU %utilization, Tank running Time mm.ss,&lt;br /&gt;
Free Memory (bytes)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Start-up Settings'''&lt;br /&gt;
&lt;br /&gt;
There is also a setup screen that displays the first time the program is run and by pressing all three buttons at once. It walks you through the following setup variables. Use left and right buttons to select the digit you wish to change or the OK or Cancel (XX) items. Use middle button to rotate the current digit or select OK or XX if that is where the cursor is. Selecting OK will save the currently displayed value to the current variable and advance to the next variable. Selecting XX will just advance to the next variable.&lt;br /&gt;
&lt;br /&gt;
1. Contrast - This comes up first on a brand new run and changes on the screen are immediate so if you can't see anything try pressing middle button a few times.&lt;br /&gt;
&lt;br /&gt;
2. VSS Pulses/Mile - use this to adjust displayed speed/miles. If the speed/miles displayed on the mpguino is low then decrease this number by the percentage that it is off and vice versa for high readings. Most asian cars will be a multiple of 8204 and GM will be 10000, we are hoping users will contribute model specific data here.&lt;br /&gt;
&lt;br /&gt;
3. MicroSec/Gallon - use this to adjust displayed fuel consumption. You may want to readjust this initially to get a ballpark MPG reading (after VSS Pulses/Mile is deemed accurate), then calibrate it with a couple fillups. If the mpguino displayed MPG is high or the displayed tank gallons is low at fillup then reduce MicroSec/Gallon by the percentage that the gallons are low or the displayed mpg is high. Like the vss pulses, this would benefit from user contributions about what values work for what specific cars.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
4. Pulses/2 revs - not currently used, but a single injector on a 4 cylinder sequential system will make 1 squirt in 2 revolutions. Hope to be able to base RPM on this at some point.&lt;br /&gt;
&lt;br /&gt;
5. Timout(microSec) - defaults to 7 minutes. If there are no injector or speed signals from the car and no buttons are pressed in that time then the display backlight turns off. When activity resumes the display will turn back on and the current trip will reset and the tank trip will be restored to the point of last activity.&lt;br /&gt;
&lt;br /&gt;
6. Tank Gal * 1000 - not currently used, but defaults to 13300 or 13.3 gallons.&lt;br /&gt;
&lt;br /&gt;
7. Injector DelayuS - Represents the mechanical delay of the injector in microseconds. Advanced topic.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Button Functions''' &lt;br /&gt;
&lt;br /&gt;
1. left: cycle through screeens in reverse&lt;br /&gt;
&lt;br /&gt;
2. middle: cycle through pre-defined brightness settings&lt;br /&gt;
&lt;br /&gt;
3. right: cycle through screeens forward&lt;br /&gt;
&lt;br /&gt;
4. left+middle: tank reset&lt;br /&gt;
&lt;br /&gt;
5. right+middle: current reset&lt;br /&gt;
&lt;br /&gt;
6. left+middle+right: go to setup screen&lt;br /&gt;
&lt;br /&gt;
== Table of Car Settings  ==&lt;br /&gt;
&lt;br /&gt;
'''I am looking for data here, if you have a car to add, email me at combustor@combustory.com with the data.'''&lt;br /&gt;
&lt;br /&gt;
{| Border=1&lt;br /&gt;
|+ MPGuino Car Settings&lt;br /&gt;
! Car Year Make Model !! Engine !! Transmission !! VSS (count/mile) !! usec/gal&lt;br /&gt;
|-&lt;br /&gt;
|1989 Chevy Celebrity|| 3.1 || 4 spd auto || 4000 || 0240000000&lt;br /&gt;
|-&lt;br /&gt;
|1990 Mitsubishi Eclipse GST || 2.0 litre || 5 speed || 16364 || 126180393&lt;br /&gt;
|-&lt;br /&gt;
|1994 Suzuki Swift GA Sedan|| 1.3 Liter || 5 Speed || ???? || ????&lt;br /&gt;
|-&lt;br /&gt;
|1996 Jeep Wrangler || 4.0 Liter || 5 speed || ???? || ????&lt;br /&gt;
|-&lt;br /&gt;
|1997 Saturn SL2,SC2,SW2,S2|| 1.9 ||  || 10000 || 0289967320&lt;br /&gt;
|-&lt;br /&gt;
|2005 Subaru Impreza Outback Sport, 2.5RS || 2.5L N/A || 5MT || 8000 || 183165000 (still calibrating)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Software &amp;amp; Release notes  ==&lt;br /&gt;
&lt;br /&gt;
Here are the latest release notes as of this writing.  Get the latest SW from [[The Arduino Code]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''8/9/2008 updates for v0.70'''&lt;br /&gt;
&lt;br /&gt;
More experiments with vss processing. Instant mph is very smooth on saturn but still jumps a bit on the metro. Distance reading on metro appears reasonably accurate (102.6 miles on odo, 102.18 on mpguino using 8208 vsspulses/mile). So the guino is doing a pretty good job of counting the vss pulses, it is a little erratic in timing the pulses though.&lt;br /&gt;
&lt;br /&gt;
want to add EOC miles to the trip next, don't know if it will fit&lt;br /&gt;
sketch size: 12884&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''8/1/2008 updates for v0.69'''&lt;br /&gt;
&lt;br /&gt;
Added event handler and added debouncing on vss. Still trying to clean up reed switch vss signal via software with no luck. will make separate post for vss issue.&lt;br /&gt;
&lt;br /&gt;
Added instantaneous mph (mpg is next), this looks at the time between vss peaks to determine the speed instead of the number of pulses in the last half second, which was jumpy at slow speeds. We are getting really really tight on space. That might also be an issue when 0012 comes out (don't know when).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''8/1/2008 updates for v0.68'''&lt;br /&gt;
&lt;br /&gt;
Removed all dependencies on timer0 so we should be arduino 0012 compatible. This also establishes an ISR under our control for scheduling events. Disabled Timer0 so use millis2(), delay2(), etc.&lt;br /&gt;
&lt;br /&gt;
Knocked off a few hundred bytes by converting LCD to a namespace instead of a class.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''7/10/2008 updates for v0.67'''&lt;br /&gt;
&lt;br /&gt;
Incorporated LCD timings from Yoshi, removed pin 15 code and power up detection code.&lt;br /&gt;
&lt;br /&gt;
moved source code to google/svn Revision 32: /trunk&lt;br /&gt;
&lt;br /&gt;
other happenings:&lt;br /&gt;
did a test with the scope regarding the voltage drop at peak pulse. I had the guino set a pin high and low within the interrupts receiving high and low and the pulse widths were the same except the generated one was perfectly square. So that is a good thing. Will need to test exactly what voltage level is acceptable.&lt;br /&gt;
&lt;br /&gt;
The power supply on the scope died I think I just need a new TL431C or NTE999 though. I didn't get a chance to witness the vss bounce, the scope died during the attempt.&lt;br /&gt;
&lt;br /&gt;
I am planning on moving all timing critical code to timer 2 with an event handler. I need real interrupt style debouncing for the vss and might as well use it as an event scheduler for debouncing the buttons as well as whatever else. This move will also allow for arduino0012 compatability.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''6/27/2008 updates for v0.66'''&lt;br /&gt;
&lt;br /&gt;
ADDED AN ONBOARD VARIABLE EDITOR!!! VARIABLES STORED IN EEPROM!! Now you can upgrade and not lose your settings and make adjustments in the car. Refer to post 1[/url] for screens and edit usage.&lt;br /&gt;
&lt;br /&gt;
Updated screens descriptions in post 1&lt;br /&gt;
&lt;br /&gt;
Checked source into sourceforge.net, linked post 1 to sourceforge (ran out of room again and wiki didn't like the extension .pde).&lt;br /&gt;
&lt;br /&gt;
Sketch size 11734, 448 bytes free&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''6/26/2008 updates for v0.65'''&lt;br /&gt;
&lt;br /&gt;
Added 7 minute activity timeout. It saves the state of the persistent trips (just tank for now) at the point of last activity and after 7 minutes of no injector pulses/vss pulses/or button presses, it turns off the LED backlight and sets up current to be reset and tank to be restored when activity resumes.&lt;br /&gt;
&lt;br /&gt;
Despazed the buttons and Screen labels so they display for a second and accidental double button presses are minimized.&lt;br /&gt;
&lt;br /&gt;
Running out of excuses (and room) to no do the user input/eprom setup screen thing Sketch size 10502 bytes.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''6/23/2008 updates for v0.64'''&lt;br /&gt;
&lt;br /&gt;
Fixed instant/tank screen (was displaying instant/current on that screen).&lt;br /&gt;
&lt;br /&gt;
Improved LCD reinit on reprogram/reset. Can (usually) tell if LCD needs reinitializing. Press left and right buttons to force an LCD init if necessary. Want to free pin 15 for future tasks if it works well enough.&lt;br /&gt;
&lt;br /&gt;
Added a bit of default verbiage to debug mode.&lt;br /&gt;
&lt;br /&gt;
Working on a portable scope deal.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''6/20/2008 updates for v0.63'''&lt;br /&gt;
&lt;br /&gt;
Wrote 64bit arithmetic routines, yay no more messing with &amp;quot;ifs&amp;quot; when it should be math!&lt;br /&gt;
&lt;br /&gt;
Noticed double vss count didn't make it in .62, fixed.&lt;br /&gt;
&lt;br /&gt;
Subtracting 500uS from each injector pulse.&lt;br /&gt;
&lt;br /&gt;
Added cli/sei around top of loop trip copy.&lt;br /&gt;
&lt;br /&gt;
Made big font a smidgeon bolder.&lt;br /&gt;
&lt;br /&gt;
Code updated, sketch size 9812, CPU 54%, free mem 602&lt;br /&gt;
[[Category:Electronics]]&lt;/div&gt;</summary>
		<author><name>Combustor</name></author>	</entry>

	<entry>
		<id>http://combustory.com/wiki/index.php/Template:Default</id>
		<title>Template:Default</title>
		<link rel="alternate" type="text/html" href="http://combustory.com/wiki/index.php/Template:Default"/>
				<updated>2008-08-26T13:54:55Z</updated>
		
		<summary type="html">&lt;p&gt;Combustor: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;big&amp;gt;Welcome to [http://combustory.com Combustory]&amp;lt;/big&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--&amp;lt;google&amp;gt;&amp;lt;/google&amp;gt;&lt;br /&gt;
&amp;lt;google&amp;gt;CH02&amp;lt;/google&amp;gt;--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Any questions or comments:'''&lt;br /&gt;
* Go to the discussion tab above and add comments or questions&lt;br /&gt;
* Or, Send them to - combustor@combustory.com&lt;br /&gt;
&lt;br /&gt;
{{Feature Articles}}&lt;/div&gt;</summary>
		<author><name>Combustor</name></author>	</entry>

	<entry>
		<id>http://combustory.com/wiki/index.php/CarCopter</id>
		<title>CarCopter</title>
		<link rel="alternate" type="text/html" href="http://combustory.com/wiki/index.php/CarCopter"/>
				<updated>2008-08-25T17:28:23Z</updated>
		
		<summary type="html">&lt;p&gt;Combustor: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{default}}&lt;br /&gt;
&lt;br /&gt;
== A Helicopter made from car parts? ==&lt;br /&gt;
&lt;br /&gt;
[[image:Carcopter.jpg]]&lt;br /&gt;
&lt;br /&gt;
That's right! Mubarak Muhammad Abdullahi takes old cars and motorbikes to pieces in the back yard at home and builds his own helicopters from the parts. He is a 24-year-old physics undergraduate in northern Nigeria and he has found the right formula for turning cars into helicopters.  This is more than just a hobby for him, it is a sense of national pride. He has been trying to get support from the Nigerian Government as well as other wealthy countrymen. Although some government officials got very excited when they saw him conduct a demonstration flight in neighbouring Katsina state, Nigeria’s Civil Aviation Authority (NCAA) has so far shown no interest in his aircraft. The chopper, which has flown briefly on six occasions, is made from scrap aluminium that Abdullahi bought with the money he makes from computer and mobile phone repairs, and a donation from his father, who teaches at Kano’s Bayero university.&lt;br /&gt;
&lt;br /&gt;
Abdullahi explained from the cockpit, “You start it, allow it to run for a minute or two and you then shift the accelerator forward and the propeller on top begins to spin. The further you shift the accelerator the faster it goes and once you reach 300 rmp you press the joystick and it takes off.” For a four-seater it is a big aircraft, measuring twelve metres (39 feet) long, seven metres high by five wide. It has never attained an altitude of more than seven feet. It is powered by a second-hand 133 horsepower Honda Civic car engine and kitted out with seats from an old Toyota saloon car. Its other parts come from the carcass of a Boeing 747 which crashed near Kano some years ago.&lt;br /&gt;
&lt;br /&gt;
This is not the end of this bright young man's career.  He is working on a second model that is supposed to double the performance of his first one.  He expects this new model to fly 15 feet for at least three hours.  To learn more about this respectable accomplishment:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;google&amp;gt;Mubarak Muhammad Abdullahi&amp;lt;/google&amp;gt;&lt;/div&gt;</summary>
		<author><name>Combustor</name></author>	</entry>

	<entry>
		<id>http://combustory.com/wiki/index.php/CarCopter</id>
		<title>CarCopter</title>
		<link rel="alternate" type="text/html" href="http://combustory.com/wiki/index.php/CarCopter"/>
				<updated>2008-08-25T17:06:45Z</updated>
		
		<summary type="html">&lt;p&gt;Combustor: New page: {{default}}  == A Helicopter made from car parts? ==  image:Carcopter  Contact: combustor@combustory.com   &amp;lt;big&amp;gt;'''Categories'''&amp;lt;/big&amp;gt;  * Motorcycles (Coming) * Cars  * [[Truck...&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{default}}&lt;br /&gt;
&lt;br /&gt;
== A Helicopter made from car parts? ==&lt;br /&gt;
&lt;br /&gt;
[[image:Carcopter]]&lt;br /&gt;
&lt;br /&gt;
Contact: combustor@combustory.com&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;big&amp;gt;'''Categories'''&amp;lt;/big&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* [[Motorcycles]] (Coming)&lt;br /&gt;
* [[Cars]] &lt;br /&gt;
* [[Trucks]] (Coming)&lt;br /&gt;
* [[Tractors]] (Coming)&lt;br /&gt;
* [[Earth Movers]] (Coming)&lt;br /&gt;
* [[Tanks]] (Coming)&lt;br /&gt;
* [[Airplanes]] (Coming)&lt;br /&gt;
* [[Jets]] (Coming)&lt;br /&gt;
* [[Rockets]] (Coming)&lt;br /&gt;
* [[Helicopters]] (Coming)&lt;br /&gt;
* [[Locomotives]] (Coming)&lt;br /&gt;
* [[General Electronics]]&lt;br /&gt;
&lt;br /&gt;
== Creators Note ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Links ==&lt;/div&gt;</summary>
		<author><name>Combustor</name></author>	</entry>

	<entry>
		<id>http://combustory.com/wiki/index.php/Template:Featured_Picture</id>
		<title>Template:Featured Picture</title>
		<link rel="alternate" type="text/html" href="http://combustory.com/wiki/index.php/Template:Featured_Picture"/>
				<updated>2008-08-25T16:13:29Z</updated>
		
		<summary type="html">&lt;p&gt;Combustor: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Image:Carcopter.jpg]]&lt;br /&gt;
&lt;br /&gt;
A car made into a helicopter?  [[CarCopter | Find out more...]]&lt;/div&gt;</summary>
		<author><name>Combustor</name></author>	</entry>

	<entry>
		<id>http://combustory.com/wiki/index.php/Main_Page</id>
		<title>Main Page</title>
		<link rel="alternate" type="text/html" href="http://combustory.com/wiki/index.php/Main_Page"/>
				<updated>2008-08-25T16:11:35Z</updated>
		
		<summary type="html">&lt;p&gt;Combustor: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{default}}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--------------------------------Featured picture-------------------------------&amp;gt;&lt;br /&gt;
{| id=&amp;quot;mp-tfp&amp;quot; style=&amp;quot;margin:4px 0px 0px 0px; width:30%; background:none;&amp;quot;&lt;br /&gt;
|class=&amp;quot;MainPageBG&amp;quot; style=&amp;quot;width:30%; border:1px solid #ddcef2; background:#faf5ff; vertical-align:top; color:#000;&amp;quot;|&lt;br /&gt;
{| cellpadding=&amp;quot;2&amp;quot; cellspacing=&amp;quot;5&amp;quot; style=&amp;quot;vertical-align:top; background:#faf5ff; color:#000; width:30%&amp;quot;&lt;br /&gt;
! &amp;lt;h3  id=&amp;quot;mp-tfp-h2&amp;quot; style=&amp;quot;margin:0; background:#ddcef2; font-size:120%; font-weight:bold; border:1px solid #afa3bf; text-align:top; color:#000; padding:0.2em 0.4em&amp;quot;&amp;gt;Featured picture&amp;lt;/h3&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;color:#000;&amp;quot;| {{Featured Picture}}&lt;br /&gt;
|}&lt;br /&gt;
|}&amp;lt;!--&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;---------Interwiki strapline----------&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Goal ==&lt;br /&gt;
&lt;br /&gt;
My original Goal was to create a website that is the most comprehensive website for Automobiles. However, as I soon found out while looking for a Domain Name that there were not many good choices related to cars.  Some how I came up with Combustory and it made me think of the History of Combustibles in general.  So I decided on a site that would include all machines dependent on Combustibles.  As you can see from the list below it is a fairly significant task that will require a world of help, so please feel free to join in the task by emailing me to create an account and start creating content. &lt;br /&gt;
&lt;br /&gt;
Contact: combustor@combustory.com&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;big&amp;gt;'''Categories'''&amp;lt;/big&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* [[Motorcycles]] (Coming)&lt;br /&gt;
* [[Cars]] &lt;br /&gt;
* [[Trucks]] (Coming)&lt;br /&gt;
* [[Tractors]] (Coming)&lt;br /&gt;
* [[Earth Movers]] (Coming)&lt;br /&gt;
* [[Tanks]] (Coming)&lt;br /&gt;
* [[Airplanes]] (Coming)&lt;br /&gt;
* [[Jets]] (Coming)&lt;br /&gt;
* [[Rockets]] (Coming)&lt;br /&gt;
* [[Helicopters]] (Coming)&lt;br /&gt;
* [[Locomotives]] (Coming)&lt;br /&gt;
* [[General Electronics]]&lt;br /&gt;
&lt;br /&gt;
== Creators Note ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Links ==&lt;/div&gt;</summary>
		<author><name>Combustor</name></author>	</entry>

	<entry>
		<id>http://combustory.com/wiki/index.php/Main_Page</id>
		<title>Main Page</title>
		<link rel="alternate" type="text/html" href="http://combustory.com/wiki/index.php/Main_Page"/>
				<updated>2008-08-25T15:58:49Z</updated>
		
		<summary type="html">&lt;p&gt;Combustor: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{default}}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--------------------------------Featured picture-------------------------------&amp;gt;&lt;br /&gt;
{| id=&amp;quot;mp-tfp&amp;quot; style=&amp;quot;margin:4px 0px 0px 0px; width:30%; background:none;&amp;quot;&lt;br /&gt;
|class=&amp;quot;MainPageBG&amp;quot; style=&amp;quot;width:30%; border:1px solid #ddcef2; background:#faf5ff; vertical-align:top; color:#000;&amp;quot;|&lt;br /&gt;
{| cellpadding=&amp;quot;2&amp;quot; cellspacing=&amp;quot;5&amp;quot; style=&amp;quot;vertical-align:top; background:#faf5ff; color:#000; width:30%&amp;quot;&lt;br /&gt;
! &amp;lt;h3  id=&amp;quot;mp-tfp-h2&amp;quot; style=&amp;quot;margin:0; background:#ddcef2; font-size:120%; font-weight:bold; border:1px solid #afa3bf; text-align:left; color:#000; padding:0.2em 0.4em&amp;quot;&amp;gt;Featured picture&amp;lt;/h3&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;color:#000;&amp;quot;| {{Featured Picture}}&lt;br /&gt;
|}&lt;br /&gt;
|}&amp;lt;!--&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;---------Interwiki strapline----------&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Goal ==&lt;br /&gt;
&lt;br /&gt;
My original Goal was to create a website that is the most comprehensive website for Automobiles. However, as I soon found out while looking for a Domain Name that there were not many good choices related to cars.  Some how I came up with Combustory and it made me think of the History of Combustibles in general.  So I decided on a site that would include all machines dependent on Combustibles.  As you can see from the list below it is a fairly significant task that will require a world of help, so please feel free to join in the task by emailing me to create an account and start creating content. &lt;br /&gt;
&lt;br /&gt;
Contact: combustor@combustory.com&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;big&amp;gt;'''Categories'''&amp;lt;/big&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* [[Motorcycles]] (Coming)&lt;br /&gt;
* [[Cars]] &lt;br /&gt;
* [[Trucks]] (Coming)&lt;br /&gt;
* [[Tractors]] (Coming)&lt;br /&gt;
* [[Earth Movers]] (Coming)&lt;br /&gt;
* [[Tanks]] (Coming)&lt;br /&gt;
* [[Airplanes]] (Coming)&lt;br /&gt;
* [[Jets]] (Coming)&lt;br /&gt;
* [[Rockets]] (Coming)&lt;br /&gt;
* [[Helicopters]] (Coming)&lt;br /&gt;
* [[Locomotives]] (Coming)&lt;br /&gt;
* [[General Electronics]]&lt;br /&gt;
&lt;br /&gt;
== Creators Note ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Links ==&lt;/div&gt;</summary>
		<author><name>Combustor</name></author>	</entry>

	<entry>
		<id>http://combustory.com/wiki/index.php/Template:Featured_Picture</id>
		<title>Template:Featured Picture</title>
		<link rel="alternate" type="text/html" href="http://combustory.com/wiki/index.php/Template:Featured_Picture"/>
				<updated>2008-08-25T15:52:43Z</updated>
		
		<summary type="html">&lt;p&gt;Combustor: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Image:Carcopter.jpg]]&lt;br /&gt;
&lt;br /&gt;
[[CarCopter | Find out more...]]&lt;/div&gt;</summary>
		<author><name>Combustor</name></author>	</entry>

	<entry>
		<id>http://combustory.com/wiki/index.php/File:Carcopter.jpg</id>
		<title>File:Carcopter.jpg</title>
		<link rel="alternate" type="text/html" href="http://combustory.com/wiki/index.php/File:Carcopter.jpg"/>
				<updated>2008-08-25T15:50:24Z</updated>
		
		<summary type="html">&lt;p&gt;Combustor: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Combustor</name></author>	</entry>

	<entry>
		<id>http://combustory.com/wiki/index.php/Template:Featured_Picture</id>
		<title>Template:Featured Picture</title>
		<link rel="alternate" type="text/html" href="http://combustory.com/wiki/index.php/Template:Featured_Picture"/>
				<updated>2008-08-25T15:47:50Z</updated>
		
		<summary type="html">&lt;p&gt;Combustor: New page: Image:CarCopter.jpg&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Image:CarCopter.jpg]]&lt;/div&gt;</summary>
		<author><name>Combustor</name></author>	</entry>

	<entry>
		<id>http://combustory.com/wiki/index.php/Main_Page</id>
		<title>Main Page</title>
		<link rel="alternate" type="text/html" href="http://combustory.com/wiki/index.php/Main_Page"/>
				<updated>2008-08-25T15:45:20Z</updated>
		
		<summary type="html">&lt;p&gt;Combustor: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{default}}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--------------------------------Featured picture-------------------------------&amp;gt;&lt;br /&gt;
{| id=&amp;quot;mp-tfp&amp;quot; style=&amp;quot;margin:4px 0px 0px 0px; width:100%; background:none;&amp;quot;&lt;br /&gt;
|class=&amp;quot;MainPageBG&amp;quot; style=&amp;quot;width:100%; border:1px solid #ddcef2; background:#faf5ff; vertical-align:top; color:#000;&amp;quot;|&lt;br /&gt;
{| cellpadding=&amp;quot;2&amp;quot; cellspacing=&amp;quot;5&amp;quot; style=&amp;quot;vertical-align:top; background:#faf5ff; color:#000; width:100%&amp;quot;&lt;br /&gt;
! &amp;lt;h3  id=&amp;quot;mp-tfp-h2&amp;quot; style=&amp;quot;margin:0; background:#ddcef2; font-size:120%; font-weight:bold; border:1px solid #afa3bf; text-align:left; color:#000; padding:0.2em 0.4em&amp;quot;&amp;gt;Featured picture&amp;lt;/h3&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;color:#000;&amp;quot;| {{Featured Picture}}&lt;br /&gt;
|}&lt;br /&gt;
|}&amp;lt;!--&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;---------Interwiki strapline----------&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Goal ==&lt;br /&gt;
&lt;br /&gt;
My original Goal was to create a website that is the most comprehensive website for Automobiles. However, as I soon found out while looking for a Domain Name that there were not many good choices related to cars.  Some how I came up with Combustory and it made me think of the History of Combustibles in general.  So I decided on a site that would include all machines dependent on Combustibles.  As you can see from the list below it is a fairly significant task that will require a world of help, so please feel free to join in the task by emailing me to create an account and start creating content. &lt;br /&gt;
&lt;br /&gt;
Contact: combustor@combustory.com&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;big&amp;gt;'''Categories'''&amp;lt;/big&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* [[Motorcycles]] (Coming)&lt;br /&gt;
* [[Cars]] &lt;br /&gt;
* [[Trucks]] (Coming)&lt;br /&gt;
* [[Tractors]] (Coming)&lt;br /&gt;
* [[Earth Movers]] (Coming)&lt;br /&gt;
* [[Tanks]] (Coming)&lt;br /&gt;
* [[Airplanes]] (Coming)&lt;br /&gt;
* [[Jets]] (Coming)&lt;br /&gt;
* [[Rockets]] (Coming)&lt;br /&gt;
* [[Helicopters]] (Coming)&lt;br /&gt;
* [[Locomotives]] (Coming)&lt;br /&gt;
* [[General Electronics]]&lt;br /&gt;
&lt;br /&gt;
== Creators Note ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Links ==&lt;/div&gt;</summary>
		<author><name>Combustor</name></author>	</entry>

	<entry>
		<id>http://combustory.com/wiki/index.php/Template:Default</id>
		<title>Template:Default</title>
		<link rel="alternate" type="text/html" href="http://combustory.com/wiki/index.php/Template:Default"/>
				<updated>2008-08-25T15:45:00Z</updated>
		
		<summary type="html">&lt;p&gt;Combustor: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;big&amp;gt;Welcome to [http://combustory.com Combustory]&amp;lt;/big&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;google&amp;gt;&amp;lt;/google&amp;gt;&lt;br /&gt;
&amp;lt;google&amp;gt;CH02&amp;lt;/google&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Any questions or comments:'''&lt;br /&gt;
* Go to the discussion tab above and add comments or questions&lt;br /&gt;
* Or, Send them to - combustor@combustory.com&lt;br /&gt;
&lt;br /&gt;
{{Feature Articles}}&lt;/div&gt;</summary>
		<author><name>Combustor</name></author>	</entry>

	<entry>
		<id>http://combustory.com/wiki/index.php/Main_Page</id>
		<title>Main Page</title>
		<link rel="alternate" type="text/html" href="http://combustory.com/wiki/index.php/Main_Page"/>
				<updated>2008-08-25T15:44:10Z</updated>
		
		<summary type="html">&lt;p&gt;Combustor: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{default}}&lt;br /&gt;
{{Feature Articles}}&lt;br /&gt;
&amp;lt;!--------------------------------Featured picture-------------------------------&amp;gt;&lt;br /&gt;
{| id=&amp;quot;mp-tfp&amp;quot; style=&amp;quot;margin:4px 0px 0px 0px; width:100%; background:none;&amp;quot;&lt;br /&gt;
|class=&amp;quot;MainPageBG&amp;quot; style=&amp;quot;width:100%; border:1px solid #ddcef2; background:#faf5ff; vertical-align:top; color:#000;&amp;quot;|&lt;br /&gt;
{| cellpadding=&amp;quot;2&amp;quot; cellspacing=&amp;quot;5&amp;quot; style=&amp;quot;vertical-align:top; background:#faf5ff; color:#000; width:100%&amp;quot;&lt;br /&gt;
! &amp;lt;h3  id=&amp;quot;mp-tfp-h2&amp;quot; style=&amp;quot;margin:0; background:#ddcef2; font-size:120%; font-weight:bold; border:1px solid #afa3bf; text-align:left; color:#000; padding:0.2em 0.4em&amp;quot;&amp;gt;Featured picture&amp;lt;/h3&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;color:#000;&amp;quot;| {{Featured Picture}}&lt;br /&gt;
|}&lt;br /&gt;
|}&amp;lt;!--&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;---------Interwiki strapline----------&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Goal ==&lt;br /&gt;
&lt;br /&gt;
My original Goal was to create a website that is the most comprehensive website for Automobiles. However, as I soon found out while looking for a Domain Name that there were not many good choices related to cars.  Some how I came up with Combustory and it made me think of the History of Combustibles in general.  So I decided on a site that would include all machines dependent on Combustibles.  As you can see from the list below it is a fairly significant task that will require a world of help, so please feel free to join in the task by emailing me to create an account and start creating content. &lt;br /&gt;
&lt;br /&gt;
Contact: combustor@combustory.com&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;big&amp;gt;'''Categories'''&amp;lt;/big&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* [[Motorcycles]] (Coming)&lt;br /&gt;
* [[Cars]] &lt;br /&gt;
* [[Trucks]] (Coming)&lt;br /&gt;
* [[Tractors]] (Coming)&lt;br /&gt;
* [[Earth Movers]] (Coming)&lt;br /&gt;
* [[Tanks]] (Coming)&lt;br /&gt;
* [[Airplanes]] (Coming)&lt;br /&gt;
* [[Jets]] (Coming)&lt;br /&gt;
* [[Rockets]] (Coming)&lt;br /&gt;
* [[Helicopters]] (Coming)&lt;br /&gt;
* [[Locomotives]] (Coming)&lt;br /&gt;
* [[General Electronics]]&lt;br /&gt;
&lt;br /&gt;
== Creators Note ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Links ==&lt;/div&gt;</summary>
		<author><name>Combustor</name></author>	</entry>

	</feed>