<?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>C i b o M a h t o . c o m &#187; Uncategorized</title>
	<atom:link href="http://www.cibomahto.com/category/uncategorized/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.cibomahto.com</link>
	<description>building making designing dreaming</description>
	<lastBuildDate>Fri, 27 Aug 2010 16:38:37 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Idea: Ceiling cat smoke detector</title>
		<link>http://www.cibomahto.com/2010/08/idea-ceiling-cat-smoke-detector/</link>
		<comments>http://www.cibomahto.com/2010/08/idea-ceiling-cat-smoke-detector/#comments</comments>
		<pubDate>Thu, 12 Aug 2010 00:41:59 +0000</pubDate>
		<dc:creator>mahto</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.cibomahto.com/2010/08/idea-ceiling-cat-smoke-detector/</guid>
		<description><![CDATA[Like any ceiling cat, the ceiling cat smoke detector watches you doing private things. This cat has another function, however- it also detects fire in your abode, and warmly alerts you to them with the moaning wail of an excited &#8230; <a href="http://www.cibomahto.com/2010/08/idea-ceiling-cat-smoke-detector/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p><a alt="image" href="http://www.cibomahto.com/wp-content/uploads/2010/08/wpid-2010-08-11-19.45.331.jpg"><img  alt="image" src="http://www.cibomahto.com/wp-content/uploads/2010/08/wpid-2010-08-11-19.45.33.jpg" /></a></p>
<p>Like any ceiling cat, the ceiling cat smoke detector watches you doing private things. This cat has another function, however- it also detects fire in your abode, and warmly alerts you to them with the moaning wail of an excited feline who seeks affirmation of their existence through copulation. Bonus features include a rotating head, flashing eyes, and articulated mouth.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.cibomahto.com/2010/08/idea-ceiling-cat-smoke-detector/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Michigan friends: Come to Maker Faire Detroit!</title>
		<link>http://www.cibomahto.com/2010/07/michigan-friends-come-to-maker-faire-detroit/</link>
		<comments>http://www.cibomahto.com/2010/07/michigan-friends-come-to-maker-faire-detroit/#comments</comments>
		<pubDate>Wed, 21 Jul 2010 16:50:51 +0000</pubDate>
		<dc:creator>mahto</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.cibomahto.com/?p=1314</guid>
		<description><![CDATA[To everyone I know who lives in or near Detroit: MAKE, the company that I&#8217;ve been writing for over the past year, is putting on a giant art/tech/craft event called Maker Faire at the Henry Ford at the end of &#8230; <a href="http://www.cibomahto.com/2010/07/michigan-friends-come-to-maker-faire-detroit/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p><object width="600" height="361"><param name="movie" value="http://www.youtube.com/v/8ToZnEu4940&#038;hl=en&#038;start=0&#038;fs=1&#038;rel=0&#038;showinfo=0&#038;ap=%2526fmt%3D18"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/8ToZnEu4940&#038;hl=en&#038;start=0&#038;fs=1&#038;rel=0&#038;showinfo=0&#038;ap=%2526fmt%3D18" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="600" height="361"></embed></object></p>
<p><a href="http://makerfaire.com/detroit/2010/"><img src="http://www.cibomahto.com/wp-content/uploads/2010/07/maker-faire-detroit.jpg" alt="" title="maker-faire-detroit" width="464" height="120" class="alignnone size-full wp-image-1315" /></a></p>
<p><em>To everyone I know who lives in or near Detroit:</em><br />
MAKE, the company that I&#8217;ve been <a href="http://blog.makezine.com/archive/author/matt_mets/">writing for</a> over the past year, is putting on a <a href="http://makerfaire.com/detroit/2010/">giant art/tech/craft event called Maker Faire</a> at the Henry Ford at the end of July. Over 200 awesome groups from around the area will be there to showcase their hobby projects, inventions, business ideas, and dreams, so if you&#8217;re curious what else is going on in the city, I strongly suggest you come out to see whats up. It&#8217;s a family friendly event, so bring the kids and get ready for a great time!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.cibomahto.com/2010/07/michigan-friends-come-to-maker-faire-detroit/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Mendel Parts!</title>
		<link>http://www.cibomahto.com/2010/05/mendel-parts/</link>
		<comments>http://www.cibomahto.com/2010/05/mendel-parts/#comments</comments>
		<pubDate>Sat, 29 May 2010 08:27:15 +0000</pubDate>
		<dc:creator>mahto</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.cibomahto.com/?p=988</guid>
		<description><![CDATA[My friend Marty used Makerbot 131 to print me a set of parts for a RepRap Mendel, so it looks like I have no choce but to build it . Here is a catalog of all the parts, in a &#8230; <a href="http://www.cibomahto.com/2010/05/mendel-parts/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.flickr.com/photos/cibomahto/4649260050/" title="Mendel Parts by cibomahto, on Flickr"><img src="http://farm5.static.flickr.com/4019/4649260050_8514243bf4.jpg" width="414" height="500" alt="Mendel Parts" /></a><br />
My friend <a href="http://creatingwithcode.com/">Marty</a> used <a href="http://creatingwithcode.com/makerbot_131/">Makerbot 131</a> to print me a set of parts for a <a href="http://reprap.org/wiki/Mendel">RepRap Mendel</a>, so it looks like I have no choce but to build it <img src='http://www.cibomahto.com/wp-includes/images/smilies/icon_biggrin.gif' alt=':-D' class='wp-smiley' /> . Here is a catalog of all the parts, in a similar style to the <a href="http://objects.reprap.org/mediawiki/images/d/dd/Printed-parts-glossary.PNG">printed parts glossary</a>. So far, I have ordered a <a href="http://ultimachine.com/content/mendel-hardware-kit">hardware kit</a>, <a href="http://ultimachine.com/content/mendel-x-timing-belt-5t51380">x timing belt</a>, and <a href="http://ultimachine.com/content/mendel-y-z-timing-belt-5t5990">y/z timing belts</a> from UltiMachine, which by my calculations was way easier than sourcing all the parts myself. I still need to decide what to use for the electronics, and pick an extruder design to start with.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.cibomahto.com/2010/05/mendel-parts/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>A short link to nearly nowhere</title>
		<link>http://www.cibomahto.com/2010/04/a-short-link-to-nearly-nowhere/</link>
		<comments>http://www.cibomahto.com/2010/04/a-short-link-to-nearly-nowhere/#comments</comments>
		<pubDate>Thu, 15 Apr 2010 17:09:33 +0000</pubDate>
		<dc:creator>mahto</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[recursion]]></category>
		<category><![CDATA[redirection]]></category>
		<category><![CDATA[short link]]></category>
		<category><![CDATA[shortlink]]></category>
		<category><![CDATA[url redirector]]></category>

		<guid isPermaLink="false">http://www.cibomahto.com/?p=924</guid>
		<description><![CDATA[It occurred to me today that sic&#8217;ing url shortener services on each other to create an infinite loop would be funny. If you aren&#8217;t familiar, these are sites that can take a long url (such as http://www.cibomahto.com/2010/04/homebrew-flash-triggers-using-xbee-radios/) and convert it &#8230; <a href="http://www.cibomahto.com/2010/04/a-short-link-to-nearly-nowhere/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.cibomahto.com/wp-content/uploads/2010/04/recursive_url.jpg"><img src="http://www.cibomahto.com/wp-content/uploads/2010/04/recursive_url.jpg" alt="" title="recursive_url" width="500" height="296" class="alignnone size-full wp-image-927" /></a></p>
<p>It occurred to me today that sic&#8217;ing <a href="http://en.wikipedia.org/wiki/URL_shortening">url shortener</a> services on each other to create an infinite loop would be funny.  If you aren&#8217;t familiar, these are sites that can take a long url (such as http://www.cibomahto.com/2010/04/homebrew-flash-triggers-using-xbee-radios/) and convert it to something shorter (http://bit.ly/bveef4).  They have been around for a while, but became really popular for use on Twitter, because the short URLs take up fewer of your precious characters.</p>
<p>At first blush, it seems impossible to do this, since they work by generating a random short URL, however a couple (foolish) services allow you to specify a custom shortlink. So, you can start by using a different service to create a shortlink to a (nonexistent) custom URL on one of those sites, then build a chain by adding new shortlinks that point to the previous link, then seal up the chain by going back and creating the custom URL, pointing it at the last shortlink you created.</p>
<p>The first time I tried this, I only used two links, and Firefox got mad and refused to load the page (smart Fox!).  The second time, though, I went for six redirects, and that appears to work.  I created this chain:</p>
<p><a href="http://bit.ly/bq66ZB">http://bit.ly/bq66ZB</a> -><br />
<a href="http://w3t.org/GE4">http://w3t.org/GE4</a> -><br />
<a href="http://urlcut.com/1veuz">http://urlcut.com/1veuz</a> -><br />
<a href="http://snipurl.com/vi927">http://snipurl.com/vi927</a> -><br />
<a href="http://simurl.com/welkif">http://simurl.com/welkif</a> -><br />
<a href="doiop.com/recurser2">doiop.com/recurser2</a> -></p>
<p>Visiting any of these URLs caused an infinite loop of redirects (until it breaks, because someone fixed their site).  A couple things i noticed were:</p>
<ul>
<li>The better redirectors blacklist other known redirectors</li>
<li>Some redirectors actually make you look at an ad before redirecting you (!)</li>
<li>Some redirectors warn you if they think they are redirecting you to a suspicious url.</li>
</ul>
<p>My suggestion is to avoid sites sites with such restrictions if you want to do stupid things, or if you run a redirection service, implement all of the above.  List of redirectors grabbed from <a href="http://lists.econsultant.com/top-10-url-redirection-services.html">this classy site</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.cibomahto.com/2010/04/a-short-link-to-nearly-nowhere/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Berlin, Dezember 2002</title>
		<link>http://www.cibomahto.com/2010/03/berlin-dezember-2002/</link>
		<comments>http://www.cibomahto.com/2010/03/berlin-dezember-2002/#comments</comments>
		<pubDate>Mon, 29 Mar 2010 18:38:56 +0000</pubDate>
		<dc:creator>mahto</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.cibomahto.com/?p=827</guid>
		<description><![CDATA[From left to right, it&#8217;s me, Thommy, Alex, Kristijan. (thanks Thommy!).]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.cibomahto.com/wp-content/uploads/2010/03/berlin_december_2002.jpg"><img src="http://www.cibomahto.com/wp-content/uploads/2010/03/berlin_december_2002.jpg" alt="" title="berlin_december_2002" width="500" height="344" class="alignnone size-full wp-image-828" /></a></p>
<p>From left to right, it&#8217;s me, Thommy, Alex, Kristijan.  (thanks <a href="http://twitter.com/JulienTee">Thommy</a>!).</p>
]]></content:encoded>
			<wfw:commentRss>http://www.cibomahto.com/2010/03/berlin-dezember-2002/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Marty Unboxes the Make: Electronics Components Pack 1</title>
		<link>http://www.cibomahto.com/2010/03/marty-unboxes-the-make-electronics-components-pack-1/</link>
		<comments>http://www.cibomahto.com/2010/03/marty-unboxes-the-make-electronics-components-pack-1/#comments</comments>
		<pubDate>Tue, 23 Mar 2010 03:11:58 +0000</pubDate>
		<dc:creator>mahto</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.cibomahto.com/?p=813</guid>
		<description><![CDATA[Marty unboxes the Make: Electronics Components Pack 1: Like many enthusiastic makers, I recently got my hands on a copy of the excellent Make: Electronics book from O’Reilly. It’s an excellent bottom-up, experiment-based introduction to electronics, but sourcing all of &#8230; <a href="http://www.cibomahto.com/2010/03/marty-unboxes-the-make-electronics-components-pack-1/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p><object width="600" height="364"><param name="movie" value="http://www.youtube.com/v/TGOL8WerVQw&#038;hl=en&#038;start=0&#038;fs=1&#038;rel=0&#038;showinfo=0&#038;ap=%2526fmt%3D18"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/TGOL8WerVQw&#038;hl=en&#038;start=0&#038;fs=1&#038;rel=0&#038;showinfo=0&#038;ap=%2526fmt%3D18" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="600" height="364"></embed></object></p>
<p>Marty unboxes the Make: Electronics Components Pack 1:</p>
<blockquote><p>Like many enthusiastic makers, I recently got my hands on a copy of the excellent <a href="http://www.makershed.com/ProductDetails.asp?ProductCode=9780596153748">Make: Electronics</a> book from O’Reilly.  It’s an excellent bottom-up, experiment-based introduction to electronics, but sourcing all of the parts required to complete each experiment can be an adventure.</p>
<p>Thankfully, the Maker Shed is now offering two <a href="http://www.makershed.com/ProductDetails.asp?ProductCode=MECP1">components</a> <a href="http://www.makershed.com/ProductDetails.asp?ProductCode=MECP2">packs</a> to help you work through the book without having to order from a half-dozen parts vendors!</p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://www.cibomahto.com/2010/03/marty-unboxes-the-make-electronics-components-pack-1/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Stepping quickly</title>
		<link>http://www.cibomahto.com/2010/02/stepping-quickly/</link>
		<comments>http://www.cibomahto.com/2010/02/stepping-quickly/#comments</comments>
		<pubDate>Thu, 18 Feb 2010 08:18:44 +0000</pubDate>
		<dc:creator>mahto</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.cibomahto.com/?p=780</guid>
		<description><![CDATA[Finally getting around to designing up a stepper motor controller for this chemical mixing robot that I picked up this summer. So, here is a super simple controller to drive one axis! Right now it&#8217;s using Arduino on an Atmega168, &#8230; <a href="http://www.cibomahto.com/2010/02/stepping-quickly/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p><object width="600" height="364"><param name="movie" value="http://www.youtube.com/v/8BXipVLuNCs&#038;hl=en&#038;start=0&#038;fs=1&#038;rel=0&#038;showinfo=0&#038;ap=%2526fmt%3D18"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/8BXipVLuNCs&#038;hl=en&#038;start=0&#038;fs=1&#038;rel=0&#038;showinfo=0&#038;ap=%2526fmt%3D18" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="600" height="364"></embed></object></p>
<p><a href="http://www.flickr.com/photos/cibomahto/4366746765/" title="Stepper controller prototype by cibomahto, on Flickr"><img src="http://farm5.static.flickr.com/4004/4366746765_6849401fb3.jpg" width="500" height="374" alt="Stepper controller prototype" /></a></p>
<p>Finally getting around to designing up a stepper motor controller for this chemical mixing robot that I picked up this summer.  So, here is a super simple controller to drive one axis!  Right now it&#8217;s using Arduino on an Atmega168, but I think i&#8217;ll switch to something lighter, give each module it&#8217;s own micro (with limit switch and encoder support), and talk to them from a master controller using some serial bus.  Or just talk to them all using a parallel port on a PC <img src='http://www.cibomahto.com/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> .  Sample code for this guy after the break.<br />
<span id="more-780"></span></p>

<div class="wp_syntax"><div class="code"><pre class="c" style="font-family:monospace;">&nbsp;
<span style="color: #666666; font-style: italic;">// _Simple_ half-stepping driver for a unipolar stepper motor</span>
<span style="color: #666666; font-style: italic;">// </span>
<span style="color: #666666; font-style: italic;">// Written by Matt Mets in 2010</span>
<span style="color: #666666; font-style: italic;">//</span>
<span style="color: #666666; font-style: italic;">// Generates a waveform that looks like this:</span>
<span style="color: #666666; font-style: italic;">//</span>
<span style="color: #666666; font-style: italic;">//    ______</span>
<span style="color: #666666; font-style: italic;">// A |      |_____________</span>
<span style="color: #666666; font-style: italic;">//   </span>
<span style="color: #666666; font-style: italic;">//         ______</span>
<span style="color: #666666; font-style: italic;">// B _____|      |________</span>
<span style="color: #666666; font-style: italic;">//   </span>
<span style="color: #666666; font-style: italic;">//              ______  </span>
<span style="color: #666666; font-style: italic;">// C __________|      |___</span>
<span style="color: #666666; font-style: italic;">//   </span>
<span style="color: #666666; font-style: italic;">//   _               _____  </span>
<span style="color: #666666; font-style: italic;">// D  |_____________|     </span>
&nbsp;
&nbsp;
<span style="color: #666666; font-style: italic;">// Digital I/O pins to which the n-channel FET drivers are connected</span>
<span style="color: #993333;">unsigned</span> <span style="color: #993333;">char</span> motorPins<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;">2</span><span style="color: #339933;">,</span> <span style="color: #0000dd;">4</span><span style="color: #339933;">,</span> <span style="color: #0000dd;">5</span><span style="color: #339933;">,</span> <span style="color: #0000dd;">3</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
&nbsp;
&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>
  <span style="color: #666666; font-style: italic;">// Set all the pins to outputs, and turn them off.  </span>
  <span style="color: #b1b100;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #993333;">unsigned</span> <span style="color: #993333;">char</span> i <span style="color: #339933;">=</span> <span style="color: #0000dd;">0</span><span style="color: #339933;">;</span> i <span style="color: #339933;">&lt;</span> <span style="color: #0000dd;">4</span><span style="color: #339933;">;</span> i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    pinMode<span style="color: #009900;">&#40;</span>motorPins<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> OUTPUT<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    digitalWrite<span style="color: #009900;">&#40;</span>motorPins<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> LOW<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: #666666; font-style: italic;">// number of times the complete cycle is repeated</span>
<span style="color: #339933;">#define rotations 50</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// microsecond delay between half-steps</span>
<span style="color: #339933;">#define delayLength 2000</span>
&nbsp;
<span style="color: #993333;">void</span> loop<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  <span style="color: #666666; font-style: italic;">// walk forward in half-steps</span>
  <span style="color: #b1b100;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #993333;">unsigned</span> <span style="color: #993333;">char</span> j <span style="color: #339933;">=</span> <span style="color: #0000dd;">0</span><span style="color: #339933;">;</span> j <span style="color: #339933;">&lt;</span> rotations<span style="color: #339933;">;</span> j<span style="color: #339933;">++</span><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;">unsigned</span> <span style="color: #993333;">char</span> i <span style="color: #339933;">=</span> <span style="color: #0000dd;">0</span><span style="color: #339933;">;</span> i <span style="color: #339933;">&lt;</span> <span style="color: #0000dd;">4</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>motorPins<span style="color: #009900;">&#91;</span><span style="color: #009900;">&#40;</span>i<span style="color: #339933;">+</span><span style="color: #0000dd;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">%</span><span style="color:#800080;">4</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> HIGH<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      delayMicroseconds<span style="color: #009900;">&#40;</span>delayLength<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      digitalWrite<span style="color: #009900;">&#40;</span>motorPins<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> LOW<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      delayMicroseconds<span style="color: #009900;">&#40;</span>delayLength<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
  <span style="color: #009900;">&#125;</span>
&nbsp;
  delay<span style="color: #009900;">&#40;</span><span style="color: #0000dd;">100</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
  <span style="color: #666666; font-style: italic;">// then backward</span>
  <span style="color: #b1b100;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #993333;">unsigned</span> <span style="color: #993333;">char</span> j <span style="color: #339933;">=</span> <span style="color: #0000dd;">0</span><span style="color: #339933;">;</span> j <span style="color: #339933;">&lt;</span> rotations<span style="color: #339933;">;</span> j<span style="color: #339933;">++</span><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;">unsigned</span> <span style="color: #993333;">char</span> i <span style="color: #339933;">=</span> <span style="color: #0000dd;">0</span><span style="color: #339933;">;</span> i <span style="color: #339933;">&lt;</span> <span style="color: #0000dd;">4</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>motorPins<span style="color: #009900;">&#91;</span><span style="color: #0000dd;">3</span> <span style="color: #339933;">-</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span>i<span style="color: #339933;">+</span><span style="color: #0000dd;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">%</span><span style="color:#800080;">4</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> HIGH<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      delayMicroseconds<span style="color: #009900;">&#40;</span>delayLength<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      digitalWrite<span style="color: #009900;">&#40;</span>motorPins<span style="color: #009900;">&#91;</span><span style="color: #0000dd;">3</span><span style="color: #339933;">-</span>i<span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> LOW<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      delayMicroseconds<span style="color: #009900;">&#40;</span>delayLength<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
  <span style="color: #009900;">&#125;</span>
&nbsp;
  delay<span style="color: #009900;">&#40;</span><span style="color: #0000dd;">100</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.cibomahto.com/2010/02/stepping-quickly/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Converting an old organ to MIDI</title>
		<link>http://www.cibomahto.com/2010/01/converting-an-old-organ-to-midi/</link>
		<comments>http://www.cibomahto.com/2010/01/converting-an-old-organ-to-midi/#comments</comments>
		<pubDate>Thu, 28 Jan 2010 22:00:48 +0000</pubDate>
		<dc:creator>mahto</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.cibomahto.com/?p=737</guid>
		<description><![CDATA[You might remember that some years ago, I found a discarded organ and brought it home. Well, it sat around for a year, then I converted it to MIDI, then I moved across the country and only brought the keyboards, &#8230; <a href="http://www.cibomahto.com/2010/01/converting-an-old-organ-to-midi/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p><object width="600" height="486"><param name="movie" value="http://www.youtube.com/v/4Q3APTV6idk&#038;hl=en&#038;start=0&#038;fs=1&#038;rel=0&#038;showinfo=0&#038;ap=%2526fmt%3D18"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/4Q3APTV6idk&#038;hl=en&#038;start=0&#038;fs=1&#038;rel=0&#038;showinfo=0&#038;ap=%2526fmt%3D18" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="600" height="486"></embed></object></p>
<p>You might remember that some years ago, I <a href="http://www.cibomahto.com/2008/06/lucky-find/">found a discarded organ</a> and brought it home.  Well, it sat around for a year, then I <a href="http://www.youtube.com/watch?v=IoBeOZTkpnE">converted it to MIDI</a>, then I moved across the country and only brought the keyboards, and finally I re-built it as the proper single-row unit featured in the above video.</p>
<p>The keys are laid out as a generic <a href="http://en.wikipedia.org/wiki/Keyboard_matrix_%28music%29">matrix-style keyboard</a>, with a column for every note in an octave (12 in total), and a row for each octave bank (up to ten, although only 8 are in use).  Using a <a href="http://www.moderndevice.com/products/bbb-kit">Barebones</a> Arduino clone and a couple of I/O expander chips (PCF854AN) for extra digital pins, I was able to convert the old keyboard into a MIDI device.  This version works fine, however the circuit is a bit extravagant- If I ever re-build it, I will use a 3-to-8 line decoder for the select lines, which should free up enough digital pins on the Arduino to be able to get rid of the I/O expander chips.  Really, though, I would prefer to convert it into a velocity sensitive keyboard, so any further effort will be in that direction.  Rough schematic and source code after the break.</p>
<p><span id="more-737"></span><br />
<a href="http://www.cibomahto.com/wp-content/uploads/2010/01/keyboard_schematic.jpg"><img src="http://www.cibomahto.com/wp-content/uploads/2010/01/keyboard_schematic.jpg" alt="" title="keyboard_schematic" class="alignnone size-full wp-image-746" /></a></p>

<div class="wp_syntax"><div class="code"><pre class="c" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">// Sketch to convert an older electric organ (Eminent S20) into a MIDI instrument.</span>
<span style="color: #666666; font-style: italic;">// By Matt Mets, completed in 2009</span>
<span style="color: #666666; font-style: italic;">//</span>
<span style="color: #666666; font-style: italic;">// This code is released into the public domain.  Attribution is appreciated.</span>
<span style="color: #666666; font-style: italic;">//</span>
<span style="color: #666666; font-style: italic;">// MIDI source code from the ITP website:</span>
<span style="color: #666666; font-style: italic;">// http://itp.nyu.edu/physcomp/Labs/MIDIOutput</span>
&nbsp;
<span style="color: #339933;">#include &lt;Wire.h&gt;</span>
&nbsp;
&nbsp;
<span style="color: #339933;">#define LEDpin 13                  // Just the standard output LED</span>
<span style="color: #339933;">#define volumePedal 1              // The analog input for the volume control</span>
&nbsp;
<span style="color: #993333;">char</span> velocity<span style="color: #339933;">;</span>                     <span style="color: #666666; font-style: italic;">// Use the foot pedal to determine this</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// Define the MIDI channels that each instrument transmits on</span>
<span style="color: #339933;">#define keyboardChannel 0</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// Number of key banks to scan.  There are eight 'normal' key banks, and 2 special ones.</span>
<span style="color: #339933;">#define numKeyBanks 8</span>
<span style="color: #339933;">#define numKeysPerBank 12</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// Lookup table, used to determine the select line to turn on to read the keys in that key bank.</span>
<span style="color: #993333;">static</span> <span style="color: #993333;">char</span> keyBankSelectLines<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;">2</span><span style="color: #339933;">,</span><span style="color: #0000dd;">3</span><span style="color: #339933;">,</span><span style="color: #0000dd;">4</span><span style="color: #339933;">,</span><span style="color: #0000dd;">5</span><span style="color: #339933;">,</span><span style="color: #0000dd;">6</span><span style="color: #339933;">,</span><span style="color: #0000dd;">7</span><span style="color: #339933;">,</span><span style="color: #0000dd;">8</span><span style="color: #339933;">,</span><span style="color: #0000dd;">11</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// Storage for the previous value of each bank of keys.  There are 10 access lines, with a maximum of 12 inputs per line.</span>
<span style="color: #666666; font-style: italic;">// The 12 bits of data on each line are split into low and high banks.</span>
<span style="color: #993333;">unsigned</span> <span style="color: #993333;">char</span> noteStatesL<span style="color: #009900;">&#91;</span>numKeyBanks<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
<span style="color: #993333;">unsigned</span> <span style="color: #993333;">char</span> noteStatesH<span style="color: #009900;">&#91;</span>numKeyBanks<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// Storage for the instrument data associated with each key.  Must be filled in at startup.</span>
<span style="color: #993333;">unsigned</span> <span style="color: #993333;">char</span> noteChannels<span style="color: #009900;">&#91;</span>numKeyBanks<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span>numKeysPerBank<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
<span style="color: #993333;">unsigned</span> <span style="color: #993333;">char</span> noteValues<span style="color: #009900;">&#91;</span>numKeyBanks<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span>numKeysPerBank<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
&nbsp;
&nbsp;
<span style="color: #666666; font-style: italic;">// Initialize IO ports</span>
<span style="color: #993333;">void</span> setup<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
  <span style="color: #666666; font-style: italic;">// Setup the I2C bus (analog pins 4&amp;5) in master mode.  This bus is used to talk to the IO expander chips.</span>
  Wire.<span style="color: #202020;">begin</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
  <span style="color: #666666; font-style: italic;">//  Set the serial port to the correct baud rate for MIDI</span>
  Serial.<span style="color: #202020;">begin</span><span style="color: #009900;">&#40;</span><span style="color: #0000dd;">31250</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
  <span style="color: #666666; font-style: italic;">// Set all initial note bank vales to 0</span>
  <span style="color: #b1b100;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #993333;">unsigned</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;">&lt;</span> numKeyBanks<span style="color: #339933;">;</span> i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    noteStatesL<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000dd;">0</span><span style="color: #339933;">;</span>
    noteStatesH<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000dd;">0</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
&nbsp;
  pinMode<span style="color: #009900;">&#40;</span>LEDpin<span style="color: #339933;">,</span> OUTPUT<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>    <span style="color: #666666; font-style: italic;">// Status LED</span>
&nbsp;
  <span style="color: #666666; font-style: italic;">// Set all of the bank select lines to outputs</span>
  <span style="color: #b1b100;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #993333;">unsigned</span> <span style="color: #993333;">char</span> bankNo <span style="color: #339933;">=</span> <span style="color: #0000dd;">0</span><span style="color: #339933;">;</span> bankNo <span style="color: #339933;">&lt;</span> numKeyBanks<span style="color: #339933;">;</span> bankNo<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    pinMode<span style="color: #009900;">&#40;</span>keyBankSelectLines<span style="color: #009900;">&#91;</span>bankNo<span style="color: #009900;">&#93;</span><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: #666666; font-style: italic;">// Set up the instrument data for the keys</span>
&nbsp;
  <span style="color: #666666; font-style: italic;">// first off, clear everything.</span>
  <span style="color: #b1b100;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #993333;">unsigned</span> <span style="color: #993333;">char</span> bank <span style="color: #339933;">=</span> <span style="color: #0000dd;">0</span><span style="color: #339933;">;</span> bank <span style="color: #339933;">&lt;</span> numKeyBanks<span style="color: #339933;">;</span> bank <span style="color: #339933;">++</span><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;">unsigned</span> <span style="color: #993333;">char</span> key <span style="color: #339933;">=</span> <span style="color: #0000dd;">0</span><span style="color: #339933;">;</span> key <span style="color: #339933;">&lt;</span> numKeysPerBank<span style="color: #339933;">;</span> key<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      noteChannels<span style="color: #009900;">&#91;</span>bank<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span>key<span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000dd;">0</span><span style="color: #339933;">;</span>
      noteValues<span style="color: #009900;">&#91;</span>bank<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span>key<span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000dd;">0</span><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;">// The bottom half of the keyboard comprised of banks 4-6, starting at F</span>
  <span style="color: #993333;">unsigned</span> <span style="color: #993333;">char</span> noteValue <span style="color: #339933;">=</span> <span style="color: #0000dd;">24</span><span style="color: #339933;">;</span>    <span style="color: #666666; font-style: italic;">// Octave 2, C note</span>
  <span style="color: #b1b100;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #993333;">unsigned</span> <span style="color: #993333;">char</span> bank <span style="color: #339933;">=</span> <span style="color: #0000dd;">4</span><span style="color: #339933;">;</span> bank <span style="color: #339933;">&lt;</span> <span style="color: #0000dd;">7</span><span style="color: #339933;">;</span> bank <span style="color: #339933;">++</span><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;">unsigned</span> <span style="color: #993333;">char</span> key <span style="color: #339933;">=</span> <span style="color: #0000dd;">0</span><span style="color: #339933;">;</span> key <span style="color: #339933;">&lt;</span> <span style="color: #0000dd;">12</span><span style="color: #339933;">;</span> key<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      noteChannels<span style="color: #009900;">&#91;</span>bank<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span>key<span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> keyboardChannel<span style="color: #339933;">;</span>
      noteValues<span style="color: #009900;">&#91;</span>bank<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span>key<span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> noteValue<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;">// The top keyboard row is comprised of banks 0-3, starting at F</span>
  <span style="color: #b1b100;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #993333;">unsigned</span> <span style="color: #993333;">char</span> bank <span style="color: #339933;">=</span> <span style="color: #0000dd;">0</span><span style="color: #339933;">;</span> bank <span style="color: #339933;">&lt;</span> <span style="color: #0000dd;">4</span><span style="color: #339933;">;</span> bank <span style="color: #339933;">++</span><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;">unsigned</span> <span style="color: #993333;">char</span> key <span style="color: #339933;">=</span> <span style="color: #0000dd;">0</span><span style="color: #339933;">;</span> key <span style="color: #339933;">&lt;</span> <span style="color: #0000dd;">12</span><span style="color: #339933;">;</span> key<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      noteChannels<span style="color: #009900;">&#91;</span>bank<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span>key<span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> keyboardChannel<span style="color: #339933;">;</span>
      noteValues<span style="color: #009900;">&#91;</span>bank<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span>key<span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> noteValue<span style="color: #339933;">++;</span>
    <span style="color: #009900;">&#125;</span>
  <span style="color: #009900;">&#125;</span>
  <span style="color: #666666; font-style: italic;">// And one extra one on bank 9 note 1</span>
  noteChannels<span style="color: #009900;">&#91;</span><span style="color: #0000dd;">7</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #0000dd;">1</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> keyboardChannel<span style="color: #339933;">;</span>
  noteValues<span style="color: #009900;">&#91;</span><span style="color: #0000dd;">7</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #0000dd;">1</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> noteValue<span style="color: #339933;">++;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//  Send a MIDI command.</span>
<span style="color: #666666; font-style: italic;">//  cmd is the command and channel (0x90 for channel 1 note on)</span>
<span style="color: #666666; font-style: italic;">//  data1 is the note</span>
<span style="color: #666666; font-style: italic;">//  data2 is the velocity</span>
<span style="color: #993333;">void</span> midiCommand<span style="color: #009900;">&#40;</span><span style="color: #993333;">char</span> cmd<span style="color: #339933;">,</span> <span style="color: #993333;">char</span> data1<span style="color: #339933;">,</span> <span style="color: #993333;">char</span> data2<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  Serial.<span style="color: #202020;">print</span><span style="color: #009900;">&#40;</span>cmd<span style="color: #339933;">,</span> BYTE<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  Serial.<span style="color: #202020;">print</span><span style="color: #009900;">&#40;</span>data1<span style="color: #339933;">,</span> BYTE<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  Serial.<span style="color: #202020;">print</span><span style="color: #009900;">&#40;</span>data2<span style="color: #339933;">,</span> BYTE<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// Map an integer into a charater given a set range</span>
<span style="color: #993333;">unsigned</span> <span style="color: #993333;">char</span> mapInteger<span style="color: #009900;">&#40;</span><span style="color: #993333;">int</span> input<span style="color: #339933;">,</span> <span style="color: #993333;">int</span> min<span style="color: #339933;">,</span> <span style="color: #993333;">int</span> max<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  <span style="color: #b1b100;">return</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span>input <span style="color: #339933;">-</span> min<span style="color: #009900;">&#41;</span><span style="color: #339933;">*</span><span style="color: #0000dd;">255</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">/</span><span style="color: #009900;">&#40;</span>max<span style="color: #339933;">-</span>min<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
&nbsp;
<span style="color: #666666; font-style: italic;">// Main loop</span>
<span style="color: #993333;">unsigned</span> <span style="color: #993333;">char</span> newNoteStateL<span style="color: #339933;">;</span>
<span style="color: #993333;">unsigned</span> <span style="color: #993333;">char</span> newNoteStateH<span style="color: #339933;">;</span>
&nbsp;
<span style="color: #993333;">void</span> loop<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span> 
  <span style="color: #666666; font-style: italic;">// Read the velocity in</span>
<span style="color: #666666; font-style: italic;">//  velocity = mapInteger(analogRead(volumePedal),400,900);</span>
  velocity <span style="color: #339933;">=</span> <span style="color: #0000dd;">90</span><span style="color: #339933;">;</span>
&nbsp;
  <span style="color: #b1b100;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #993333;">char</span> bankNo <span style="color: #339933;">=</span> <span style="color: #0000dd;">0</span><span style="color: #339933;">;</span> bankNo <span style="color: #339933;">&lt;</span> numKeyBanks<span style="color: #339933;">;</span> bankNo<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
    digitalWrite<span style="color: #009900;">&#40;</span>keyBankSelectLines<span style="color: #009900;">&#91;</span>bankNo<span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> HIGH<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>    <span style="color: #666666; font-style: italic;">// Select the key bank</span>
&nbsp;
    Wire.<span style="color: #202020;">requestFrom</span><span style="color: #009900;">&#40;</span><span style="color: #208080;">0x38</span><span style="color: #339933;">,</span> <span style="color: #0000dd;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>                      <span style="color: #666666; font-style: italic;">// Read the low data</span>
    <span style="color: #b1b100;">while</span> <span style="color: #009900;">&#40;</span>Wire.<span style="color: #202020;">available</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      newNoteStateL <span style="color: #339933;">=</span> Wire.<span style="color: #202020;">receive</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    Wire.<span style="color: #202020;">requestFrom</span><span style="color: #009900;">&#40;</span><span style="color: #208080;">0x39</span><span style="color: #339933;">,</span> <span style="color: #0000dd;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>                      <span style="color: #666666; font-style: italic;">// Read the high data</span>
    <span style="color: #b1b100;">while</span> <span style="color: #009900;">&#40;</span>Wire.<span style="color: #202020;">available</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      newNoteStateH <span style="color: #339933;">=</span> Wire.<span style="color: #202020;">receive</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    digitalWrite<span style="color: #009900;">&#40;</span>keyBankSelectLines<span style="color: #009900;">&#91;</span>bankNo<span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> LOW<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>     <span style="color: #666666; font-style: italic;">// Deselect the key bank</span>
&nbsp;
    <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>newNoteStateL <span style="color: #339933;">!=</span> noteStatesL<span style="color: #009900;">&#91;</span>bankNo<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>      <span style="color: #666666; font-style: italic;">// Check if any notes in this bank are different</span>
      <span style="color: #993333;">char</span> stateDelta <span style="color: #339933;">=</span> newNoteStateL <span style="color: #339933;">^</span> noteStatesL<span style="color: #009900;">&#91;</span>bankNo<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
      <span style="color: #b1b100;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #993333;">unsigned</span> <span style="color: #993333;">char</span> i <span style="color: #339933;">=</span> <span style="color: #0000dd;">0</span><span style="color: #339933;">;</span> i <span style="color: #339933;">&lt;</span> <span style="color: #0000dd;">8</span><span style="color: #339933;">;</span> i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span>stateDelta <span style="color: #339933;">&gt;&gt;</span> i<span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;</span> <span style="color: #0000dd;">1</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
          <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span>newNoteStateL <span style="color: #339933;">&gt;&gt;</span> i<span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;</span> <span style="color: #0000dd;">1</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #666666; font-style: italic;">// Send a MIDI on message</span>
            midiCommand<span style="color: #009900;">&#40;</span><span style="color: #208080;">0x90</span> <span style="color: #339933;">+</span> noteChannels<span style="color: #009900;">&#91;</span>bankNo<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> noteValues<span style="color: #009900;">&#91;</span>bankNo<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> velocity<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
          <span style="color: #009900;">&#125;</span>
          <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #666666; font-style: italic;">// Send a MIDI off message</span>
            midiCommand<span style="color: #009900;">&#40;</span><span style="color: #208080;">0x80</span> <span style="color: #339933;">+</span> noteChannels<span style="color: #009900;">&#91;</span>bankNo<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> noteValues<span style="color: #009900;">&#91;</span>bankNo<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> velocity<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
          <span style="color: #009900;">&#125;</span>
        <span style="color: #009900;">&#125;</span>
      <span style="color: #009900;">&#125;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>newNoteStateH <span style="color: #339933;">!=</span> noteStatesH<span style="color: #009900;">&#91;</span>bankNo<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>      <span style="color: #666666; font-style: italic;">// Check if any notes in this bank are different</span>
      digitalWrite<span style="color: #009900;">&#40;</span>LEDpin<span style="color: #339933;">,</span> HIGH<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      <span style="color: #993333;">char</span> stateDelta <span style="color: #339933;">=</span> newNoteStateH <span style="color: #339933;">^</span> noteStatesH<span style="color: #009900;">&#91;</span>bankNo<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
      <span style="color: #b1b100;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #993333;">unsigned</span> <span style="color: #993333;">char</span> i <span style="color: #339933;">=</span> <span style="color: #0000dd;">0</span><span style="color: #339933;">;</span> i <span style="color: #339933;">&lt;</span> <span style="color: #0000dd;">8</span><span style="color: #339933;">;</span> i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span>stateDelta <span style="color: #339933;">&gt;&gt;</span> i<span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;</span> <span style="color: #0000dd;">1</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
          <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span>newNoteStateH <span style="color: #339933;">&gt;&gt;</span> i<span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;</span> <span style="color: #0000dd;">1</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #666666; font-style: italic;">// Send a MIDI on message</span>
            midiCommand<span style="color: #009900;">&#40;</span><span style="color: #208080;">0x90</span> <span style="color: #339933;">+</span> noteChannels<span style="color: #009900;">&#91;</span>bankNo<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span>i<span style="color: #339933;">+</span><span style="color: #0000dd;">8</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> noteValues<span style="color: #009900;">&#91;</span>bankNo<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span>i<span style="color: #339933;">+</span><span style="color: #0000dd;">8</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> velocity<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
          <span style="color: #009900;">&#125;</span>
          <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #666666; font-style: italic;">// Send a MIDI off message</span>
            midiCommand<span style="color: #009900;">&#40;</span><span style="color: #208080;">0x80</span> <span style="color: #339933;">+</span> noteChannels<span style="color: #009900;">&#91;</span>bankNo<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span>i<span style="color: #339933;">+</span><span style="color: #0000dd;">8</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> noteValues<span style="color: #009900;">&#91;</span>bankNo<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span>i<span style="color: #339933;">+</span><span style="color: #0000dd;">8</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> velocity<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
          <span style="color: #009900;">&#125;</span>
        <span style="color: #009900;">&#125;</span>
      <span style="color: #009900;">&#125;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    noteStatesL<span style="color: #009900;">&#91;</span>bankNo<span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> newNoteStateL<span style="color: #339933;">;</span>
    noteStatesH<span style="color: #009900;">&#91;</span>bankNo<span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> newNoteStateH<span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.cibomahto.com/2010/01/converting-an-old-organ-to-midi/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Machine code Mario</title>
		<link>http://www.cibomahto.com/2010/01/machine-code-mario/</link>
		<comments>http://www.cibomahto.com/2010/01/machine-code-mario/#comments</comments>
		<pubDate>Wed, 06 Jan 2010 20:52:02 +0000</pubDate>
		<dc:creator>mahto</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.cibomahto.com/?p=677</guid>
		<description><![CDATA[Here&#8217;s an image of Mario, drawn using the machine code for Super Mario Brothers. Created using C++, the EasyBMP library and the GIMP. Source code after the break. This program reads in a ROM file, and creates an image out &#8230; <a href="http://www.cibomahto.com/2010/01/machine-code-mario/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.flickr.com/photos/cibomahto/4251355789/" title="Machine code Mario by cibomahto, on Flickr"><img src="http://farm5.static.flickr.com/4048/4251355789_f4a5cecf03_o.jpg" width="496" height="664" alt="Machine code Mario" /></a></p>
<p>Here&#8217;s an image of Mario, drawn using the machine code for Super Mario Brothers.  Created using <a href="http://gcc.gnu.org/">C++</a>, the <a href="http://easybmp.sourceforge.net/">EasyBMP library</a> and the <a href="http://www.gimp.org/">GIMP</a>.  Source code after the break.<br />
<span id="more-677"></span><br />
This program reads in a ROM file, and creates an image out of it using the specified aspect ratio.    Each byte is drawn as a column of 8 pixels, which are arranged into rows and then columns to fill the space.  Once the image is generated, I created the color overlay in GIMP by resizing and placing a sprite from the game in a separate layer, with mode set to &#8216;Screen&#8217;.</p>

<div class="wp_syntax"><div class="code"><pre class="c" style="font-family:monospace;"><span style="color: #339933;">#include &lt;iostream&gt;</span>
<span style="color: #339933;">#include &lt;fstream&gt;</span>
<span style="color: #339933;">#include &lt;cmath&gt;            // for square root</span>
<span style="color: #339933;">#include &lt;sys/stat.h&gt;       // For file size</span>
<span style="color: #339933;">#include &quot;easybmp/EasyBMP.h&quot;</span>
&nbsp;
<span style="color: #993333;">int</span> main<span style="color: #009900;">&#40;</span><span style="color: #993333;">int</span> argc<span style="color: #339933;">,</span> <span style="color: #993333;">char</span><span style="color: #339933;">**</span> argv<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #666666; font-style: italic;">// Rom info</span>
    <span style="color: #993333;">char</span> fileName<span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #ff0000;">&quot;smb.nes&quot;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #666666; font-style: italic;">// Desired aspect ratio</span>
    <span style="color: #993333;">float</span> aspectRatio <span style="color: #339933;">=</span>  <span style="color:#800080;">1.333</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #666666; font-style: italic;">// Determine the file size</span>
    <span style="color: #993333;">int</span> romByteSize <span style="color: #339933;">=</span> <span style="color: #0000dd;">0</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #993333;">struct</span> stat results<span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>stat<span style="color: #009900;">&#40;</span>fileName<span style="color: #339933;">,</span> <span style="color: #339933;">&amp;</span>results<span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> <span style="color: #0000dd;">0</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        romByteSize <span style="color: #339933;">=</span> results.<span style="color: #202020;">st_size</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
    <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
        std<span style="color: #339933;">::</span><span style="color: #000066;">cout</span> <span style="color: #339933;">&lt;&lt;</span> <span style="color: #ff0000;">&quot;Sorry, could not determine file length!&quot;</span> <span style="color: #339933;">&lt;&lt;</span> std<span style="color: #339933;">::</span><span style="color: #202020;">endl</span><span style="color: #339933;">;</span>
        <span style="color: #b1b100;">return</span> <span style="color: #0000dd;">1</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #666666; font-style: italic;">// Determine the height and with to achieve the proper aspect ratio</span>
    <span style="color: #666666; font-style: italic;">// we know:</span>
    <span style="color: #666666; font-style: italic;">//    h/w = aspectRatio/8</span>
    <span style="color: #666666; font-style: italic;">//    h*w = romByteSize</span>
    <span style="color: #666666; font-style: italic;">// So:</span>
    <span style="color: #666666; font-style: italic;">//    h = aspectRatio*w</span>
    <span style="color: #666666; font-style: italic;">//    h = romByteSize/w</span>
    <span style="color: #666666; font-style: italic;">//    w^2 = romByteSize / (aspectRatio/8)</span>
&nbsp;
    <span style="color: #993333;">int</span> imageWidth <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span><span style="color: #993333;">int</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#40;</span>sqrt<span style="color: #009900;">&#40;</span>romByteSize <span style="color: #339933;">/</span> <span style="color: #009900;">&#40;</span>aspectRatio<span style="color: #339933;">/</span><span style="color: #0000dd;">8</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">+</span><span style="color:#800080;">.5</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #993333;">int</span> imageHeight <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>aspectRatio<span style="color: #009900;">&#41;</span><span style="color: #339933;">*</span>imageWidth <span style="color: #339933;">-</span> <span style="color: #009900;">&#40;</span><span style="color: #993333;">int</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span>aspectRatio<span style="color: #009900;">&#41;</span><span style="color: #339933;">*</span>imageWidth<span style="color: #009900;">&#41;</span><span style="color: #339933;">%</span><span style="color:#800080;">8</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span> <span style="color: #0000dd;">8</span><span style="color: #339933;">;</span>
&nbsp;
    std<span style="color: #339933;">::</span><span style="color: #000066;">cout</span> <span style="color: #339933;">&lt;&lt;</span> <span style="color: #ff0000;">&quot;romByteSize=&quot;</span> <span style="color: #339933;">&lt;&lt;</span> romByteSize
              <span style="color: #339933;">&lt;&lt;</span> <span style="color: #ff0000;">&quot; imageWidth=&quot;</span> <span style="color: #339933;">&lt;&lt;</span> imageWidth
              <span style="color: #339933;">&lt;&lt;</span> <span style="color: #ff0000;">&quot; imageHeight=&quot;</span> <span style="color: #339933;">&lt;&lt;</span> imageHeight
              <span style="color: #339933;">&lt;&lt;</span> std<span style="color: #339933;">::</span><span style="color: #202020;">endl</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #666666; font-style: italic;">// Open the binary</span>
    std<span style="color: #339933;">::</span><span style="color: #202020;">ifstream</span> myFile <span style="color: #009900;">&#40;</span>fileName<span style="color: #339933;">,</span> std<span style="color: #339933;">::</span><span style="color: #202020;">ios</span><span style="color: #339933;">::</span><span style="color: #202020;">in</span> <span style="color: #339933;">|</span> std<span style="color: #339933;">::</span><span style="color: #202020;">ios</span><span style="color: #339933;">::</span><span style="color: #202020;">binary</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span>myFile<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        std<span style="color: #339933;">::</span><span style="color: #000066;">cout</span> <span style="color: #339933;">&lt;&lt;</span> <span style="color: #ff0000;">&quot;Sorry, couldn't open file for reading!&quot;</span> <span style="color: #339933;">&lt;&lt;</span> std<span style="color: #339933;">::</span><span style="color: #202020;">endl</span><span style="color: #339933;">;</span>
        <span style="color: #b1b100;">return</span> <span style="color: #0000dd;">1</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #666666; font-style: italic;">// Create a bitmap to hold the image</span>
    BMP Output<span style="color: #339933;">;</span>
    Output.<span style="color: #202020;">SetSize</span><span style="color: #009900;">&#40;</span> imageWidth<span style="color: #339933;">,</span> imageHeight <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    Output.<span style="color: #202020;">SetBitDepth</span><span style="color: #009900;">&#40;</span> <span style="color: #0000dd;">1</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #666666; font-style: italic;">// Copy the image data over, byte by byte</span>
    RGBApixel blackPixel <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span><span style="color: #0000dd;">0</span><span style="color: #339933;">,</span><span style="color: #0000dd;">0</span><span style="color: #339933;">,</span><span style="color: #0000dd;">0</span><span style="color: #339933;">,</span><span style="color: #0000dd;">0</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #b1b100;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #993333;">int</span> pos <span style="color: #339933;">=</span> <span style="color: #0000dd;">0</span><span style="color: #339933;">;</span> pos <span style="color: #339933;">&lt;</span> romByteSize<span style="color: #339933;">;</span> pos<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #993333;">char</span> byte<span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span>myFile.<span style="color: #202020;">read</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">&amp;</span>byte<span style="color: #339933;">,</span> <span style="color: #0000dd;">1</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            std<span style="color: #339933;">::</span><span style="color: #000066;">cout</span> <span style="color: #339933;">&lt;&lt;</span> <span style="color: #ff0000;">&quot;read error, bailing.  pos=&quot;</span> <span style="color: #339933;">&lt;&lt;</span> pos <span style="color: #339933;">&lt;&lt;</span> std<span style="color: #339933;">::</span><span style="color: #202020;">endl</span><span style="color: #339933;">;</span>
            <span style="color: #b1b100;">return</span> <span style="color: #0000dd;">1</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
&nbsp;
        <span style="color: #993333;">int</span> Col <span style="color: #339933;">=</span> pos<span style="color: #339933;">%</span>imageWidth<span style="color: #339933;">;</span>
        <span style="color: #993333;">int</span> baseRow <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>pos<span style="color: #339933;">/</span>imageWidth<span style="color: #009900;">&#41;</span><span style="color: #339933;">*</span><span style="color: #0000dd;">8</span><span style="color: #339933;">;</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;">&lt;</span> <span style="color: #0000dd;">8</span><span style="color: #339933;">;</span> i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span>byte <span style="color: #339933;">&gt;&gt;</span> <span style="color: #009900;">&#40;</span><span style="color: #0000dd;">7</span><span style="color: #339933;">-</span>i<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;</span> <span style="color: #0000dd;">1</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
                Output.<span style="color: #202020;">SetPixel</span><span style="color: #009900;">&#40;</span> Col<span style="color: #339933;">,</span> baseRow <span style="color: #339933;">+</span> i<span style="color: #339933;">,</span> blackPixel <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #009900;">&#125;</span>
        <span style="color: #009900;">&#125;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #666666; font-style: italic;">// Then write it to a file</span>
    Output.<span style="color: #202020;">WriteToFile</span><span style="color: #009900;">&#40;</span> <span style="color: #ff0000;">&quot;rom_image.bmp&quot;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #b1b100;">return</span> <span style="color: #0000dd;">0</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.cibomahto.com/2010/01/machine-code-mario/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Come and learn about Soft Circuits!</title>
		<link>http://www.cibomahto.com/2009/10/come-and-learn-about-soft-circuits/</link>
		<comments>http://www.cibomahto.com/2009/10/come-and-learn-about-soft-circuits/#comments</comments>
		<pubDate>Wed, 21 Oct 2009 05:25:02 +0000</pubDate>
		<dc:creator>mahto</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.cibomahto.com/?p=626</guid>
		<description><![CDATA[Now, I know you all are just itching to pay me* to teach you stuff, so here is your chance! I&#8217;m co-teaching an introductory Soft Circuits workshop with Elizabeth Perry next month on Saturday, November 14th, so be sure to &#8230; <a href="http://www.cibomahto.com/2009/10/come-and-learn-about-soft-circuits/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.flickr.com/photos/cibomahto/2987802961/" title="Becky Stern's Soft Circuit Embroidery Workshop @ SMoCA by cibomahto, on Flickr"><img src="http://farm4.static.flickr.com/3185/2987802961_9527cc12fe.jpg" width="500" height="331" alt="Becky Stern's Soft Circuit Embroidery Workshop @ SMoCA" /></a><br />
Now, I know you all are just itching to pay me* to teach you stuff, so here is your chance!  I&#8217;m co-teaching an introductory Soft Circuits workshop with <a href="http://www.elizabethperry.com/">Elizabeth Perry</a> next month on Saturday, November 14th, so be sure to be there!  <a href="http://www.eventbrite.com/event/468380940">Tickets are available now</a> for the low low price of $40 ($30 for HackPGH members), which even includes materials!  Take advantage of this sweet offer before I become famous and charge you $1000 just for a signature!</p>
<p>We will be making a light-up cuff bracelet using industrial felt, batteries and LEDs, with a button for a switch.  No previous experience with sewing, electronics, computing, or soldering is needed.  It&#8217;s guaranteed** to be a fun time!</p>
<p>*Actually, all proceeds go to making Hack Pittsburgh an awesome place to be, but if you want you can also <a href="http://www.amazon.com/gp/registry/wishlist/34N7F1EA2ZV2L/">buy me a book</a> or something.<br />
**Guaranteed by design!</p>
<p>[photo above is by me, of a workshop held by Becky Stern]</p>
]]></content:encoded>
			<wfw:commentRss>http://www.cibomahto.com/2009/10/come-and-learn-about-soft-circuits/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
