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

<channel>
	<title>HackDevDotCom &#187; Projects</title>
	<atom:link href="http://hackdev.com/category/projects/feed/" rel="self" type="application/rss+xml" />
	<link>http://hackdev.com</link>
	<description>Hacked Development</description>
	<lastBuildDate>Wed, 25 Jan 2012 23:58:14 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>I&#8217;ve been slacking off&#8230;</title>
		<link>http://hackdev.com/2012/01/slacking-off/</link>
		<comments>http://hackdev.com/2012/01/slacking-off/#comments</comments>
		<pubDate>Wed, 25 Jan 2012 23:58:14 +0000</pubDate>
		<dc:creator>Gues7</dc:creator>
				<category><![CDATA[College]]></category>
		<category><![CDATA[General]]></category>
		<category><![CDATA[Projects]]></category>
		<category><![CDATA[beer]]></category>
		<category><![CDATA[blogging]]></category>
		<category><![CDATA[brewing]]></category>
		<category><![CDATA[college]]></category>
		<category><![CDATA[life]]></category>
		<category><![CDATA[slacking]]></category>

		<guid isPermaLink="false">http://hackdev.com/?p=289</guid>
		<description><![CDATA[I really should get into the habit of updating this site more often, but a few things have been conspiring against me; mostly laziness and lack of motivation to be fair, but there have been some other real-life instances distracting &#8230; <a href="http://hackdev.com/2012/01/slacking-off/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I really should get into the habit of updating this site more often, but a few things have been conspiring against me; mostly laziness and lack of motivation to be fair, but there have been some other real-life instances distracting me from my goal of world domination, err, I meant regular blogging.</p>
<p>I have been working on renovating my house to some extent, adding additional insulation to the rooms that need it whilst giving it a good clearing out&#8230; one skip rental and two trips to the dump have done quite a bit to help me along in this challenge, but there is still more to do&#8230; much, much more.</p>
<p>I got accepted into college and have completed my first semester of study! That is a fairly big time vampire alright, but it is very enjoyable. I&#8217;m currently studying computing, but will select a more specific area after my second semester&#8230; I&#8217;ll definitely be going for software development as the primary role in this.</p>
<p>I&#8217;ve been working on building up my brewery and brewing skills so that I can make lots and lots of delicious beers of all types and strengths, in fact my one and only new years (beers) resolution is to do at lease one brew a month, which at the end of the year if followed through will see me producing 60 gallons of beer. Good thing I&#8217;ve been buying in bulk and picked up a few more kegs!</p>
<p>Being ready for many eventualities is now also higher on my list of objectives as last year alone we had heavy snow that practically stopped the country, and quite serious flooding. Since I live alone I have become more aware that I will require food stores and basic necessities on hand should I be unable to move around too easily.</p>
<p>With a new year bringing along new challenges and opportunities, I intend to be ready for all of it and to take it on with a deep, hearty evil laugh!</p>
]]></content:encoded>
			<wfw:commentRss>http://hackdev.com/2012/01/slacking-off/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Custom Fermentation Controller</title>
		<link>http://hackdev.com/2011/05/custom-fermentation-controller/</link>
		<comments>http://hackdev.com/2011/05/custom-fermentation-controller/#comments</comments>
		<pubDate>Fri, 27 May 2011 04:20:05 +0000</pubDate>
		<dc:creator>Gues7</dc:creator>
				<category><![CDATA[Arduino]]></category>
		<category><![CDATA[Electronics]]></category>
		<category><![CDATA[Home Brewing]]></category>
		<category><![CDATA[Projects]]></category>

		<guid isPermaLink="false">http://hackdev.com/?p=279</guid>
		<description><![CDATA[I have started work on my custom fermentation controller using peltier based thermo-electric elements. If you don&#8217;t know what that is, there is a good article available on wikipedia. The benefit I will find is that for the (hopefully) short &#8230; <a href="http://hackdev.com/2011/05/custom-fermentation-controller/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I have started work on my custom fermentation controller using peltier based thermo-electric elements. If you don&#8217;t know what that is, there is a good article available on<a href="http://en.wikipedia.org/wiki/Thermoelectric_cooling"> wikipedia</a>.</p>
<p>The benefit I will find is that for the (hopefully) short durations that the peltier will need to run, it will be more efficient than just running a fridge through an ATC. The only moving parts will be two cheap computer fans, so it should be cheaper to maintain should something break. It also means that the unit can be built to my exact requirements, which is always a bonus.</p>
<p>The unit it&#8217;s self will be a double ply wooden box with a full front door for inserting/removing the fermenting vessel. The box will most likely be made from 2&#215;4&#8242;s, plywood (probably OSB on the inside), and a load of insulation. My basic idea is to build a frame out of 2&#215;4&#8242;s, fit the internal paneling; fill the crevice with fiberglass, rockwool or polystyrene, and then fit the outer panels. The inside will most likely be sealed with a wood sealant, and then have the joints smeared with caulk, and then coated with a plastic resin coating. This will allow for restricted movement of air (like a fridge) and for waterproofing.</p>
<p>Electronically, the peltier element can both heat and cool by reversing the polarity on the cables. I have purchased almost all of the electronics for this (and some nice new tools <img src='http://hackdev.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> ) and I&#8217;m just waiting on delivery. In it&#8217;s most basic sense, the peltier will be in one of three states, heating, cooling, or off. This will be accomplished using a H-Bridge setup built from FET&#8217;s (think of them as switches). If you would like more information on H-Bridges you can find some good information <a href=" http://www.pyroelectro.com/tutorials/h_bridge_4_transistor/">here</a>.</p>
<p>The unit will also have a 4 digit LED 7 Segment display, a few LED&#8217;s, a few buttons for configuration, a buzzer for an alarm, and will probably be powered from a hacked computer PSU.</p>
<p>I have some of the parts I need here, and I have begun development and testing on them. Unfortunately, I don&#8217;t have the peltiers themselves, or the heatsinks for them, or the display, I do have a temperature sensor, but it is not the correct one. As such, I have been using a serial console and some LED&#8217;s to monitor the states.</p>
<p>Within the software, I have it set up such that a minimum and a maximum temperature can be specified. In addition to this, an alarm temperature can also be specified, in such that if the current temperature exceeds the minimum or the maximum by this value, an alarm sounds.</p>
<p>I think I&#8217;m babbling a little now&#8230;.</p>
<p>Here&#8217;s what it does so far:<br />
The unit powers up, and retrieves the user specified minimum, maximum and differential temperatures from memory (EEPROM).<br />
The unit then measures the current temperature, and will activate the respective heating or cooling logic based on the current temperature (or do nothing if it is within bounds).<br />
If the temperature is above or below the min/max temperature by the differential, it will sound off 3 beeps and continue to take corrective measures.<br />
If the differential is set to 0, it will not sound the alarm.</p>
<p>There is also functionality to store the users parameters persistently between sessions.</p>
<p>Here&#8217;s what I have to make it do:<br />
Display the current temperature on the display (which I don&#8217;t have yet).<br />
Provide a configuration menu for the user to input the min/max/dif temperatures.<br />
Provide a configuration menu for the user to input the cycle time and jitter time (explained below).<br />
Port it from the development platform (Arduino) to a bog-standard microcontroller (PIC or AVR, or MSP430).<br />
Design &amp; Test the H-Bridge Circuitry.<br />
Get some circuit boards made <img src='http://hackdev.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>The cycle time is the delay the system pauses for at the end of each cycle, realistically this code could run thousands of times a second, and there is no need. So rather than do that and waste power, the circuit will sample every X number of seconds. (Currently hard set to 1 second)</p>
<p>The jitter time (or dampening time for you engineers!) is when the system changes state from heating to idle, idle to heating, idle to cooling, or cooling to idle. Ideally, this delay should be slightly longer than the normal cycle time to allow for some measurable change to take effect. This will also cut out on a temperature being a point of a degree off, activating another state, then deactivating the state almost straight away, and ending up being a point of a degree out again a second later. (Currently hard set to 5 seconds).</p>
<p>Are there any other features that you think I should implement? It will be easier to do now than when I have it all done and have to rework code to add a new feature&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://hackdev.com/2011/05/custom-fermentation-controller/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Updated Black Ops RCON</title>
		<link>http://hackdev.com/2010/11/updated-black-ops-rcon/</link>
		<comments>http://hackdev.com/2010/11/updated-black-ops-rcon/#comments</comments>
		<pubDate>Sun, 14 Nov 2010 16:39:50 +0000</pubDate>
		<dc:creator>Gues7</dc:creator>
				<category><![CDATA[Fixes / Patches]]></category>
		<category><![CDATA[Game Server]]></category>
		<category><![CDATA[Gaming]]></category>
		<category><![CDATA[General]]></category>
		<category><![CDATA[Projects]]></category>
		<category><![CDATA[Roll your own:]]></category>

		<guid isPermaLink="false">http://hackdev.com/?p=233</guid>
		<description><![CDATA[Hey folks, this is just a quick update to let you know I have still been working on this&#8230; as it stands I have implemented two functions which work, and one which doesn&#8217;t. Slowly but surely I will be adding &#8230; <a href="http://hackdev.com/2010/11/updated-black-ops-rcon/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Hey folks, this is just a quick update to let you know I have still been working on this&#8230; as it stands I have implemented two functions which work, and one which doesn&#8217;t. Slowly but surely I will be adding more and more functionality&#8230; unfortunately I don&#8217;t have RCON access to an unranked server at the moment, would anyone like to oblige me on that? <img src='http://hackdev.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>I would also like to mention at this point, that I have not looked into causing errors on the RCON, ie invalid logins etc&#8230; so be warned, while most of this should work, I cannot and will not guarantee it. Also, it is written for Python 2.6, not 3.whatever&#8230; I will be getting a few more people on board to help with this soon and we will be cleaning it up, adding error handling etc&#8230;</p>
<p>Anyways, here is what you have all been waiting for&#8230;.</p>

<div class="wp_syntax"><div class="code"><pre class="python" style="font-family:monospace;"><span style="color: #808080; font-style: italic;">#!/usr/bin/python</span>
&nbsp;
<span style="color: #483d8b;">''</span><span style="color: #483d8b;">'
_______               ________      .___
<span style="color: #000099; font-weight: bold;">\ </span>  _  <span style="color: #000099; font-weight: bold;">\_</span>_  _  ______ <span style="color: #000099; font-weight: bold;">\_</span>____  <span style="color: #000099; font-weight: bold;">\ </span>  __| _/
/  /_<span style="color: #000099; font-weight: bold;">\ </span> <span style="color: #000099; font-weight: bold;">\ </span><span style="color: #000099; font-weight: bold;">\/</span> <span style="color: #000099; font-weight: bold;">\/</span> /    <span style="color: #000099; font-weight: bold;">\ </span> _(__  &amp;lt;  / __ |
<span style="color: #000099; font-weight: bold;">\ </span> <span style="color: #000099; font-weight: bold;">\_</span>/   <span style="color: #000099; font-weight: bold;">\ </span>    /   |  <span style="color: #000099; font-weight: bold;">\/</span>       <span style="color: #000099; font-weight: bold;">\/</span> /_/ |
 <span style="color: #000099; font-weight: bold;">\_</span>____  /<span style="color: #000099; font-weight: bold;">\/</span><span style="color: #000099; font-weight: bold;">\_</span>/|___|  /______  /<span style="color: #000099; font-weight: bold;">\_</span>___ |
       <span style="color: #000099; font-weight: bold;">\/</span>           <span style="color: #000099; font-weight: bold;">\/</span>       <span style="color: #000099; font-weight: bold;">\/</span>      <span style="color: #000099; font-weight: bold;">\/</span>
                    http://hackdev.com
&nbsp;
Author:
    Steven from hackdev.com
&nbsp;
File History:
    09/11/10:
        [+] Initial Inception. Proof of concept written entirely inline that
            allows for a single hard coded command to be sent to the server.
&nbsp;
    10/11/10:
        [+] Creation of functions to handle the sending and receiving of commands.
        [+] Added the ability for users to change passwords in the configuration
            section of the script.
        [+] Broke commands, preambles etc... into variables for easier use &amp;amp; modification.
        [+] Added comments, previous code did not contain comments. ** Important **
    14/11/10:
        [+] Added command boGetPlayerList
        [+] Added command boSayToServer
        [+] Added command boSayToPlayer
        [+] Figured out that not everything has to be done in <span style="color: #000099; font-weight: bold;">\x</span>68<span style="color: #000099; font-weight: bold;">\x</span>65<span style="color: #000099; font-weight: bold;">\x</span>78
&nbsp;
'</span><span style="color: #483d8b;">''</span>
&nbsp;
<span style="color: #ff7700;font-weight:bold;">import</span> <span style="color: #dc143c;">socket</span>       <span style="color: #808080; font-style: italic;">#Used for creating the UDP sockets</span>
&nbsp;
<span style="color: #808080; font-style: italic;">#-----------------------------------------------------------------------------------</span>
<span style="color: #808080; font-style: italic;">#   User Configurable Options</span>
<span style="color: #808080; font-style: italic;">#-----------------------------------------------------------------------------------</span>
&nbsp;
boHost          = <span style="color: #483d8b;">&quot;&quot;</span>      <span style="color: #808080; font-style: italic;">#The server IP</span>
boPort          = <span style="color: #ff4500;">3074</span>                  <span style="color: #808080; font-style: italic;">#The server Port</span>
boPassword      = <span style="color: #483d8b;">&quot;&quot;</span>              <span style="color: #808080; font-style: italic;">#The RCON Password</span>
&nbsp;
<span style="color: #808080; font-style: italic;">#-----------------------------------------------------------------------------------</span>
<span style="color: #808080; font-style: italic;">#   End User Configurable Options</span>
<span style="color: #808080; font-style: italic;">#-----------------------------------------------------------------------------------</span>
&nbsp;
svrAddress = <span style="color: black;">&#40;</span>boHost, boPort<span style="color: black;">&#41;</span>           <span style="color: #808080; font-style: italic;">#Used to create a tuple of host &amp;amp; port</span>
&nbsp;
<span style="color: #808080; font-style: italic;">#-----------------------------------------------------------------------------------</span>
<span style="color: #808080; font-style: italic;">#   Command Definitions, sorry about the variables :(</span>
<span style="color: #808080; font-style: italic;">#-----------------------------------------------------------------------------------</span>
<span style="color: #ff7700;font-weight:bold;">global</span> cmdPreamble
cmdPreamble  = <span style="color: #483d8b;">&quot;<span style="color: #000099; font-weight: bold;">\x</span>ff<span style="color: #000099; font-weight: bold;">\x</span>ff<span style="color: #000099; font-weight: bold;">\x</span>ff<span style="color: #000099; font-weight: bold;">\x</span>ff<span style="color: #000099; font-weight: bold;">\x</span>00&quot;</span>                       <span style="color: #808080; font-style: italic;">#Preamble used to prefix the packet</span>
<span style="color: #ff7700;font-weight:bold;">global</span> cmdSeporator
cmdSeporator = <span style="color: #483d8b;">&quot;<span style="color: #000099; font-weight: bold;">\x</span>20&quot;</span>                                       <span style="color: #808080; font-style: italic;">#Seporator used between password &amp;amp; command</span>
<span style="color: #ff7700;font-weight:bold;">global</span> cmdPostamble
cmdPostamble = <span style="color: #483d8b;">&quot;<span style="color: #000099; font-weight: bold;">\0</span>0&quot;</span>                                        <span style="color: #808080; font-style: italic;">#Ending of the packet, end of command</span>
&nbsp;
<span style="color: #808080; font-style: italic;">#-----------------------------------------------------------------------------------</span>
<span style="color: #808080; font-style: italic;">#   Socket Generation</span>
<span style="color: #808080; font-style: italic;">#-----------------------------------------------------------------------------------</span>
udpSock = <span style="color: #dc143c;">socket</span>.<span style="color: #dc143c;">socket</span><span style="color: black;">&#40;</span><span style="color: #dc143c;">socket</span>.<span style="color: black;">AF_INET</span>, <span style="color: #dc143c;">socket</span>.<span style="color: black;">SOCK_DGRAM</span><span style="color: black;">&#41;</span>
&nbsp;
<span style="color: #808080; font-style: italic;">#-----------------------------------------------------------------------------------</span>
<span style="color: #808080; font-style: italic;">#   Function used to send commands to the server, function returns the</span>
<span style="color: #808080; font-style: italic;">#   data returned from the query, unformatted...</span>
<span style="color: #808080; font-style: italic;">#-----------------------------------------------------------------------------------</span>
&nbsp;
<span style="color: #ff7700;font-weight:bold;">def</span> boSendCommand<span style="color: black;">&#40;</span>boCommand, boArgument=<span style="color: #ff4500;">0</span>, recvBufferSize=<span style="color: #ff4500;">4096</span><span style="color: black;">&#41;</span>:
    <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: #ff7700;font-weight:bold;">not</span> boArgument:
        commandBuffer = cmdPreamble + boPassword + cmdSeporator + boCommand + cmdPostamble
    <span style="color: #ff7700;font-weight:bold;">else</span>:
        commandBuffer = cmdPreamble + boPassword + cmdSeporator + boCommand + cmdSeporator + boArgument + cmdPostamble
    boSentBytes = udpSock.<span style="color: black;">sendto</span><span style="color: black;">&#40;</span>commandBuffer, svrAddress<span style="color: black;">&#41;</span>     <span style="color: #808080; font-style: italic;">#Send the data to the server</span>
    <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: black;">&#40;</span>boSentBytes <span style="color: #66cc66;">&amp;</span>lt<span style="color: #66cc66;">;</span> <span style="color: #008000;">len</span><span style="color: black;">&#40;</span>commandBuffer<span style="color: black;">&#41;</span><span style="color: black;">&#41;</span>:                      <span style="color: #808080; font-style: italic;">#Check the num of bytes sent</span>
        <span style="color: #ff7700;font-weight:bold;">print</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;An error was encountered while sending the command %s&quot;</span>, boCommand<span style="color: black;">&#41;</span>
    boRecvBuffer = udpSock.<span style="color: black;">recv</span><span style="color: black;">&#40;</span>recvBufferSize<span style="color: black;">&#41;</span>                 <span style="color: #808080; font-style: italic;">#Receive the data returned</span>
&nbsp;
    <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: #008000;">len</span><span style="color: black;">&#40;</span>boRecvBuffer<span style="color: black;">&#41;</span> <span style="color: #66cc66;">&amp;</span>gt<span style="color: #66cc66;">;</span> <span style="color: #ff4500;">0</span>:                                   <span style="color: #808080; font-style: italic;">#Check to ensure there is something</span>
        <span style="color: #ff7700;font-weight:bold;">return</span> boRecvBuffer                                     <span style="color: #808080; font-style: italic;">#Return the buffer</span>
    <span style="color: #ff7700;font-weight:bold;">else</span>:
        <span style="color: #ff7700;font-weight:bold;">return</span> <span style="color: #ff4500;">0</span>                                                <span style="color: #808080; font-style: italic;">#If theres nothing, return 0</span>
&nbsp;
<span style="color: #ff7700;font-weight:bold;">def</span> boGetPlayerList<span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>:
    playerlist = boSendCommand<span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;teamstatus&quot;</span><span style="color: black;">&#41;</span>
    <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: #ff7700;font-weight:bold;">not</span> playerlist:
        <span style="color: #ff7700;font-weight:bold;">return</span> <span style="color: #ff4500;">0</span>
    <span style="color: #ff7700;font-weight:bold;">else</span>:
        <span style="color: #ff7700;font-weight:bold;">return</span> playerlist
&nbsp;
<span style="color: #ff7700;font-weight:bold;">def</span> boSayToServer<span style="color: black;">&#40;</span>message<span style="color: black;">&#41;</span>:
    <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: #ff7700;font-weight:bold;">not</span> message:
        <span style="color: #ff7700;font-weight:bold;">return</span> <span style="color: #ff4500;">0</span>
    <span style="color: #ff7700;font-weight:bold;">else</span>:
        servermessage = boSendCommand<span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;say&quot;</span>, <span style="color: #483d8b;">'&quot;'</span> + message + <span style="color: #483d8b;">'&quot;'</span><span style="color: black;">&#41;</span>
        <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: #ff7700;font-weight:bold;">not</span> servermessage:
            <span style="color: #ff7700;font-weight:bold;">return</span> <span style="color: #ff4500;">0</span>
        <span style="color: #ff7700;font-weight:bold;">else</span>:
            <span style="color: #ff7700;font-weight:bold;">return</span> servermessage
&nbsp;
<span style="color: #ff7700;font-weight:bold;">def</span> boSayToPlayer<span style="color: black;">&#40;</span>message, playerID<span style="color: black;">&#41;</span>:
    <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: #ff7700;font-weight:bold;">not</span> message <span style="color: #ff7700;font-weight:bold;">or</span> <span style="color: #ff7700;font-weight:bold;">not</span> playerID:
        <span style="color: #ff7700;font-weight:bold;">return</span> <span style="color: #ff4500;">0</span>
    <span style="color: #ff7700;font-weight:bold;">else</span>:
        playermessage = boSendCommand<span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;tell&quot;</span>, playerID + <span style="color: #483d8b;">&quot;<span style="color: #000099; font-weight: bold;">\x</span>20&quot;</span> + <span style="color: #483d8b;">'&quot;'</span> + message + <span style="color: #483d8b;">'&quot;'</span><span style="color: black;">&#41;</span>
        <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: #ff7700;font-weight:bold;">not</span> playermessage:
            <span style="color: #ff7700;font-weight:bold;">return</span> <span style="color: #ff4500;">0</span>
        <span style="color: #ff7700;font-weight:bold;">else</span>:
            <span style="color: #ff7700;font-weight:bold;">return</span> playermessage
&nbsp;
<span style="color: #ff7700;font-weight:bold;">print</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;Playerlist&quot;</span><span style="color: black;">&#41;</span>
myPlayerList = boGetPlayerList<span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
<span style="color: #ff7700;font-weight:bold;">print</span><span style="color: black;">&#40;</span>myPlayerList<span style="color: black;">&#41;</span>
&nbsp;
<span style="color: #ff7700;font-weight:bold;">print</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;Server Message&quot;</span><span style="color: black;">&#41;</span>
myServerMessage = boSayToServer<span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;Testing!&quot;</span><span style="color: black;">&#41;</span>
<span style="color: #ff7700;font-weight:bold;">print</span><span style="color: black;">&#40;</span>myServerMessage<span style="color: black;">&#41;</span>
&nbsp;
<span style="color: #ff7700;font-weight:bold;">print</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;Player Message&quot;</span><span style="color: black;">&#41;</span>
myPlayerMessage = boSayToPlayer<span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;Testing 123&quot;</span>, <span style="color: #483d8b;">&quot;1&quot;</span><span style="color: black;">&#41;</span>
<span style="color: #ff7700;font-weight:bold;">print</span><span style="color: black;">&#40;</span>myPlayerMessage<span style="color: black;">&#41;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://hackdev.com/2010/11/updated-black-ops-rcon/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Hello World via. MSP430 (TI Launchpad)</title>
		<link>http://hackdev.com/2010/09/hello-world-via-msp430-ti-launchpad/</link>
		<comments>http://hackdev.com/2010/09/hello-world-via-msp430-ti-launchpad/#comments</comments>
		<pubDate>Mon, 20 Sep 2010 16:11:35 +0000</pubDate>
		<dc:creator>Gues7</dc:creator>
				<category><![CDATA[Electronics]]></category>
		<category><![CDATA[MSP430]]></category>
		<category><![CDATA[Projects]]></category>
		<category><![CDATA[TI Launchpad]]></category>

		<guid isPermaLink="false">http://hackdev.com/?p=214</guid>
		<description><![CDATA[My box of TI Launchpad&#8217;s arrived on Friday, but I have only had the chance to start playing with them today, naturally the first port of call is to get the hello world application working, as such, here is my &#8230; <a href="http://hackdev.com/2010/09/hello-world-via-msp430-ti-launchpad/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>My box of TI Launchpad&#8217;s arrived on Friday, but I have only had the chance to start playing with them today, naturally the first port of call is to get the hello world application working, as such, here is my version of Hello World for the MSP430 running on the TI Launchpad.</p>
<p>Just for those who don&#8217;t know or are unsure, the default Hello World application for a Microcontroller is to get an LED blinking.</p>

<div class="wp_syntax"><div class="code"><pre class="c" style="font-family:monospace;"><span style="color: #808080; font-style: italic;">/*
&nbsp;
$TITLE		:	TI Launchpad MSP430G2231 Flashing LED Example.
&nbsp;
$Author		:	Steven from http://hackdev.com
$Version	:	0001
&nbsp;
*/</span>
&nbsp;
<span style="color: #339933;">#include </span>
&nbsp;
<span style="color: #993333;">int</span> main<span style="color: #009900;">&#40;</span><span style="color: #993333;">void</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">//Stop Watchdog Timer</span>
	WDTCTL <span style="color: #339933;">=</span> WDTPW <span style="color: #339933;">+</span> WDTHOLD<span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">//Configure Port Directions</span>
	P1DIR <span style="color: #339933;">|=</span> <span style="color: #208080;">0x41</span><span style="color: #339933;">;</span>		<span style="color: #666666; font-style: italic;">//0100 0001</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">//Loop forever</span>
	<span style="color: #b1b100;">for</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">;;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #666666; font-style: italic;">//Produce a delay</span>
		<span style="color: #993333;">unsigned</span> <span style="color: #993333;">int</span> i <span style="color: #339933;">=</span> <span style="color: #0000dd;">50000</span><span style="color: #339933;">;</span>
		<span style="color: #b1b100;">while</span><span style="color: #009900;">&#40;</span>i<span style="color: #339933;">&gt;</span><span style="color: #0000dd;">0</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			i<span style="color: #339933;">--;</span>
		<span style="color: #009900;">&#125;</span>
&nbsp;
		<span style="color: #666666; font-style: italic;">//Toggle the LED pins using XOR.</span>
		P1OUT <span style="color: #339933;">^=</span> <span style="color: #208080;">0x41</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #009900;">&#125;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://hackdev.com/2010/09/hello-world-via-msp430-ti-launchpad/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>The Arduino Brain Machine</title>
		<link>http://hackdev.com/2010/09/the-arduino-brain-machine/</link>
		<comments>http://hackdev.com/2010/09/the-arduino-brain-machine/#comments</comments>
		<pubDate>Fri, 03 Sep 2010 17:33:42 +0000</pubDate>
		<dc:creator>Gues7</dc:creator>
				<category><![CDATA[Arduino]]></category>
		<category><![CDATA[Electronics]]></category>
		<category><![CDATA[Projects]]></category>

		<guid isPermaLink="false">http://hackdev.com/?p=188</guid>
		<description><![CDATA[First off, if this thing messes up your brain, its your own fault and not my problem. Getting back to my late night hackery, I was kinda bored last night and unable to sleep; but I was previously reading about &#8230; <a href="http://hackdev.com/2010/09/the-arduino-brain-machine/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>First off, if this thing messes up your brain, its your own fault and not my problem.</p>
<p>Getting back to my late night hackery, I was kinda bored last night and unable to sleep; but I was previously reading about <strong>brain machines</strong> (Thanks Hack A Day), they seem to be getting quite popular all of a sudden. So I decided to try my hand at it and I built a very basic pair of glasses, and a little bit of <strong>Arduino</strong><strong> code</strong> to pulse the lights at a specific frequency. I did like the affect it had, it was very relaxing; which is strange to say the least as your having bright lights flashing in your eyes&#8230; Anyways, I then remembered Mitch Altman&#8217;s <strong>brain machine</strong> based on a POV kit from LadaAda and set out to find the <strong>source code</strong> for it. I was not disappointed, and immediately began porting it over to the <strong>Arduino</strong>. Now, keep in mind this was done at 3am with NO CAFFEINE and a bit of sleep deprivation thrown in so there probably will be bugs and discrepancies. The things I know of so far are:</p>
<ul>
<li>No Button to start the cycle</li>
<li>Doesnt stop (or maybe it does and I just didn&#8217;t give it long enough)</li>
<li>Frequencies are not exactly the same (But I think they were a few points of a Hz off due to the timing of the AVR)</li>
</ul>
<p>I have not tested the audio bit yet as I was too lazy to fire up the soldering iron again to build the audio filter circuit.</p>

<div class="wp_syntax"><div class="code"><pre class="c" style="font-family:monospace;"><span style="color: #993333;">int</span> leftEye <span style="color: #339933;">=</span> <span style="color: #0000dd;">13</span><span style="color: #339933;">;</span>
<span style="color: #993333;">int</span> rightEye <span style="color: #339933;">=</span> <span style="color: #0000dd;">12</span><span style="color: #339933;">;</span>
<span style="color: #993333;">int</span> leftEar <span style="color: #339933;">=</span> <span style="color: #0000dd;">11</span><span style="color: #339933;">;</span>
<span style="color: #993333;">int</span> rightEar <span style="color: #339933;">=</span> <span style="color: #0000dd;">10</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #993333;">char</span> brainType<span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span>
  <span style="color: #ff0000;">'b'</span><span style="color: #339933;">,</span>
  <span style="color: #ff0000;">'a'</span><span style="color: #339933;">,</span>
  <span style="color: #ff0000;">'b'</span><span style="color: #339933;">,</span>
  <span style="color: #ff0000;">'a'</span><span style="color: #339933;">,</span>
  <span style="color: #ff0000;">'b'</span><span style="color: #339933;">,</span>
  <span style="color: #ff0000;">'a'</span><span style="color: #339933;">,</span>
  <span style="color: #ff0000;">'b'</span><span style="color: #339933;">,</span>
  <span style="color: #ff0000;">'a'</span><span style="color: #339933;">,</span>
  <span style="color: #ff0000;">'b'</span><span style="color: #339933;">,</span>
  <span style="color: #ff0000;">'a'</span><span style="color: #339933;">,</span>
  <span style="color: #ff0000;">'t'</span><span style="color: #339933;">,</span>
  <span style="color: #ff0000;">'a'</span><span style="color: #339933;">,</span>
  <span style="color: #ff0000;">'t'</span><span style="color: #339933;">,</span>
  <span style="color: #ff0000;">'a'</span><span style="color: #339933;">,</span>
  <span style="color: #ff0000;">'t'</span><span style="color: #339933;">,</span>
  <span style="color: #ff0000;">'a'</span><span style="color: #339933;">,</span>
  <span style="color: #ff0000;">'t'</span><span style="color: #339933;">,</span>
  <span style="color: #ff0000;">'a'</span><span style="color: #339933;">,</span>
  <span style="color: #ff0000;">'b'</span><span style="color: #339933;">,</span>
  <span style="color: #ff0000;">'a'</span><span style="color: #339933;">,</span>
  <span style="color: #ff0000;">'t'</span><span style="color: #339933;">,</span>
  <span style="color: #ff0000;">'d'</span><span style="color: #339933;">,</span>
  <span style="color: #ff0000;">'t'</span><span style="color: #339933;">,</span>
  <span style="color: #ff0000;">'d'</span><span style="color: #339933;">,</span>
  <span style="color: #ff0000;">'t'</span><span style="color: #339933;">,</span>
  <span style="color: #ff0000;">'d'</span><span style="color: #339933;">,</span>
  <span style="color: #ff0000;">'t'</span><span style="color: #339933;">,</span>
  <span style="color: #ff0000;">'a'</span><span style="color: #339933;">,</span>
  <span style="color: #ff0000;">'b'</span><span style="color: #339933;">,</span>
  <span style="color: #ff0000;">'a'</span><span style="color: #339933;">,</span>
  <span style="color: #ff0000;">'t'</span><span style="color: #339933;">,</span>
  <span style="color: #ff0000;">'a'</span><span style="color: #339933;">,</span>
  <span style="color: #ff0000;">'b'</span><span style="color: #339933;">,</span>
  <span style="color: #ff0000;">'a'</span><span style="color: #339933;">,</span>
  <span style="color: #ff0000;">'b'</span><span style="color: #339933;">,</span>
  <span style="color: #ff0000;">'a'</span><span style="color: #339933;">,</span>
  <span style="color: #ff0000;">'b'</span><span style="color: #339933;">,</span>
  <span style="color: #ff0000;">'a'</span><span style="color: #339933;">,</span>
  <span style="color: #ff0000;">'b'</span><span style="color: #339933;">,</span>
  <span style="color: #ff0000;">'a'</span><span style="color: #339933;">,</span>
  <span style="color: #ff0000;">'b'</span><span style="color: #339933;">,</span>
  <span style="color: #ff0000;">'a'</span><span style="color: #339933;">,</span>
  <span style="color: #ff0000;">'b'</span><span style="color: #339933;">,</span>
  <span style="color: #ff0000;">'0'</span>
<span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
<span style="color: #993333;">unsigned</span> <span style="color: #993333;">long</span> <span style="color: #993333;">int</span> brainDuration<span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span>
  <span style="color: #0000dd;">600000</span> <span style="color: #339933;">,</span>
  <span style="color: #0000dd;">100000</span> <span style="color: #339933;">,</span>
  <span style="color: #0000dd;">200000</span> <span style="color: #339933;">,</span>
  <span style="color: #0000dd;">150000</span> <span style="color: #339933;">,</span>
  <span style="color: #0000dd;">150000</span> <span style="color: #339933;">,</span>
  <span style="color: #0000dd;">200000</span> <span style="color: #339933;">,</span>
  <span style="color: #0000dd;">100000</span> <span style="color: #339933;">,</span>
  <span style="color: #0000dd;">300000</span> <span style="color: #339933;">,</span>
  <span style="color: #0000dd;">50000</span> <span style="color: #339933;">,</span>
  <span style="color: #0000dd;">600000</span> <span style="color: #339933;">,</span>
  <span style="color: #0000dd;">100000</span> <span style="color: #339933;">,</span>
  <span style="color: #0000dd;">300000</span> <span style="color: #339933;">,</span>
  <span style="color: #0000dd;">200000</span> <span style="color: #339933;">,</span>
  <span style="color: #0000dd;">300000</span> <span style="color: #339933;">,</span>
  <span style="color: #0000dd;">300000</span> <span style="color: #339933;">,</span>
  <span style="color: #0000dd;">150000</span> <span style="color: #339933;">,</span>
  <span style="color: #0000dd;">600000</span> <span style="color: #339933;">,</span>
  <span style="color: #0000dd;">150000</span> <span style="color: #339933;">,</span>
  <span style="color: #0000dd;">10000</span> <span style="color: #339933;">,</span>
  <span style="color: #0000dd;">150000</span> <span style="color: #339933;">,</span>
  <span style="color: #0000dd;">600000</span> <span style="color: #339933;">,</span>
  <span style="color: #0000dd;">10000</span> <span style="color: #339933;">,</span>
  <span style="color: #0000dd;">100000</span> <span style="color: #339933;">,</span>
  <span style="color: #0000dd;">10000</span> <span style="color: #339933;">,</span>
  <span style="color: #0000dd;">100000</span> <span style="color: #339933;">,</span>
  <span style="color: #0000dd;">10000</span> <span style="color: #339933;">,</span>
  <span style="color: #0000dd;">300000</span> <span style="color: #339933;">,</span>
  <span style="color: #0000dd;">150000</span> <span style="color: #339933;">,</span>
  <span style="color: #0000dd;">10000</span> <span style="color: #339933;">,</span>
  <span style="color: #0000dd;">150000</span> <span style="color: #339933;">,</span>
  <span style="color: #0000dd;">300000</span> <span style="color: #339933;">,</span>
  <span style="color: #0000dd;">150000</span> <span style="color: #339933;">,</span>
  <span style="color: #0000dd;">10000</span> <span style="color: #339933;">,</span>
  <span style="color: #0000dd;">200000</span> <span style="color: #339933;">,</span>
  <span style="color: #0000dd;">50000</span> <span style="color: #339933;">,</span>
  <span style="color: #0000dd;">200000</span> <span style="color: #339933;">,</span>
  <span style="color: #0000dd;">150000</span> <span style="color: #339933;">,</span>
  <span style="color: #0000dd;">150000</span> <span style="color: #339933;">,</span>
  <span style="color: #0000dd;">200000</span> <span style="color: #339933;">,</span>
  <span style="color: #0000dd;">100000</span> <span style="color: #339933;">,</span>
  <span style="color: #0000dd;">250000</span> <span style="color: #339933;">,</span>
  <span style="color: #0000dd;">50000</span> <span style="color: #339933;">,</span>
  <span style="color: #0000dd;">600000</span>
<span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #993333;">void</span> delay_one_tenth_ms<span style="color: #009900;">&#40;</span><span style="color: #993333;">unsigned</span> <span style="color: #993333;">long</span> <span style="color: #993333;">int</span> ms<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  delayMicroseconds<span style="color: #009900;">&#40;</span>ms<span style="color: #339933;">*</span><span style="color: #0000dd;">100</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #993333;">void</span> blink_LEDs<span style="color: #009900;">&#40;</span><span style="color: #993333;">int</span> duration<span style="color: #339933;">,</span> <span style="color: #993333;">int</span> onTime<span style="color: #339933;">,</span> <span style="color: #993333;">int</span> offTime<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  <span style="color: #b1b100;">for</span><span style="color: #009900;">&#40;</span><span style="color: #993333;">int</span> i<span style="color: #339933;">=</span><span style="color: #0000dd;">0</span><span style="color: #339933;">;</span> i<span style="color: #339933;">&amp;</span>lt<span style="color: #339933;">;</span><span style="color: #009900;">&#40;</span>duration<span style="color: #339933;">/</span><span style="color: #009900;">&#40;</span>onTime<span style="color: #339933;">+</span>offTime<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    digitalWrite<span style="color: #009900;">&#40;</span>leftEye<span style="color: #339933;">,</span> HIGH<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    digitalWrite<span style="color: #009900;">&#40;</span>rightEye<span style="color: #339933;">,</span> HIGH<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    delay_one_tenth_ms<span style="color: #009900;">&#40;</span>onTime<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    digitalWrite<span style="color: #009900;">&#40;</span>leftEye<span style="color: #339933;">,</span> LOW<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    digitalWrite<span style="color: #009900;">&#40;</span>rightEye<span style="color: #339933;">,</span> LOW<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    delay_one_tenth_ms<span style="color: #009900;">&#40;</span>offTime<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #993333;">void</span> do_brainwave_element<span style="color: #009900;">&#40;</span><span style="color: #993333;">int</span> index<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span>brainType<span style="color: #009900;">&#91;</span>index<span style="color: #009900;">&#93;</span> <span style="color: #339933;">==</span> <span style="color: #ff0000;">'b'</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    blink_LEDs<span style="color: #009900;">&#40;</span>brainDuration<span style="color: #009900;">&#91;</span>index<span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #0000dd;">347</span><span style="color: #339933;">,</span> <span style="color: #0000dd;">347</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    tone<span style="color: #009900;">&#40;</span>leftEar<span style="color: #339933;">,</span> <span style="color: #0000dd;">14</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
&nbsp;
  <span style="color: #b1b100;">else</span> <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>brainType<span style="color: #009900;">&#91;</span>index<span style="color: #009900;">&#93;</span> <span style="color: #339933;">==</span> <span style="color: #ff0000;">'a'</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    blink_LEDs<span style="color: #009900;">&#40;</span>brainDuration<span style="color: #009900;">&#91;</span>index<span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #0000dd;">451</span><span style="color: #339933;">,</span> <span style="color: #0000dd;">451</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    tone<span style="color: #009900;">&#40;</span>leftEar<span style="color: #339933;">,</span> <span style="color: #0000dd;">11</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
&nbsp;
  <span style="color: #b1b100;">else</span> <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>brainType<span style="color: #009900;">&#91;</span>index<span style="color: #009900;">&#93;</span> <span style="color: #339933;">==</span> <span style="color: #ff0000;">'t'</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    blink_LEDs<span style="color: #009900;">&#40;</span>brainDuration<span style="color: #009900;">&#91;</span>index<span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #0000dd;">835</span><span style="color: #339933;">,</span> <span style="color: #0000dd;">835</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    tone<span style="color: #009900;">&#40;</span>leftEar<span style="color: #339933;">,</span> <span style="color: #0000dd;">6</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
&nbsp;
  <span style="color: #b1b100;">else</span> <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>brainType<span style="color: #009900;">&#91;</span>index<span style="color: #009900;">&#93;</span> <span style="color: #339933;">==</span> <span style="color: #ff0000;">'d'</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    blink_LEDs<span style="color: #009900;">&#40;</span>brainDuration<span style="color: #009900;">&#91;</span>index<span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #0000dd;">2253</span><span style="color: #339933;">,</span> <span style="color: #0000dd;">2253</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    tone<span style="color: #009900;">&#40;</span>leftEar<span style="color: #339933;">,</span> <span style="color: #0000dd;">2</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
&nbsp;
  <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #b1b100;">return</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #993333;">void</span> setup<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  pinMode<span style="color: #009900;">&#40;</span>leftEye<span style="color: #339933;">,</span> OUTPUT<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  pinMode<span style="color: #009900;">&#40;</span>rightEye<span style="color: #339933;">,</span> OUTPUT<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #993333;">void</span> loop<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  tone<span style="color: #009900;">&#40;</span>rightEar<span style="color: #339933;">,</span> <span style="color: #0000dd;">400</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #993333;">int</span> j<span style="color: #339933;">=</span><span style="color: #0000dd;">0</span><span style="color: #339933;">;</span>
  <span style="color: #b1b100;">while</span><span style="color: #009900;">&#40;</span>brainType<span style="color: #009900;">&#91;</span>j<span style="color: #009900;">&#93;</span> <span style="color: #339933;">!=</span> <span style="color: #0000dd;">0</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    do_brainwave_element<span style="color: #009900;">&#40;</span>j<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    noTone<span style="color: #009900;">&#40;</span>leftEar<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    j<span style="color: #339933;">++;</span>
  <span style="color: #009900;">&#125;</span>
  noTone<span style="color: #009900;">&#40;</span>rightEar<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>Now, I didn&#8217;t bother trying to figure out why the Arduino IDE was fighting with me over the struct, so I just made two indexed arrays instead (remember, no caffeine). Also, this code is not complete. It is all based on Mitch Altman&#8217;s <strong>brain machine code</strong>, posted below.</p>

<div class="wp_syntax"><div class="code"><pre class="c" style="font-family:monospace;"><span style="color: #808080; font-style: italic;">/*
Sound &amp;amp; Light Machine
Firmware
for use with ATtiny2313
Make Magazine issue #10
Mitch Altman
19-Mar-07
*/</span>
&nbsp;
<span style="color: #339933;">#include              // this contains all the IO port definitions</span>
<span style="color: #339933;">#include       // definitions for interrupts</span>
<span style="color: #339933;">#include           // definitions for power-down modes</span>
<span style="color: #339933;">#include        // definitions or keeping constants in program memory</span>
&nbsp;
<span style="color: #339933;">#define TIMER0_PRESCALE_1 1</span>
<span style="color: #339933;">#define TIMER0_PRESCALE_8 2</span>
<span style="color: #339933;">#define TIMER0_PRESCALE_64 3</span>
<span style="color: #339933;">#define TIMER0_PRESCALE_256 4</span>
<span style="color: #339933;">#define TIMER0_PRESCALE_1024 5</span>
<span style="color: #339933;">#define TIMER1_PRESCALE_1 1</span>
<span style="color: #339933;">#define TIMER1_PRESCALE_8 2</span>
<span style="color: #339933;">#define TIMER1_PRESCALE_64 3</span>
<span style="color: #339933;">#define TIMER1_PRESCALE_256 4</span>
<span style="color: #339933;">#define TIMER1_PRESCALE_1024 5</span>
&nbsp;
<span style="color: #808080; font-style: italic;">/*
The hardware for this project is very simple:
     ATtiny2313 has 20 pins:
       pin 1   connects to serial port programming circuitry
       pin 10  ground
       pin 12  PB0 - Left eye LED1
       pin 13  PB1 - Right eye LED1
       pin 14  OC0A - Left ear speaker (base-frequency)
       pin 15  OC1A - Right ear speaker (Offset Frequencies for binaural beats)
       pin 17  connects to serial port programming circuitry
       pin 18  connects to serial port programming circuitry
       pin 19  connects to serial port programming circuitry
       pin 20  +3v
    All other pins are unused
&nbsp;
    This firmware requires that the clock frequency of the ATtiny
      is the default that it is shipped with:  8.0MHz
*/</span>
&nbsp;
<span style="color: #808080; font-style: italic;">/*
The C compiler creates code that will transfer all constants into RAM when the microcontroller
resets.  Since this firmware has a table (brainwaveTab) that is too large to transfer into RAM,
the C compiler needs to be told to keep it in program memory space.  This is accomplished by
the macro PROGMEM (this is used, below, in the definition for the brainwaveTab).  Since the
C compiler assumes that constants are in RAM, rather than in program memory, when accessing
the brainwaveTab, we need to use the pgm_read_byte() and pgm_read_dword() macros, and we need
to use the brainwveTab as an address, i.e., precede it with &quot;&amp;amp;&quot;.  For example, to access
brainwaveTab[3].bwType, which is a byte, this is how to do it:
     pgm_read_byte( &amp;amp;brainwaveTab[3].bwType );
And to access brainwaveTab[3].bwDuration, which is a double-word, this is how to do it:
     pgm_read_dword( &amp;amp;brainwaveTab[3].bwDuration );
*/</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// table of values for meditation</span>
<span style="color: #666666; font-style: italic;">//   start with lots of Beta (awake / conscious)</span>
<span style="color: #666666; font-style: italic;">//   add Alpha (dreamy / trancy to connect with subconscious Theta that'll be coming up)</span>
<span style="color: #666666; font-style: italic;">//   reduce Beta (less conscious)</span>
<span style="color: #666666; font-style: italic;">//   start adding Theta (more subconscious)</span>
<span style="color: #666666; font-style: italic;">//   pulse in some Delta (creativity)</span>
<span style="color: #666666; font-style: italic;">//   and then reverse the above to come up refreshed</span>
<span style="color: #993333;">struct</span> brainwaveElement <span style="color: #009900;">&#123;</span>
  <span style="color: #993333;">char</span> bwType<span style="color: #339933;">;</span>  <span style="color: #666666; font-style: italic;">// 'a' for Alpha, 'b' for Beta, 't' for Theta, or 'd' for Delta ('0' signifies last entry in table</span>
  <span style="color: #993333;">unsigned</span> <span style="color: #993333;">long</span> <span style="color: #993333;">int</span> bwDuration<span style="color: #339933;">;</span>  <span style="color: #666666; font-style: italic;">// Duration of this Brainwave Type (divide by 10,000 to get seconds)</span>
<span style="color: #009900;">&#125;</span> <span style="color: #993333;">const</span> brainwaveTab<span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> PROGMEM <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span>
  <span style="color: #009900;">&#123;</span> <span style="color: #ff0000;">'b'</span><span style="color: #339933;">,</span> <span style="color: #0000dd;">600000</span> <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
  <span style="color: #009900;">&#123;</span> <span style="color: #ff0000;">'a'</span><span style="color: #339933;">,</span> <span style="color: #0000dd;">100000</span> <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
  <span style="color: #009900;">&#123;</span> <span style="color: #ff0000;">'b'</span><span style="color: #339933;">,</span> <span style="color: #0000dd;">200000</span> <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
  <span style="color: #009900;">&#123;</span> <span style="color: #ff0000;">'a'</span><span style="color: #339933;">,</span> <span style="color: #0000dd;">150000</span> <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
  <span style="color: #009900;">&#123;</span> <span style="color: #ff0000;">'b'</span><span style="color: #339933;">,</span> <span style="color: #0000dd;">150000</span> <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
  <span style="color: #009900;">&#123;</span> <span style="color: #ff0000;">'a'</span><span style="color: #339933;">,</span> <span style="color: #0000dd;">200000</span> <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
  <span style="color: #009900;">&#123;</span> <span style="color: #ff0000;">'b'</span><span style="color: #339933;">,</span> <span style="color: #0000dd;">100000</span> <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
  <span style="color: #009900;">&#123;</span> <span style="color: #ff0000;">'a'</span><span style="color: #339933;">,</span> <span style="color: #0000dd;">300000</span> <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
  <span style="color: #009900;">&#123;</span> <span style="color: #ff0000;">'b'</span><span style="color: #339933;">,</span>  <span style="color: #0000dd;">50000</span> <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
  <span style="color: #009900;">&#123;</span> <span style="color: #ff0000;">'a'</span><span style="color: #339933;">,</span> <span style="color: #0000dd;">600000</span> <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
  <span style="color: #009900;">&#123;</span> <span style="color: #ff0000;">'t'</span><span style="color: #339933;">,</span> <span style="color: #0000dd;">100000</span> <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
  <span style="color: #009900;">&#123;</span> <span style="color: #ff0000;">'a'</span><span style="color: #339933;">,</span> <span style="color: #0000dd;">300000</span> <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
  <span style="color: #009900;">&#123;</span> <span style="color: #ff0000;">'t'</span><span style="color: #339933;">,</span> <span style="color: #0000dd;">200000</span> <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
  <span style="color: #009900;">&#123;</span> <span style="color: #ff0000;">'a'</span><span style="color: #339933;">,</span> <span style="color: #0000dd;">300000</span> <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
  <span style="color: #009900;">&#123;</span> <span style="color: #ff0000;">'t'</span><span style="color: #339933;">,</span> <span style="color: #0000dd;">300000</span> <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
  <span style="color: #009900;">&#123;</span> <span style="color: #ff0000;">'a'</span><span style="color: #339933;">,</span> <span style="color: #0000dd;">150000</span> <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
  <span style="color: #009900;">&#123;</span> <span style="color: #ff0000;">'t'</span><span style="color: #339933;">,</span> <span style="color: #0000dd;">600000</span> <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
  <span style="color: #009900;">&#123;</span> <span style="color: #ff0000;">'a'</span><span style="color: #339933;">,</span> <span style="color: #0000dd;">150000</span> <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
  <span style="color: #009900;">&#123;</span> <span style="color: #ff0000;">'b'</span><span style="color: #339933;">,</span>  <span style="color: #0000dd;">10000</span> <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
  <span style="color: #009900;">&#123;</span> <span style="color: #ff0000;">'a'</span><span style="color: #339933;">,</span> <span style="color: #0000dd;">150000</span> <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
  <span style="color: #009900;">&#123;</span> <span style="color: #ff0000;">'t'</span><span style="color: #339933;">,</span> <span style="color: #0000dd;">600000</span> <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
  <span style="color: #009900;">&#123;</span> <span style="color: #ff0000;">'d'</span><span style="color: #339933;">,</span>  <span style="color: #0000dd;">10000</span> <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
  <span style="color: #009900;">&#123;</span> <span style="color: #ff0000;">'t'</span><span style="color: #339933;">,</span> <span style="color: #0000dd;">100000</span> <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
  <span style="color: #009900;">&#123;</span> <span style="color: #ff0000;">'d'</span><span style="color: #339933;">,</span>  <span style="color: #0000dd;">10000</span> <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
  <span style="color: #009900;">&#123;</span> <span style="color: #ff0000;">'t'</span><span style="color: #339933;">,</span> <span style="color: #0000dd;">100000</span> <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
  <span style="color: #009900;">&#123;</span> <span style="color: #ff0000;">'d'</span><span style="color: #339933;">,</span>  <span style="color: #0000dd;">10000</span> <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
  <span style="color: #009900;">&#123;</span> <span style="color: #ff0000;">'t'</span><span style="color: #339933;">,</span> <span style="color: #0000dd;">300000</span> <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
  <span style="color: #009900;">&#123;</span> <span style="color: #ff0000;">'a'</span><span style="color: #339933;">,</span> <span style="color: #0000dd;">150000</span> <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
  <span style="color: #009900;">&#123;</span> <span style="color: #ff0000;">'b'</span><span style="color: #339933;">,</span>  <span style="color: #0000dd;">10000</span> <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
  <span style="color: #009900;">&#123;</span> <span style="color: #ff0000;">'a'</span><span style="color: #339933;">,</span> <span style="color: #0000dd;">150000</span> <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
  <span style="color: #009900;">&#123;</span> <span style="color: #ff0000;">'t'</span><span style="color: #339933;">,</span> <span style="color: #0000dd;">300000</span> <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
  <span style="color: #009900;">&#123;</span> <span style="color: #ff0000;">'a'</span><span style="color: #339933;">,</span> <span style="color: #0000dd;">150000</span> <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
  <span style="color: #009900;">&#123;</span> <span style="color: #ff0000;">'b'</span><span style="color: #339933;">,</span>  <span style="color: #0000dd;">10000</span> <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
  <span style="color: #009900;">&#123;</span> <span style="color: #ff0000;">'a'</span><span style="color: #339933;">,</span> <span style="color: #0000dd;">200000</span> <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
  <span style="color: #009900;">&#123;</span> <span style="color: #ff0000;">'b'</span><span style="color: #339933;">,</span>  <span style="color: #0000dd;">50000</span> <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
  <span style="color: #009900;">&#123;</span> <span style="color: #ff0000;">'a'</span><span style="color: #339933;">,</span> <span style="color: #0000dd;">200000</span> <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
  <span style="color: #009900;">&#123;</span> <span style="color: #ff0000;">'b'</span><span style="color: #339933;">,</span> <span style="color: #0000dd;">150000</span> <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
  <span style="color: #009900;">&#123;</span> <span style="color: #ff0000;">'a'</span><span style="color: #339933;">,</span> <span style="color: #0000dd;">150000</span> <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
  <span style="color: #009900;">&#123;</span> <span style="color: #ff0000;">'b'</span><span style="color: #339933;">,</span> <span style="color: #0000dd;">200000</span> <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
  <span style="color: #009900;">&#123;</span> <span style="color: #ff0000;">'a'</span><span style="color: #339933;">,</span> <span style="color: #0000dd;">100000</span> <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
  <span style="color: #009900;">&#123;</span> <span style="color: #ff0000;">'b'</span><span style="color: #339933;">,</span> <span style="color: #0000dd;">250000</span> <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
  <span style="color: #009900;">&#123;</span> <span style="color: #ff0000;">'a'</span><span style="color: #339933;">,</span>  <span style="color: #0000dd;">50000</span> <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
  <span style="color: #009900;">&#123;</span> <span style="color: #ff0000;">'b'</span><span style="color: #339933;">,</span> <span style="color: #0000dd;">600000</span> <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
  <span style="color: #009900;">&#123;</span> <span style="color: #ff0000;">'0'</span><span style="color: #339933;">,</span>      <span style="color: #0000dd;">0</span> <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// This function delays the specified number of 1/10 milliseconds</span>
<span style="color: #993333;">void</span> delay_one_tenth_ms<span style="color: #009900;">&#40;</span><span style="color: #993333;">unsigned</span> <span style="color: #993333;">long</span> <span style="color: #993333;">int</span> ms<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  <span style="color: #993333;">unsigned</span> <span style="color: #993333;">long</span> <span style="color: #993333;">int</span> timer<span style="color: #339933;">;</span>
  <span style="color: #993333;">const</span> <span style="color: #993333;">unsigned</span> <span style="color: #993333;">long</span> <span style="color: #993333;">int</span> DelayCount<span style="color: #339933;">=</span><span style="color: #0000dd;">87</span><span style="color: #339933;">;</span>  <span style="color: #666666; font-style: italic;">// this value was determined by trial and error</span>
&nbsp;
  <span style="color: #b1b100;">while</span> <span style="color: #009900;">&#40;</span>ms <span style="color: #339933;">!=</span> <span style="color: #0000dd;">0</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #666666; font-style: italic;">// Toggling PD0 is done here to force the compiler to do this loop, rather than optimize it away</span>
    <span style="color: #b1b100;">for</span> <span style="color: #009900;">&#40;</span>timer<span style="color: #339933;">=</span><span style="color: #0000dd;">0</span><span style="color: #339933;">;</span> timer <span style="color: #339933;">&amp;</span>lt<span style="color: #339933;">;=</span> DelayCount<span style="color: #339933;">;</span> timer<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>PIND <span style="color: #339933;">|=</span> <span style="color: #208080;">0b0000001</span><span style="color: #339933;">;</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
    ms<span style="color: #339933;">--;</span>
  <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// This function blinks the LEDs (connected to PB0, PB1 - for Left eye, Right eye, respectively)</span>
<span style="color: #666666; font-style: italic;">//   at the rate determined by onTime and offTime</span>
<span style="color: #666666; font-style: italic;">//   and keeps them blinking for the Duration specified (Duration given in 1/10 millisecs)</span>
<span style="color: #666666; font-style: italic;">// This function also acts as a delay for the Duration specified</span>
<span style="color: #993333;">void</span> blink_LEDs<span style="color: #009900;">&#40;</span> <span style="color: #993333;">unsigned</span> <span style="color: #993333;">long</span> <span style="color: #993333;">int</span> duration<span style="color: #339933;">,</span> <span style="color: #993333;">unsigned</span> <span style="color: #993333;">long</span> <span style="color: #993333;">int</span> onTime<span style="color: #339933;">,</span> <span style="color: #993333;">unsigned</span> <span style="color: #993333;">long</span> <span style="color: #993333;">int</span> offTime<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  <span style="color: #b1b100;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #993333;">int</span> i<span style="color: #339933;">=</span><span style="color: #0000dd;">0</span><span style="color: #339933;">;</span> i<span style="color: #339933;">&amp;</span>lt<span style="color: #339933;">;</span><span style="color: #009900;">&#40;</span>duration<span style="color: #339933;">/</span><span style="color: #009900;">&#40;</span>onTime<span style="color: #339933;">+</span>offTime<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>     PORTB <span style="color: #339933;">|=</span> <span style="color: #208080;">0b00000011</span><span style="color: #339933;">;</span>          <span style="color: #666666; font-style: italic;">// turn on LEDs at PB0, PB1     delay_one_tenth_ms(onTime);   //   for onTime     PORTB &amp;amp;= 0b11111100;          // turn off LEDs at PB0, PB1     delay_one_tenth_ms(offTime);  //   for offTime   } } // This function starts the Offset Frequency audio in the Right ear through output OC1A  (using Timer 1) //   to create a binaural beat (between Left and Right ears) for a Brainwave Element //   (the base-frequency of 400.641Hz is already assumed to be playing in the Left ear before calling this function) //   and blinks the LEDs at the same frequency for the Brainwave Element //   and keeps it going for the Duration specified for the Brainwave Element // The timing for the Right ear is done with 16-bit Timer 1 (set up for CTC Mode, toggling output on each compare) //   Output frequency = Fclk / (2 * Prescale * (1 + OCR1A) ) = 8,000,000 / (2 * (1 + OCR1A) ) void do_brainwave_element(int index) {     char brainChr = pgm_read_byte(&amp;amp;brainwaveTab[index].bwType);     if (brainChr == 'b') {          // PORTB &amp;amp;= 0b00001100;  // (for debugging purposes only -- commented out for SLM)          // PORTB |= 0b10000000;       // Beta       // start Timer 1 with the correct Offset Frequency for a binaural beat for the Brainwave Type       //   to Right ear speaker through output OC1A (PB3, pin 15)       OCR1A = 9637;  // T1 generates 415.024Hz, for a binaural beat of 14.4Hz       // delay for the time specified in the table while blinking the LEDs at the correct rate       //   onTime = 34.7ms, offTime = 34.7ms --&amp;gt; 14.4Hz</span>
      blink_LEDs<span style="color: #009900;">&#40;</span> pgm_read_dword<span style="color: #009900;">&#40;</span><span style="color: #339933;">&amp;</span>amp<span style="color: #339933;">;</span>brainwaveTab<span style="color: #009900;">&#91;</span>index<span style="color: #009900;">&#93;</span>.<span style="color: #202020;">bwDuration</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #0000dd;">347</span><span style="color: #339933;">,</span> <span style="color: #0000dd;">347</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      <span style="color: #b1b100;">return</span><span style="color: #339933;">;</span>   <span style="color: #666666; font-style: italic;">// Beta</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #b1b100;">else</span> <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>brainChr <span style="color: #339933;">==</span> <span style="color: #ff0000;">'a'</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
         <span style="color: #666666; font-style: italic;">// PORTB &amp;amp;= 0b00001100;  // (for debugging purposes only -- commented out for SLM)</span>
         <span style="color: #666666; font-style: italic;">// PORTB |= 0b01000000;</span>
      <span style="color: #666666; font-style: italic;">// Alpha</span>
      <span style="color: #666666; font-style: italic;">// start Timer 1 with the correct Offset Frequency for a binaural beat for the Brainwave Type</span>
      <span style="color: #666666; font-style: italic;">//   to Right ear speaker through output OC1A (PB3, pin 15)</span>
      OCR1A <span style="color: #339933;">=</span> <span style="color: #0000dd;">9714</span><span style="color: #339933;">;</span>  <span style="color: #666666; font-style: italic;">// T1 generates 411.734Hz, for a binaural beat of 11.1Hz</span>
      <span style="color: #666666; font-style: italic;">// delay for the time specified in the table while blinking the LEDs at the correct rate</span>
      <span style="color: #666666; font-style: italic;">//   onTime = 45.1ms, offTime = 45.0ms --&amp;gt; 11.1Hz</span>
      blink_LEDs<span style="color: #009900;">&#40;</span> pgm_read_dword<span style="color: #009900;">&#40;</span><span style="color: #339933;">&amp;</span>amp<span style="color: #339933;">;</span>brainwaveTab<span style="color: #009900;">&#91;</span>index<span style="color: #009900;">&#93;</span>.<span style="color: #202020;">bwDuration</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #0000dd;">451</span><span style="color: #339933;">,</span> <span style="color: #0000dd;">450</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      <span style="color: #b1b100;">return</span><span style="color: #339933;">;</span>   <span style="color: #666666; font-style: italic;">// Alpha</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #b1b100;">else</span> <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>brainChr <span style="color: #339933;">==</span> <span style="color: #ff0000;">'t'</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
         <span style="color: #666666; font-style: italic;">// PORTB &amp;amp;= 0b00001100;  // (for debugging purposes only -- commented out for SLM)</span>
         <span style="color: #666666; font-style: italic;">// PORTB |= 0b00100000;</span>
      <span style="color: #666666; font-style: italic;">// Theta</span>
      <span style="color: #666666; font-style: italic;">// start Timer 1 with the correct Offset Frequency for a binaural beat for the Brainwave Type</span>
      <span style="color: #666666; font-style: italic;">//   to Right ear speaker through output OC1A (PB3, pin 15)</span>
      OCR1A <span style="color: #339933;">=</span> <span style="color: #0000dd;">9836</span><span style="color: #339933;">;</span>  <span style="color: #666666; font-style: italic;">// T1 generates 406.628Hz, for a binaural beat of 6.0Hz</span>
      <span style="color: #666666; font-style: italic;">// delay for the time specified in the table while blinking the LEDs at the correct rate</span>
      <span style="color: #666666; font-style: italic;">//   onTime = 83.5ms, offTime = 83.5ms --&amp;gt; 6.0Hz</span>
      blink_LEDs<span style="color: #009900;">&#40;</span> pgm_read_dword<span style="color: #009900;">&#40;</span><span style="color: #339933;">&amp;</span>amp<span style="color: #339933;">;</span>brainwaveTab<span style="color: #009900;">&#91;</span>index<span style="color: #009900;">&#93;</span>.<span style="color: #202020;">bwDuration</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #0000dd;">835</span><span style="color: #339933;">,</span> <span style="color: #0000dd;">835</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      <span style="color: #b1b100;">return</span><span style="color: #339933;">;</span>   <span style="color: #666666; font-style: italic;">// Theta</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #b1b100;">else</span> <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>brainChr <span style="color: #339933;">==</span> <span style="color: #ff0000;">'d'</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
         <span style="color: #666666; font-style: italic;">// PORTB &amp;amp;= 0b00001100;  // (for debugging purposes only -- commented out for SLM)</span>
         <span style="color: #666666; font-style: italic;">// PORTB |= 0b00010000;</span>
      <span style="color: #666666; font-style: italic;">// Delta</span>
      <span style="color: #666666; font-style: italic;">// start Timer 1 with the correct Offset Frequency for a binaural beat for the Brainwave Type</span>
      <span style="color: #666666; font-style: italic;">//   to Right ear speaker through output OC1A (PB3, pin 15)</span>
      OCR1A <span style="color: #339933;">=</span> <span style="color: #0000dd;">9928</span><span style="color: #339933;">;</span>  <span style="color: #666666; font-style: italic;">// T1 generates 402.860Hz, for a binaural beat of 2.2Hz</span>
      <span style="color: #666666; font-style: italic;">// delay for the time specified in the table while blinking the LEDs at the correct rate</span>
      <span style="color: #666666; font-style: italic;">//   onTime = 225.3ms, offTime = 225.3ms --&amp;gt; 2.2Hz</span>
      blink_LEDs<span style="color: #009900;">&#40;</span> pgm_read_dword<span style="color: #009900;">&#40;</span><span style="color: #339933;">&amp;</span>amp<span style="color: #339933;">;</span>brainwaveTab<span style="color: #009900;">&#91;</span>index<span style="color: #009900;">&#93;</span>.<span style="color: #202020;">bwDuration</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #0000dd;">2253</span><span style="color: #339933;">,</span> <span style="color: #0000dd;">2253</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      <span style="color: #b1b100;">return</span><span style="color: #339933;">;</span>   <span style="color: #666666; font-style: italic;">// Delta</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #666666; font-style: italic;">// this should never be executed, since we catch the end of table in the main loop</span>
    <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
         <span style="color: #666666; font-style: italic;">// PORTB &amp;amp;= 0b00001100;  // (for debugging purposes only -- commented out for SLM)</span>
         <span style="color: #666666; font-style: italic;">// PORTB |= 0b00000010;</span>
      <span style="color: #b1b100;">return</span><span style="color: #339933;">;</span>      <span style="color: #666666; font-style: italic;">// end of table</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #993333;">int</span> main<span style="color: #009900;">&#40;</span><span style="color: #993333;">void</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
  TIMSK <span style="color: #339933;">=</span> <span style="color: #208080;">0x00</span><span style="color: #339933;">;</span>  <span style="color: #666666; font-style: italic;">// no Timer interrupts enabled</span>
  DDRB <span style="color: #339933;">=</span> <span style="color: #208080;">0xFF</span><span style="color: #339933;">;</span>   <span style="color: #666666; font-style: italic;">// set all PortB pins as outputs</span>
  PORTB <span style="color: #339933;">=</span> <span style="color: #208080;">0x00</span><span style="color: #339933;">;</span>  <span style="color: #666666; font-style: italic;">// all PORTB output pins Off</span>
&nbsp;
  <span style="color: #666666; font-style: italic;">// start up Base frequency = 400.641Hz on Left ear speaker through output OC0A (using Timer 0)</span>
  <span style="color: #666666; font-style: italic;">//   8-bit Timer 0 OC0A (PB2, pin 14) is set up for CTC mode, toggling output on each compare</span>
  <span style="color: #666666; font-style: italic;">//   Fclk = Clock = 8MHz</span>
  <span style="color: #666666; font-style: italic;">//   Prescale = 256</span>
  <span style="color: #666666; font-style: italic;">//   OCR0A = 38</span>
  <span style="color: #666666; font-style: italic;">//   F = Fclk / (2 * Prescale * (1 + OCR0A) ) = 400.641Hz</span>
  TCCR0A <span style="color: #339933;">=</span> <span style="color: #208080;">0b01000010</span><span style="color: #339933;">;</span>  <span style="color: #666666; font-style: italic;">// COM0A1:0=01 to toggle OC0A on Compare Match</span>
                        <span style="color: #666666; font-style: italic;">// COM0B1:0=00 to disconnect OC0B</span>
                        <span style="color: #666666; font-style: italic;">// bits 3:2 are unused</span>
                        <span style="color: #666666; font-style: italic;">// WGM01:00=10 for CTC Mode (WGM02=0 in TCCR0B)</span>
  TCCR0B <span style="color: #339933;">=</span> <span style="color: #208080;">0b00000100</span><span style="color: #339933;">;</span>  <span style="color: #666666; font-style: italic;">// FOC0A=0 (no force compare)</span>
                        <span style="color: #666666; font-style: italic;">// F0C0B=0 (no force compare)</span>
                        <span style="color: #666666; font-style: italic;">// bits 5:4 are unused</span>
                        <span style="color: #666666; font-style: italic;">// WGM2=0 for CTC Mode (WGM01:00=10 in TCCR0A)</span>
                        <span style="color: #666666; font-style: italic;">// CS02:00=100 for divide by 256 prescaler</span>
  OCR0A <span style="color: #339933;">=</span> <span style="color: #0000dd;">38</span><span style="color: #339933;">;</span>  <span style="color: #666666; font-style: italic;">// to output 400.641Hz on OC0A (PB2, pin 14)</span>
&nbsp;
  <span style="color: #666666; font-style: italic;">// set up T1 to accept Offset Frequencies on Right ear speaker through OC1A (but don't actually start the Timer 1 here)</span>
  <span style="color: #666666; font-style: italic;">//   16-bit Timer 1 OC1A (PB3, pin 15) is set up for CTC mode, toggling output on each compare</span>
  <span style="color: #666666; font-style: italic;">//   Fclk = Clock = 8MHz</span>
  <span style="color: #666666; font-style: italic;">//   Prescale = 1</span>
  <span style="color: #666666; font-style: italic;">//   OCR0A = value for Beta, Alpha, Theta, or Delta (i.e., 9520, 9714, 9836, or 9928)</span>
  <span style="color: #666666; font-style: italic;">//   F = Fclk / (2 * Prescale * (1 + OCR0A) )</span>
  TCCR1A <span style="color: #339933;">=</span> <span style="color: #208080;">0b01000000</span><span style="color: #339933;">;</span>  <span style="color: #666666; font-style: italic;">// COM1A1:0=01 to toggle OC1A on Compare Match</span>
                        <span style="color: #666666; font-style: italic;">// COM1B1:0=00 to disconnect OC1B</span>
                        <span style="color: #666666; font-style: italic;">// bits 3:2 are unused</span>
                        <span style="color: #666666; font-style: italic;">// WGM11:10=00 for CTC Mode (WGM13:12=01 in TCCR1B)</span>
  TCCR1B <span style="color: #339933;">=</span> <span style="color: #208080;">0b00001001</span><span style="color: #339933;">;</span>  <span style="color: #666666; font-style: italic;">// ICNC1=0 (no Noise Canceller)</span>
                        <span style="color: #666666; font-style: italic;">// ICES1=0 (don't care about Input Capture Edge)</span>
                        <span style="color: #666666; font-style: italic;">// bit 5 is unused</span>
                        <span style="color: #666666; font-style: italic;">// WGM13:12=01 for CTC Mode (WGM11:10=00 in TCCR1A)</span>
                        <span style="color: #666666; font-style: italic;">// CS12:10=001 for divide by 1 prescaler</span>
  TCCR1C <span style="color: #339933;">=</span> <span style="color: #208080;">0b00000000</span><span style="color: #339933;">;</span>  <span style="color: #666666; font-style: italic;">// FOC1A=0 (no Force Output Compare for Channel A)</span>
                        <span style="color: #666666; font-style: italic;">// FOC1B=0 (no Force Output Compare for Channel B)</span>
                        <span style="color: #666666; font-style: italic;">// bits 5:0 are unused</span>
&nbsp;
  <span style="color: #666666; font-style: italic;">// loop through entire Brainwave Table of Brainwave Elements</span>
  <span style="color: #666666; font-style: italic;">//   each Brainwave Element consists of a Brainwave Type (Beta, Alpha, Theta, or Delta) and a Duration</span>
  <span style="color: #666666; font-style: italic;">// Seeing the LEDs blink and hearing the binaural beats for the sequence of Brainwave Elements</span>
  <span style="color: #666666; font-style: italic;">//   synchs up the user's brain to follow the sequence (hopefully it is a useful sequence)</span>
  <span style="color: #993333;">int</span> j <span style="color: #339933;">=</span> <span style="color: #0000dd;">0</span><span style="color: #339933;">;</span>
  <span style="color: #b1b100;">while</span> <span style="color: #009900;">&#40;</span>pgm_read_byte<span style="color: #009900;">&#40;</span><span style="color: #339933;">&amp;</span>amp<span style="color: #339933;">;</span>brainwaveTab<span style="color: #009900;">&#91;</span>j<span style="color: #009900;">&#93;</span>.<span style="color: #202020;">bwType</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">!=</span> <span style="color: #ff0000;">'0'</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>  <span style="color: #666666; font-style: italic;">// '0' signifies end of table</span>
    do_brainwave_element<span style="color: #009900;">&#40;</span>j<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    j<span style="color: #339933;">++;</span>
  <span style="color: #009900;">&#125;</span>
&nbsp;
  <span style="color: #666666; font-style: italic;">// Shut down everything and put the CPU to sleep</span>
  TCCR0B <span style="color: #339933;">&amp;</span>amp<span style="color: #339933;">;=</span> <span style="color: #208080;">0b11111000</span><span style="color: #339933;">;</span>  <span style="color: #666666; font-style: italic;">// CS02:CS00=000 to stop Timer0 (turn off audio in Right ear speaker)</span>
  TCCR1B <span style="color: #339933;">&amp;</span>amp<span style="color: #339933;">;=</span> <span style="color: #208080;">0b11111000</span><span style="color: #339933;">;</span>  <span style="color: #666666; font-style: italic;">// CS12:CS10=000 to stop Timer1 (turn off audio in Left ear speaker)</span>
  MCUCR <span style="color: #339933;">|=</span> <span style="color: #208080;">0b00100000</span><span style="color: #339933;">;</span>   <span style="color: #666666; font-style: italic;">// SE=1 (bit 5)</span>
  MCUCR <span style="color: #339933;">|=</span> <span style="color: #208080;">0b00010000</span><span style="color: #339933;">;</span>   <span style="color: #666666; font-style: italic;">// SM1:0=01 to enable Power Down Sleep Mode (bits 6, 4)</span>
  delay_one_tenth_ms<span style="color: #009900;">&#40;</span><span style="color: #0000dd;">10000</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>  <span style="color: #666666; font-style: italic;">// wait 1 second</span>
  PORTB <span style="color: #339933;">=</span> <span style="color: #208080;">0x00</span><span style="color: #339933;">;</span>          <span style="color: #666666; font-style: italic;">// turn off all PORTB outputs</span>
  DDRB <span style="color: #339933;">=</span> <span style="color: #208080;">0x00</span><span style="color: #339933;">;</span>           <span style="color: #666666; font-style: italic;">// make PORTB all inputs</span>
  sleep_cpu<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>           <span style="color: #666666; font-style: italic;">// put CPU into Power Down Sleep Mode</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://hackdev.com/2010/09/the-arduino-brain-machine/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>LED Matrix Displays</title>
		<link>http://hackdev.com/2010/05/led-matrix-displays/</link>
		<comments>http://hackdev.com/2010/05/led-matrix-displays/#comments</comments>
		<pubDate>Sun, 23 May 2010 23:13:47 +0000</pubDate>
		<dc:creator>Gues7</dc:creator>
				<category><![CDATA[Arduino]]></category>
		<category><![CDATA[Projects]]></category>

		<guid isPermaLink="false">http://hackdev.com/?p=157</guid>
		<description><![CDATA[*Updated small bug where I forgot to enable the system afterwards&#8230; I&#8217;ve managed to pick up a few LED matrix displays from Sure Electronics that use the HT1632 LED Matrix driver, as such, I have written a new library for &#8230; <a href="http://hackdev.com/2010/05/led-matrix-displays/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>*Updated small bug where I forgot to enable the system afterwards&#8230;</p>
<p>I&#8217;ve managed to pick up a few LED matrix displays from Sure Electronics that use the HT1632 LED Matrix driver, as such, I have written a new library for the Arduino project to make use of the displays, I haven&#8217;t done anything in relation to generating characters for them or doing any scrolling, but I can now pretty much call all of the features of the handy driver. There is still some work to do on cleaning up the library and adding some more functionality, but it does indeed work as it should. Here is the source&#8230;</p>

<div class="wp_syntax"><div class="code"><pre class="c" style="font-family:monospace;"><span style="color: #808080; font-style: italic;">/*
&nbsp;
    Holtech HT1632 Driver Class (Header)
    Values taken from Datasheet...
&nbsp;
*/</span>
&nbsp;
<span style="color: #339933;">#ifndef HT1632_h</span>
<span style="color: #339933;">#define HT1632_h</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//Data Mode</span>
<span style="color: #339933;">#define HT1632_CTL_COMMAND      0x04    //Preceeds all _COMMANDS_ to the system</span>
<span style="color: #339933;">#define HT1632_CTL_WRITE        0x05    //Write data to the RAM</span>
<span style="color: #339933;">#define HT1632_CTL_READ         0x06    //Read data from the RAM</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//Command Mode</span>
<span style="color: #339933;">#define HT1632_CMD_SYSDIS       0x00    //Turn off system oscillator and LED duty cycle generator</span>
<span style="color: #339933;">#define HT1632_CMD_SYSEN        0x01    //Turn on system oscillator</span>
<span style="color: #339933;">#define HT1632_CMD_LEDOFF       0x02    //Turn off LED duty cycle generator</span>
<span style="color: #339933;">#define HT1632_CMD_LEDON        0x03    //Turn on LED duty cycle generator</span>
<span style="color: #339933;">#define HT1632_CMD_BLINKOFF     0x08    //Turn off blinking function</span>
<span style="color: #339933;">#define HT1632_CMD_BLINKON      0x09    //Turn on blinking function</span>
<span style="color: #339933;">#define HT1632_CMD_SLAVEMODE    0x10    //Set slave mode and clock source from external clock, the system clock input from OSC pin and synchronous signal input from SYN pin</span>
<span style="color: #339933;">#define HT1632_CMD_RCMASTER     0x18    //Set master mode anc clock source from on-chip RC oscillator, the system clock output to OSC pin and synchronous signal output SYN pin</span>
<span style="color: #339933;">#define HT1632_CMD_EXTCLK       0x1C    //System clock source, external</span>
<span style="color: #339933;">#define HT1632_CMD_COM00        0x20    //N-MOS open drain output and 8 COM option</span>
<span style="color: #339933;">#define HT1632_CMD_COM01        0x24    //N-MOS open drain output and 8 COM option</span>
<span style="color: #339933;">#define HT1632_CMD_COM10        0x28    //P-MOS open drain output and 8 COM option</span>
<span style="color: #339933;">#define HT1632_CMD_COM11        0x2C    //P-MOS open drain output and 16 COM option</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//Command Mode - PWM Settings</span>
<span style="color: #339933;">#define HT1632_CMD_PWM01        0xA0    //PWM 1/16 Duty</span>
<span style="color: #339933;">#define HT1632_CMD_PWM02        0xA1    //PWM 2/16 Duty</span>
<span style="color: #339933;">#define HT1632_CMD_PWM03        0xA2    //PWM 3/16 Duty</span>
<span style="color: #339933;">#define HT1632_CMD_PWM04        0xA3    //PWM 4/16 Duty</span>
<span style="color: #339933;">#define HT1632_CMD_PWM05        0xA4    //PWM 5/16 Duty</span>
<span style="color: #339933;">#define HT1632_CMD_PWM06        0xA5    //PWM 6/16 Duty</span>
<span style="color: #339933;">#define HT1632_CMD_PWM07        0xA6    //PWM 7/16 Duty</span>
<span style="color: #339933;">#define HT1632_CMD_PWM08        0xA7    //PWM 8/16 Duty</span>
<span style="color: #339933;">#define HT1632_CMD_PWM09        0xA8    //PWM 9/16 Duty</span>
<span style="color: #339933;">#define HT1632_CMD_PWM10        0xA9    //PWM 10/16 Duty</span>
<span style="color: #339933;">#define HT1632_CMD_PWM11        0xAA    //PWM 11/16 Duty</span>
<span style="color: #339933;">#define HT1632_CMD_PWM12        0xAB    //PWM 12/16 Duty</span>
<span style="color: #339933;">#define HT1632_CMD_PWM13        0xAC    //PWM 13/16 Duty</span>
<span style="color: #339933;">#define HT1632_CMD_PWM14        0xAD    //PWM 14/16 Duty</span>
<span style="color: #339933;">#define HT1632_CMD_PWM15        0xAE    //PWM 15/16 Duty</span>
<span style="color: #339933;">#define HT1632_CMD_PWM16        0xAF    //PWM 16/16 Duty</span>
&nbsp;
<span style="color: #339933;">#include &quot;wProgram.h&quot;</span>
&nbsp;
class HT1632 <span style="color: #009900;">&#123;</span>
    public<span style="color: #339933;">:</span>
        HT1632<span style="color: #009900;">&#40;</span>byte data<span style="color: #339933;">,</span> byte wclock<span style="color: #339933;">,</span> byte chip0<span style="color: #339933;">,</span> byte chip1<span style="color: #339933;">=</span>NULL<span style="color: #339933;">,</span> byte chip2<span style="color: #339933;">=</span>NULL<span style="color: #339933;">,</span> byte chip3<span style="color: #339933;">=</span>NULL<span style="color: #339933;">,</span> byte rclock<span style="color: #339933;">=</span>NULL<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #993333;">void</span> ChipSelect<span style="color: #009900;">&#40;</span>byte chip<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #993333;">void</span> ChipRelease<span style="color: #009900;">&#40;</span>byte chip<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #993333;">void</span> SendCommand<span style="color: #009900;">&#40;</span>byte command<span style="color: #339933;">,</span> byte chip<span style="color: #339933;">=</span><span style="color: #0000dd;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #993333;">void</span> WriteBits<span style="color: #009900;">&#40;</span>byte bits<span style="color: #339933;">,</span> byte mask<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        byte ReadData<span style="color: #009900;">&#40;</span>byte address<span style="color: #339933;">,</span> byte chip<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #993333;">void</span> Clear<span style="color: #009900;">&#40;</span>byte chip<span style="color: #339933;">=</span><span style="color: #0000dd;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #993333;">void</span> WriteData<span style="color: #009900;">&#40;</span>byte address<span style="color: #339933;">,</span> byte data<span style="color: #339933;">,</span> byte chip<span style="color: #339933;">=</span><span style="color: #0000dd;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #993333;">void</span> Init<span style="color: #009900;">&#40;</span>byte chip<span style="color: #339933;">=</span><span style="color: #0000dd;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #993333;">void</span> BlinkMode<span style="color: #009900;">&#40;</span>bool blink<span style="color: #339933;">=</span><span style="color: #000000; font-weight: bold;">false</span><span style="color: #339933;">,</span> byte chip<span style="color: #339933;">=</span><span style="color: #0000dd;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    private<span style="color: #339933;">:</span>
        byte _DATA<span style="color: #339933;">;</span>
        byte _WCLOCK<span style="color: #339933;">;</span>
        byte _RCLOCK<span style="color: #339933;">;</span>
        byte _CHIP0<span style="color: #339933;">;</span>
        byte _CHIP1<span style="color: #339933;">;</span>
        byte _CHIP2<span style="color: #339933;">;</span>
        byte _CHIP3<span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #339933;">#endif</span></pre></div></div>


<div class="wp_syntax"><div class="code"><pre class="cpp" style="font-family:monospace;"><span style="color: #ff0000; font-style: italic;">/*
&nbsp;
    Holtech HT1632 Driver Class
    Some functionality inspired by westfw from this thread: http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1225239439
&nbsp;
*/</span>
&nbsp;
<span style="color: #339900;">#include &quot;wProgram.h&quot;</span>
<span style="color: #339900;">#include &quot;HT1632.h&quot;</span>
&nbsp;
HT1632<span style="color: #008080;">::</span><span style="color: #007788;">HT1632</span><span style="color: #008000;">&#40;</span>byte data, byte wclock, byte chip0, byte chip1, byte chip2, byte chip3, byte rclock<span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span>
    <span style="color: #666666;">//Set the I/O Directions</span>
    pinMode<span style="color: #008000;">&#40;</span>data, OUTPUT<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
    pinMode<span style="color: #008000;">&#40;</span>wclock, OUTPUT<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
    <span style="color: #0000ff;">if</span><span style="color: #008000;">&#40;</span>rclock<span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span>
        pinMode<span style="color: #008000;">&#40;</span>rclock, OUTPUT<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
        _RCLOCK <span style="color: #000080;">=</span> rclock<span style="color: #008080;">;</span>
    <span style="color: #008000;">&#125;</span>
&nbsp;
    pinMode<span style="color: #008000;">&#40;</span>chip0, OUTPUT<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
    digitalWrite<span style="color: #008000;">&#40;</span>chip0, HIGH<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
    _CHIP0 <span style="color: #000080;">=</span> chip0<span style="color: #008080;">;</span>
&nbsp;
    <span style="color: #0000ff;">if</span><span style="color: #008000;">&#40;</span>chip1<span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span>
        pinMode<span style="color: #008000;">&#40;</span>chip1, OUTPUT<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
        digitalWrite<span style="color: #008000;">&#40;</span>chip1, HIGH<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
        _CHIP1 <span style="color: #000080;">=</span> chip1<span style="color: #008080;">;</span>
    <span style="color: #008000;">&#125;</span>
&nbsp;
    <span style="color: #0000ff;">if</span><span style="color: #008000;">&#40;</span>chip2<span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span>
        pinMode<span style="color: #008000;">&#40;</span>chip2, OUTPUT<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
        digitalWrite<span style="color: #008000;">&#40;</span>chip2, HIGH<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
        _CHIP2 <span style="color: #000080;">=</span> chip2<span style="color: #008080;">;</span>
    <span style="color: #008000;">&#125;</span>
&nbsp;
    <span style="color: #0000ff;">if</span><span style="color: #008000;">&#40;</span>chip3<span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span>
        pinMode<span style="color: #008000;">&#40;</span>chip3, OUTPUT<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
        digitalWrite<span style="color: #008000;">&#40;</span>chip3, HIGH<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
        _CHIP2 <span style="color: #000080;">=</span> chip2<span style="color: #008080;">;</span>
    <span style="color: #008000;">&#125;</span>
&nbsp;
    _DATA <span style="color: #000080;">=</span> data<span style="color: #008080;">;</span>
    _WCLOCK <span style="color: #000080;">=</span> wclock<span style="color: #008080;">;</span>
<span style="color: #008000;">&#125;</span>
&nbsp;
<span style="color: #0000ff;">void</span> HT1632<span style="color: #008080;">::</span><span style="color: #007788;">ChipSelect</span><span style="color: #008000;">&#40;</span>byte chip<span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span>
    <span style="color: #0000ff;">switch</span><span style="color: #008000;">&#40;</span>chip<span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span>
        <span style="color: #0000ff;">case</span> <span style="color: #0000dd;">0</span><span style="color: #008080;">:</span>
            digitalWrite<span style="color: #008000;">&#40;</span>_CHIP0, LOW<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
            <span style="color: #0000ff;">break</span><span style="color: #008080;">;</span>
        <span style="color: #0000ff;">case</span> <span style="color: #0000dd;">1</span><span style="color: #008080;">:</span>
            digitalWrite<span style="color: #008000;">&#40;</span>_CHIP1, LOW<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
            <span style="color: #0000ff;">break</span><span style="color: #008080;">;</span>
        <span style="color: #0000ff;">case</span> <span style="color: #0000dd;">2</span><span style="color: #008080;">:</span>
            digitalWrite<span style="color: #008000;">&#40;</span>_CHIP2, LOW<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
            <span style="color: #0000ff;">break</span><span style="color: #008080;">;</span>
        <span style="color: #0000ff;">case</span> <span style="color: #0000dd;">3</span><span style="color: #008080;">:</span>
            digitalWrite<span style="color: #008000;">&#40;</span>_CHIP3, LOW<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
            <span style="color: #0000ff;">break</span><span style="color: #008080;">;</span>
        <span style="color: #008000;">&#125;</span>
<span style="color: #008000;">&#125;</span>
&nbsp;
<span style="color: #0000ff;">void</span> HT1632<span style="color: #008080;">::</span><span style="color: #007788;">ChipRelease</span><span style="color: #008000;">&#40;</span>byte chip<span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span>
    <span style="color: #0000ff;">switch</span><span style="color: #008000;">&#40;</span>chip<span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span>
        <span style="color: #0000ff;">case</span> <span style="color: #0000dd;">0</span><span style="color: #008080;">:</span>
            digitalWrite<span style="color: #008000;">&#40;</span>_CHIP0, HIGH<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
            <span style="color: #0000ff;">break</span><span style="color: #008080;">;</span>
        <span style="color: #0000ff;">case</span> <span style="color: #0000dd;">1</span><span style="color: #008080;">:</span>
            digitalWrite<span style="color: #008000;">&#40;</span>_CHIP1, HIGH<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
            <span style="color: #0000ff;">break</span><span style="color: #008080;">;</span>
        <span style="color: #0000ff;">case</span> <span style="color: #0000dd;">2</span><span style="color: #008080;">:</span>
            digitalWrite<span style="color: #008000;">&#40;</span>_CHIP2, HIGH<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
            <span style="color: #0000ff;">break</span><span style="color: #008080;">;</span>
        <span style="color: #0000ff;">case</span> <span style="color: #0000dd;">3</span><span style="color: #008080;">:</span>
            digitalWrite<span style="color: #008000;">&#40;</span>_CHIP3, HIGH<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
            <span style="color: #0000ff;">break</span><span style="color: #008080;">;</span>
    <span style="color: #008000;">&#125;</span>
<span style="color: #008000;">&#125;</span>
&nbsp;
<span style="color: #0000ff;">void</span> HT1632<span style="color: #008080;">::</span><span style="color: #007788;">WriteBits</span><span style="color: #008000;">&#40;</span>byte bits, byte mask<span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span>
    <span style="color: #0000ff;">while</span> <span style="color: #008000;">&#40;</span>mask<span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span>
        digitalWrite<span style="color: #008000;">&#40;</span>_WCLOCK, LOW<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
        <span style="color: #0000ff;">if</span> <span style="color: #008000;">&#40;</span>bits <span style="color: #000040;">&amp;</span>amp<span style="color: #008080;">;</span> mask<span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span>
            digitalWrite<span style="color: #008000;">&#40;</span>_DATA, HIGH<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
        <span style="color: #008000;">&#125;</span> <span style="color: #0000ff;">else</span> <span style="color: #008000;">&#123;</span>
            digitalWrite<span style="color: #008000;">&#40;</span>_DATA, LOW<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
        <span style="color: #008000;">&#125;</span>
        digitalWrite<span style="color: #008000;">&#40;</span>_WCLOCK, HIGH<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
        mask <span style="color: #000040;">&amp;</span>gt<span style="color: #008080;">;</span><span style="color: #000040;">&amp;</span>gt<span style="color: #008080;">;</span><span style="color: #000080;">=</span> <span style="color: #0000dd;">1</span><span style="color: #008080;">;</span>
    <span style="color: #008000;">&#125;</span>
<span style="color: #008000;">&#125;</span>
&nbsp;
<span style="color: #0000ff;">void</span> HT1632<span style="color: #008080;">::</span><span style="color: #007788;">SendCommand</span><span style="color: #008000;">&#40;</span>byte command, byte chip<span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span>
    ChipSelect<span style="color: #008000;">&#40;</span>chip<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
    WriteBits<span style="color: #008000;">&#40;</span>HT1632_CTL_COMMAND, <span style="color: #0000dd;">1</span><span style="color: #000040;">&amp;</span>lt<span style="color: #008080;">;</span><span style="color: #000040;">&amp;</span>lt<span style="color: #008080;">;</span><span style="color: #0000dd;">2</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span><span style="color: #666666;">//3 bit command id</span>
    WriteBits<span style="color: #008000;">&#40;</span>command, <span style="color: #0000dd;">1</span><span style="color: #000040;">&amp;</span>lt<span style="color: #008080;">;</span><span style="color: #000040;">&amp;</span>lt<span style="color: #008080;">;</span><span style="color: #0000dd;">7</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span><span style="color: #666666;">//8 bit command</span>
    WriteBits<span style="color: #008000;">&#40;</span><span style="color: #0000dd;">0</span>,<span style="color: #0000dd;">1</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span><span style="color: #666666;">//There's one extra bit in commands that dont matter...</span>
    ChipRelease<span style="color: #008000;">&#40;</span>chip<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
<span style="color: #008000;">&#125;</span>
&nbsp;
byte HT1632<span style="color: #008080;">::</span><span style="color: #007788;">ReadData</span><span style="color: #008000;">&#40;</span>byte address, byte chip<span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span>
    <span style="color: #666666;">//Do stuff here to read the data from the chip...</span>
<span style="color: #008000;">&#125;</span>
&nbsp;
<span style="color: #0000ff;">void</span> HT1632<span style="color: #008080;">::</span><span style="color: #007788;">Clear</span><span style="color: #008000;">&#40;</span>byte chip<span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span>
    ChipSelect<span style="color: #008000;">&#40;</span>chip<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
    <span style="color: #0000ff;">for</span><span style="color: #008000;">&#40;</span><span style="color: #0000ff;">int</span> i<span style="color: #000080;">=</span><span style="color: #0000dd;">0</span><span style="color: #008080;">;</span> i<span style="color: #000040;">&amp;</span>lt<span style="color: #008080;">;</span><span style="color: #0000dd;">256</span><span style="color: #008080;">;</span> i<span style="color: #000040;">++</span><span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span>
        WriteData<span style="color: #008000;">&#40;</span>i, <span style="color: #0000dd;">0</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
    <span style="color: #008000;">&#125;</span>
    ChipRelease<span style="color: #008000;">&#40;</span>chip<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
<span style="color: #008000;">&#125;</span>
&nbsp;
<span style="color: #0000ff;">void</span> HT1632<span style="color: #008080;">::</span><span style="color: #007788;">WriteData</span><span style="color: #008000;">&#40;</span>byte address, byte data, byte chip<span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span>
    ChipSelect<span style="color: #008000;">&#40;</span>chip<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span><span style="color: #666666;">//Select the chip...</span>
    <span style="color: #666666;">//Send the WRITE command...</span>
    WriteBits<span style="color: #008000;">&#40;</span>HT1632_CTL_WRITE, <span style="color: #0000dd;">1</span><span style="color: #000040;">&amp;</span>lt<span style="color: #008080;">;</span><span style="color: #000040;">&amp;</span>lt<span style="color: #008080;">;</span><span style="color: #0000dd;">2</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>  <span style="color: #666666;">//3 bit command</span>
    <span style="color: #666666;">//Send the Address...</span>
    WriteBits<span style="color: #008000;">&#40;</span>address, <span style="color: #0000dd;">1</span><span style="color: #000040;">&amp;</span>lt<span style="color: #008080;">;</span><span style="color: #000040;">&amp;</span>lt<span style="color: #008080;">;</span><span style="color: #0000dd;">6</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>   <span style="color: #666666;">//7 bit address</span>
    <span style="color: #666666;">//Send the data...</span>
    WriteBits<span style="color: #008000;">&#40;</span>data, <span style="color: #0000dd;">1</span><span style="color: #000040;">&amp;</span>lt<span style="color: #008080;">;</span><span style="color: #000040;">&amp;</span>lt<span style="color: #008080;">;</span><span style="color: #0000dd;">3</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span> <span style="color: #666666;">//4 bit data</span>
    ChipRelease<span style="color: #008000;">&#40;</span>chip<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span><span style="color: #666666;">//Release the chip...</span>
<span style="color: #008000;">&#125;</span>
&nbsp;
<span style="color: #0000ff;">void</span> HT1632<span style="color: #008080;">::</span><span style="color: #007788;">Init</span><span style="color: #008000;">&#40;</span>byte chip<span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span>
    SendCommand<span style="color: #008000;">&#40;</span>HT1632_CMD_SYSDIS<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span> <span style="color: #666666;">//Disable system</span>
    SendCommand<span style="color: #008000;">&#40;</span>HT1632_CMD_COM11<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span> <span style="color: #666666;">//PMOS drivers</span>
    SendCommand<span style="color: #008000;">&#40;</span>HT1632_CMD_RCMASTER<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span> <span style="color: #666666;">//Master mode</span>
    SendCommand<span style="color: #008000;">&#40;</span>HT1632_CMD_SYSEN<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span> <span style="color: #666666;">//System Enable</span>
    SendCommand<span style="color: #008000;">&#40;</span>HT1632_CMD_LEDON<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span> <span style="color: #666666;">//Enable the display</span>
    Clear<span style="color: #008000;">&#40;</span>chip<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
<span style="color: #008000;">&#125;</span>
&nbsp;
<span style="color: #0000ff;">void</span> HT1632<span style="color: #008080;">::</span><span style="color: #007788;">BlinkMode</span><span style="color: #008000;">&#40;</span><span style="color: #0000ff;">bool</span> blink, byte chip<span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span>
    <span style="color: #0000ff;">if</span><span style="color: #008000;">&#40;</span>blink<span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span>
        SendCommand<span style="color: #008000;">&#40;</span>HT1632_CMD_BLINKON, chip<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
    <span style="color: #008000;">&#125;</span> <span style="color: #0000ff;">else</span> <span style="color: #008000;">&#123;</span>
        SendCommand<span style="color: #008000;">&#40;</span>HT1632_CMD_BLINKOFF, chip<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
    <span style="color: #008000;">&#125;</span>
<span style="color: #008000;">&#125;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://hackdev.com/2010/05/led-matrix-displays/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Just a general update&#8230;</title>
		<link>http://hackdev.com/2010/04/just-a-general-update/</link>
		<comments>http://hackdev.com/2010/04/just-a-general-update/#comments</comments>
		<pubDate>Fri, 23 Apr 2010 20:48:55 +0000</pubDate>
		<dc:creator>Gues7</dc:creator>
				<category><![CDATA[Fixes / Patches]]></category>
		<category><![CDATA[Gaming]]></category>
		<category><![CDATA[General]]></category>
		<category><![CDATA[Mancave]]></category>
		<category><![CDATA[Projects]]></category>

		<guid isPermaLink="false">http://hackdev.com/?p=144</guid>
		<description><![CDATA[It&#8217;s been quite a while since I&#8217;ve posted  anything, I&#8217;ve been very busy lately but since I&#8217;m out sick now for a few days, I have a bit of time to update&#8230; If you have tried to play Fallout 3 &#8230; <a href="http://hackdev.com/2010/04/just-a-general-update/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>It&#8217;s been quite a while since I&#8217;ve posted  anything, I&#8217;ve been very busy lately but since I&#8217;m out sick now for a few days, I have a bit of time to update&#8230;</p>
<p>If you have tried to play Fallout 3 using an Asus branded NVidia card, and it crashes stating &#8220;Fallout 3 has stopped working&#8221; every time you try to load a new game, check and see if you have Asus Gamer OSD installed, if you do, get rid of it. Something the overlay does interferes with the game  and causes this to happen&#8230;</p>
<p>I have been doing some more work on the lighting for the man cave so I have some Python code that will pull the Average color (not the most predominant, yet, wont be hard, but I am lazy) so here it is, please keep in mind its not nice, fast or clean&#8230; for high res images it takes a few seconds to do its thing&#8230;</p>
<p style="padding-left: 30px;">

<div class="wp_syntax"><div class="code"><pre class="python" style="font-family:monospace;"><span style="color: #808080; font-style: italic;">#!/usr/bin/env python</span>
&nbsp;
<span style="color: #808080; font-style: italic;">#</span>
<span style="color: #808080; font-style: italic;"># PIL Image Module Handbook - http://www.pythonware.com/library/pil/handbook/image.htm</span>
<span style="color: #808080; font-style: italic;">#</span>
&nbsp;
<span style="color: #ff7700;font-weight:bold;">from</span> PIL <span style="color: #ff7700;font-weight:bold;">import</span> Image
<span style="color: #ff7700;font-weight:bold;">from</span> <span style="color: #dc143c;">optparse</span> <span style="color: #ff7700;font-weight:bold;">import</span> OptionParser
&nbsp;
<span style="color: #ff7700;font-weight:bold;">def</span> processImageAverage<span style="color: black;">&#40;</span>imageFile<span style="color: black;">&#41;</span>:
    image = Image.<span style="color: #008000;">open</span><span style="color: black;">&#40;</span>imageFile<span style="color: black;">&#41;</span>     <span style="color: #808080; font-style: italic;">#open the image for processing</span>
    pixels = <span style="color: #008000;">list</span><span style="color: black;">&#40;</span>image.<span style="color: black;">getdata</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span>    <span style="color: #808080; font-style: italic;">#break the image down into a list of pixels, each pixel contains a list of red,green,blue</span>
&nbsp;
    totalpx = <span style="color: #ff4500;">0</span> <span style="color: #808080; font-style: italic;">#set some default values to start counting...</span>
    redpx = <span style="color: #ff4500;">0</span>
    greenpx = <span style="color: #ff4500;">0</span>
    bluepx = <span style="color: #ff4500;">0</span>
&nbsp;
    <span style="color: #ff7700;font-weight:bold;">for</span> pixel <span style="color: #ff7700;font-weight:bold;">in</span> pixels:    <span style="color: #808080; font-style: italic;">#loop through the lists and build the values.</span>
        totalpx += <span style="color: #ff4500;">1</span>
        redpx += pixel<span style="color: black;">&#91;</span><span style="color: #ff4500;">0</span><span style="color: black;">&#93;</span>
        greenpx += pixel<span style="color: black;">&#91;</span><span style="color: #ff4500;">1</span><span style="color: black;">&#93;</span>
        bluepx += pixel<span style="color: black;">&#91;</span><span style="color: #ff4500;">2</span><span style="color: black;">&#93;</span>
&nbsp;
    redavg = redpx / totalpx   <span style="color: #808080; font-style: italic;">#generate the averages</span>
    greenavg = greenpx / totalpx
    blueavg = bluepx / totalpx
&nbsp;
    <span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #483d8b;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>Total Pixels:<span style="color: #000099; font-weight: bold;">\t</span>&quot;</span>, totalpx     <span style="color: #808080; font-style: italic;">#and write them out.</span>
    <span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #483d8b;">&quot;Red Average:<span style="color: #000099; font-weight: bold;">\t</span>&quot;</span>, redavg
    <span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #483d8b;">&quot;Green Average:<span style="color: #000099; font-weight: bold;">\t</span>&quot;</span>, greenavg
    <span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #483d8b;">&quot;Blue Average:<span style="color: #000099; font-weight: bold;">\t</span>&quot;</span>, blueavg
    <span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #483d8b;">&quot;HEX Color:<span style="color: #000099; font-weight: bold;">\t</span>#%x%x%x&quot;</span> <span style="color: #66cc66;">%</span> <span style="color: black;">&#40;</span>redavg, greenavg, blueavg<span style="color: black;">&#41;</span>
&nbsp;
<span style="color: #ff7700;font-weight:bold;">def</span> main<span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>:
    <span style="color: #dc143c;">parser</span> = OptionParser<span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;Usage: %prog source&quot;</span><span style="color: black;">&#41;</span>
&nbsp;
    <span style="color: black;">&#40;</span>options, arguments<span style="color: black;">&#41;</span> = <span style="color: #dc143c;">parser</span>.<span style="color: black;">parse_args</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
    <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: #008000;">len</span><span style="color: black;">&#40;</span>arguments<span style="color: black;">&#41;</span> <span style="color: #66cc66;">!</span>= <span style="color: #ff4500;">1</span>:
        <span style="color: #dc143c;">parser</span>.<span style="color: black;">error</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;Please specify a single input file.&quot;</span><span style="color: black;">&#41;</span>
&nbsp;
    processImageAverage<span style="color: black;">&#40;</span>arguments<span style="color: black;">&#91;</span><span style="color: #ff4500;">0</span><span style="color: black;">&#93;</span><span style="color: black;">&#41;</span>
&nbsp;
<span style="color: #ff7700;font-weight:bold;">if</span> __name__ == <span style="color: #483d8b;">&quot;__main__&quot;</span>:
    main<span style="color: black;">&#40;</span><span style="color: black;">&#41;</span></pre></div></div>

</p>
<p>I have a new job now, I&#8217;m no longer a software validation engineer (tester), I&#8217;m now an IT Support Engineer (IT Techie&#8230;) which is kinda nice&#8230;.</p>
<p>Well&#8230; that is for now&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://hackdev.com/2010/04/just-a-general-update/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>New addition to the ManCave for the bar&#8230;</title>
		<link>http://hackdev.com/2010/02/new-addition-to-the-mancave-for-the-bar/</link>
		<comments>http://hackdev.com/2010/02/new-addition-to-the-mancave-for-the-bar/#comments</comments>
		<pubDate>Sun, 14 Feb 2010 17:09:50 +0000</pubDate>
		<dc:creator>Gues7</dc:creator>
				<category><![CDATA[Mancave]]></category>

		<guid isPermaLink="false">http://hackdev.com/?p=137</guid>
		<description><![CDATA[]]></description>
			<content:encoded><![CDATA[<p><img src="http://img519.imageshack.us/img519/8719/p140210164301.jpg" alt="http://img519.imageshack.us/img519/8719/p140210164301.jpg" width="512" height="384" /></p>
]]></content:encoded>
			<wfw:commentRss>http://hackdev.com/2010/02/new-addition-to-the-mancave-for-the-bar/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>€1366.07 down&#8230;</title>
		<link>http://hackdev.com/2010/02/e1366-07-down/</link>
		<comments>http://hackdev.com/2010/02/e1366-07-down/#comments</comments>
		<pubDate>Sun, 14 Feb 2010 14:34:31 +0000</pubDate>
		<dc:creator>Gues7</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[Mancave]]></category>

		<guid isPermaLink="false">http://hackdev.com/?p=135</guid>
		<description><![CDATA[So I have been doing some serious work on my mancave during my two weeks off, so far I have all of the walls battened, the new door fitted, and two of the walls wired for mains sockets. I have &#8230; <a href="http://hackdev.com/2010/02/e1366-07-down/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>So I have been doing some serious work on my mancave during my two weeks off, so far I have all of the walls battened, the new door fitted, and two of the walls wired for mains sockets. I have even been picking up some additional parts that we are not quite ready yet, such as a roll of CAT6 cable, CAT6 wall outlets with faceplate&#8217;s, 17 double gang switched sockets and much much more&#8230; all in all its coming along nicely. No photo&#8217;s taken as of yet though, I really should have taken some at the start and all the way through as it would have been quite a good evolution slide show, but alas its too late now&#8230; we did run into a few issues though, the garage is still crammed full of stuff and there is not much room to move around in it so that has been slowing us down a lot, however there is nowhere else to put it so it has to be this way for now I&#8217;m afraid <img src='http://hackdev.com/wp-includes/images/smilies/icon_sad.gif' alt=':(' class='wp-smiley' /> </p>
<p>Another issue we&#8217;ve encountered was that the cavity blocks haven&#8217;t aged all that well and are quite hard, like flint even, so masonry nails havent been working out too well on that, so as a more expensive, and time consuming work-around, we have been using nail-anchors and manually drilling for each baton&#8230; not the most fun thing in the world, but at least its progress&#8230;</p>
<p>As a side note, from working out in the cold weather all week I seem to have gotten another cold <img src='http://hackdev.com/wp-includes/images/smilies/icon_sad.gif' alt=':(' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://hackdev.com/2010/02/e1366-07-down/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Embedded Linux Development</title>
		<link>http://hackdev.com/2009/11/embedded-linux-development/</link>
		<comments>http://hackdev.com/2009/11/embedded-linux-development/#comments</comments>
		<pubDate>Wed, 18 Nov 2009 22:07:33 +0000</pubDate>
		<dc:creator>Gues7</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Projects]]></category>

		<guid isPermaLink="false">http://hackdev.com/?p=74</guid>
		<description><![CDATA[I work for a company that is currently utilising Linux on an embedded platform, now I am a big fan of Linux, and I do really like embedded systems&#8230; so the natural progression was to go and learn about embedded &#8230; <a href="http://hackdev.com/2009/11/embedded-linux-development/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I work for a company that is currently utilising Linux on an embedded platform, now I am a big fan of Linux, and I do really like embedded systems&#8230; so the natural progression was to go and learn about embedded Linux development. I managed to find a really good book called the <a href="http://www.amazon.com/gp/product/0131679848?ie=UTF8&amp;tag=hackdcom-20&amp;linkCode=as2&amp;camp=1789&amp;creative=9325&amp;creativeASIN=0131679848">Embedded Linux Primer: A Practical Real-World Approach</a> which really is very good. So, as a kind of training exercise, I will be attempting to build my own customer miniture linux distribution (borrowing some things from other projects) for an embedded system. The board I have chosen is the BifferBoard which is available from http://www.bifferboard.com and is a very cheap x86 based system with a lot of handy features such as UART, JTAG, GPIO, Ethernet, really good board and again, really cheap, I paid around €30 for mine&#8230;</p>
<p>I do have a few goals that I intend to accheive in the proccess of doing this project and a few additional tools will be imported from other projects&#8230; the main requirements that I have are&#8230;</p>
<ul>
<li>Very small footprint.</li>
<li>Custom compiled kernel that has the bare essentials to support <strong>all</strong> of the hardware on the board natively, no KLM&#8217;s allowed.</li>
<li>A working shell environment, Busybox is my target at present.</li>
<li>A port of UCI which is extensively used throughout OpenWRT, that really is an awesome configuration utility.</li>
<li>A port of the LUCI framwork, again, used extensively throughout OpenWRT.
<ul>
<li>LUCI is a MVC based framework written in LUA that provides superb interaction with the UCI configuration tool.</li>
</ul>
</li>
<li>A method of automatically &#8216;provisioning&#8217; a unit with a set of configuration files
<ul>
<li>Most likely the provisioning will be handled on a back end server somewhere (read: webserver) where the unit it&#8217;s self simply checks the server on first boot and will grab the config files if they exist.</li>
</ul>
</li>
<li>Support for V4L and webcams. This provides the potential to take a cheap webcam, and a cheap board, and have a cheap IP camera.</li>
</ul>
<p>More will be added to this list as some of the items are checked off or as a need arises for them. One thing that I cant think of, and I have never been very good at it, is a <strong>name</strong> for the project. Any ideas? Please do let me know in the comments, one idea I heard was ic-linux&#8230;</p>
<p>Since committing to doing this I have built a small development area for myself using my Laptop and some other equipment I had that would be useful, USB hub, old router with DHCP disabled as I dont have a small switch, various tools, memory sticks etc&#8230; unfortunately I was doing some work on my room and ended up making a mess of it all so its not exactly picture worthy at the minute, but I will get some put up soon.</p>
<p>Anyway, thats enough rambling on for now&#8230;<img style="border:none !important; margin:0px !important;" src="http://www.assoc-amazon.com/e/ir?t=hackdcom-20&amp;l=as2&amp;o=1&amp;a=0131679848" border="0" alt="" width="1" height="1" /></p>
]]></content:encoded>
			<wfw:commentRss>http://hackdev.com/2009/11/embedded-linux-development/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

